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.

feat(infra): add safe Dokploy deployment recovery

Rahman6b71cac06145
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 034e1f44..a18387a1 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**
+- `infra` add safe Dokploy deployment recovery
- `infra` manage Convex Cloud custom domains safely
- `infra` add bounded Dokploy public env rollout
diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md
index 972b7084..b6b3ee4d 100644
--- a/docs/PROGRESS.md
+++ b/docs/PROGRESS.md
@@ -2794,3 +2794,8 @@ Screenshot evidence previously lived in unrelated scratch directories or only in
- Added a native `convex-cloud` CLI credential import that reads only `~/.convex/config.json`, refuses symlink/non-owner inputs, hardens the local credential directory/file to `0700/0600`, validates the token before saving, and never returns the credential.
- Added bounded exact-connection operations for listing/ensuring Convex custom domains and reading/updating canonical `convexCloud` / `convexSite` URLs. Canonical operations mint a scoped short-lived deploy key and revoke it in `finally`; custom canonical URLs must already be registered and verified.
- The operations stay behind `integration_execute` / `integration_manage`; no generic Convex HTTP escape hatch and no new global MCP tool were added.
+
+### 2026-09-06 — Dokploy deployment diagnostics + safe public Git recovery
+- Added bounded deployment-history and redacted deployment-log reads for Dokploy applications, using the official `deployment.all` / `deployment.readLogs` APIs.
+- Added `dokploy.git.recover`: for an application currently configured as a Dokploy GitHub source, derive a public HTTPS GitHub URL only from its existing validated owner/repository metadata, preserve branch/build path/watch paths/submodule settings, verify the source became generic `git`, then queue one redeploy. No arbitrary Git/SSH URL input is accepted.
+- Internal provider diagnostics remain out of the compact MCP schema; only the bounded deployment list/log and recovery operations are exposed.
diff --git a/lib/infra/clients.ts b/lib/infra/clients.ts
index 69c98015..8688b79d 100644
--- a/lib/infra/clients.ts
+++ b/lib/infra/clients.ts
@@ -9,7 +9,7 @@ import { doctorHostinger } from "./hostinger";
import { doctorComposio } from "./composio";
export { listCloudflareZones, upsertCloudflareDns } from "./cloudflare";
-export { ensureDokployProject, listDokployProjects, listDokployApplications, upsertDokployPublicBuildEnv } from "./dokploy";
+export { ensureDokployProject, listDokployProjects, listDokployApplications, listDokployDeployments, readDokployDeploymentLogs, inspectDokployApplication, listDokployGitProviders, inspectDokployGithubProvider, testDokployGithubProvider, recoverDokployPublicGithubToHttpsGit, upsertDokployPublicBuildEnv } from "./dokploy";
export { upsertHostingerDns } from "./hostinger";
export { listHostingerMailOrders, getHostingerMailPlan, listHostingerMail, listHostingerMailLogs, mutateHostingerMail } from "./hostinger-mail";
diff --git a/lib/infra/connection-dispatch.ts b/lib/infra/connection-dispatch.ts
index d6241623..4c067820 100644
--- a/lib/infra/connection-dispatch.ts
+++ b/lib/infra/connection-dispatch.ts
@@ -4,7 +4,7 @@ import { authorizeIntegration, composioConnectionCall } from "./connection-exter
import { IntegrationError, identity, metadataOnly, type ConnectionSelector } from "./identity";
import { importConvexCliPersonalConnection } from "./convex-cli-import";
import { listConvexCustomDomains, ensureConvexCustomDomain, getConvexCanonicalUrls, setConvexCanonicalUrl } from "./convex-cloud";
-import { doctorInfraProvider, ensureDokployProject, listDokployApplications, listDokployProjects, listCloudflareZones, upsertCloudflareDns, upsertDokployPublicBuildEnv, upsertHostingerDns, listHostingerMailOrders, getHostingerMailPlan, listHostingerMail, listHostingerMailLogs, mutateHostingerMail } from "./clients";
+import { doctorInfraProvider, ensureDokployProject, listDokployApplications, listDokployDeployments, readDokployDeploymentLogs, recoverDokployPublicGithubToHttpsGit, listDokployProjects, listCloudflareZones, upsertCloudflareDns, upsertDokployPublicBuildEnv, upsertHostingerDns, listHostingerMailOrders, getHostingerMailPlan, listHostingerMail, listHostingerMailLogs, mutateHostingerMail } from "./clients";
import { isInfraProviderId } from "./catalog";
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});
@@ -39,6 +39,9 @@ export async function executeIntegrationAction(raw: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.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.publicEnv.upsert":{provider:"dokploy",fields:["applicationId","key","value"],run:()=>upsertDokployPublicBuildEnv(args as {applicationId:string;key:string;value:string})},
"dokploy.project.ensure":{provider:"dokploy",fields:["name"],run:()=>ensureDokployProject(String((args as Record<string,unknown>).name))},
"convex.customDomains.list":{provider:"convex-cloud",fields:["deploymentName"],run:()=>listConvexCustomDomains(String((args as Record<string,unknown>).deploymentName))},
diff --git a/lib/infra/dokploy-deployment-read.test.ts b/lib/infra/dokploy-deployment-read.test.ts
new file mode 100644
index 00000000..b2817c1a
--- /dev/null
+++ b/lib/infra/dokploy-deployment-read.test.ts
@@ -0,0 +1,54 @@
+import { afterEach, beforeEach, expect, it, vi } from "vitest";
+import { promises as fs } from "node:fs";
+import os from "node:os";
+import path from "node:path";
+
+let root:string;
+const KEY="synthetic_dokploy_key_123456789";
+beforeEach(async()=>{root=await fs.mkdtemp(path.join(os.tmpdir(),"mso-dokploy-read-"));process.env.OS_INFRA_STORE=path.join(root,"infra.json");vi.resetModules();});
+afterEach(async()=>{delete process.env.OS_INFRA_STORE;vi.unstubAllGlobals();await fs.rm(root,{recursive:true,force:true});vi.resetModules();});
+async function seeded(){
+ const {integrationManage}=await import("./connection-manage");
+ await integrationManage({action:"user.create",user:"alice",confirm:true});
+ await integrationManage({action:"connection.create",user:"alice",provider:"dokploy",connection:"work",authMethod:"direct",source:"direct",confirm:true});
+ const {withIntegrationSelection}=await import("./connection-service"),{setInfraProvider}=await import("./store");
+ await withIntegrationSelection({user:"alice",connection:"work"},()=>setInfraProvider("dokploy",{apiUrl:"http://127.0.0.1:4123/api",apiKey:KEY}));
+ return withIntegrationSelection;
+}
+it("lists bounded deployment metadata and redacts secret-shaped fields",async()=>{
+ const withSelection=await seeded();
+ vi.stubGlobal("fetch",vi.fn(async(input:RequestInfo|URL)=>{
+ const url=new URL(new Request(input).url);
+ if(url.pathname.endsWith("/deployment.all"))return new Response(JSON.stringify([{deploymentId:"deployment_123",status:"error",title:"Deploy",description:"token=abc123",errorMessage:"authorization=Bearer super-secret",createdAt:"2026-09-06T00:00:00Z"}]),{status:200});
+ return new Response("not found",{status:404});
+ }));
+ const {listDokployDeployments}=await import("./dokploy");
+ const rows=await withSelection({user:"alice",connection:"work"},()=>listDokployDeployments("application_123"));
+ expect(rows[0]).toMatchObject({deploymentId:"deployment_123",status:"error",title:"Deploy"});
+ expect(JSON.stringify(rows)).not.toContain("super-secret");
+});
+it("returns only redacted bounded deployment logs",async()=>{
+ const withSelection=await seeded();
+ vi.stubGlobal("fetch",vi.fn(async(input:RequestInfo|URL)=>{
+ const url=new URL(new Request(input).url);
+ if(url.pathname.endsWith("/deployment.readLogs")){expect(url.searchParams.get("tail")).toBe("160");return new Response(JSON.stringify("build failed\nAPI_KEY=very-secret-value\n"),{status:200});}
+ return new Response("not found",{status:404});
+ }));
+ const {readDokployDeploymentLogs}=await import("./dokploy");
+ const result=await withSelection({user:"alice",connection:"work"},()=>readDokployDeploymentLogs("deployment_123"));
+ expect(result.logs).toContain("build failed");
+ expect(result.logs).not.toContain("very-secret-value");
+});
+it("recovers only an existing GitHub source to validated public HTTPS Git and redeploys",async()=>{
+ const withSelection=await seeded();let sourceType="github",customGitUrl="",customGitBranch="",deploys=0;
+ vi.stubGlobal("fetch",vi.fn(async(input:RequestInfo|URL,init?:RequestInit)=>{
+ const req=new Request(input,init),url=new URL(req.url);
+ if(url.pathname.endsWith("/application.one"))return new Response(JSON.stringify({applicationId:"application_123",sourceType,owner:"rahmanef63",repository:"CareerPack",branch:"main",buildPath:"/",watchPaths:[],enableSubmodules:false,customGitUrl,customGitBranch}),{status:200});
+ if(url.pathname.endsWith("/application.saveGitProvider")){const body=JSON.parse(await req.text());expect(body).toEqual({applicationId:"application_123",customGitBuildPath:"/",customGitUrl:"https://github.com/rahmanef63/CareerPack.git",watchPaths:[],enableSubmodules:false,customGitBranch:"main",customGitSSHKeyId:null});sourceType="git";customGitUrl=body.customGitUrl;customGitBranch=body.customGitBranch;return new Response("{}",{status:200});}
+ if(url.pathname.endsWith("/application.deploy")){deploys++;return new Response("{}",{status:200});}
+ return new Response("not found",{status:404});
+ }));
+ const {recoverDokployPublicGithubToHttpsGit}=await import("./dokploy");
+ const result=await withSelection({user:"alice",connection:"work"},()=>recoverDokployPublicGithubToHttpsGit("application_123"));
+ expect(result).toMatchObject({sourceType:"git",customGitUrl:"https://github.com/rahmanef63/CareerPack.git",redeployQueued:true});expect(deploys).toBe(1);
+});
diff --git a/lib/infra/dokploy.ts b/lib/infra/dokploy.ts
index 93dbb091..654b8041 100644
--- a/lib/infra/dokploy.ts
+++ b/lib/infra/dokploy.ts
@@ -2,6 +2,7 @@ import type { InfraProviderValues } from "./types";
import { safeProviderFetch } from "@/lib/host/ssrf";
import { readInfraProvider } from "./store";
import { obj, request, TIMEOUT_MS } from "./http";
+import { redactText } from "@/lib/security/redact-text";
function dokployFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
const requestInput = new Request(input, { ...init, redirect: "error" });
@@ -166,3 +167,45 @@ export async function upsertDokployPublicBuildEnv(args: {
await call("/application.deploy", "POST", { applicationId });
return { applicationId, key: args.key, changed: true, redeployQueued: true };
}
+
+export type DokployDeploymentSummary={deploymentId:string;status:string|null;title:string;description:string;errorMessage:string;createdAt:string};
+export async function listDokployDeployments(applicationId:string):Promise<DokployDeploymentSummary[]>{
+ const id=dokployId(applicationId,"application id"),payload=await call(`/deployment.all?applicationId=${encodeURIComponent(id)}`);
+ if(!Array.isArray(payload))throw new Error("Dokploy deployment.all returned an unexpected response");
+ return payload.slice(0,50).map(raw=>{const row=obj(raw);return {deploymentId:String(row.deploymentId??row.id??""),status:typeof row.status==="string"?row.status:null,title:redactText(String(row.title??row.titleLog??""),240),description:redactText(String(row.description??row.descriptionLog??""),500),errorMessage:redactText(String(row.errorMessage??""),1200),createdAt:String(row.createdAt??row.created_at??"")};}).filter(row=>row.deploymentId);
+}
+export async function readDokployDeploymentLogs(deploymentId:string,tail=160):Promise<{deploymentId:string;logs:string}>{
+ const id=dokployId(deploymentId,"deployment id"),safeTail=Math.max(1,Math.min(500,Math.trunc(tail)));
+ const payload=await call(`/deployment.readLogs?deploymentId=${encodeURIComponent(id)}&tail=${safeTail}`),record=typeof payload==="object"&&payload?obj(payload):{};
+ const raw=typeof payload==="string"?payload:typeof record.logs==="string"?record.logs:typeof record.content==="string"?record.content:JSON.stringify(payload);
+ return {deploymentId:id,logs:redactText(raw,16000)};
+}
+
+export async function inspectDokployApplication(applicationId:string){
+ const row=await readDokployApplication(applicationId);
+ return {applicationId:String(row.applicationId??row.id??""),name:String(row.name??""),sourceType:String(row.sourceType??""),repository:String(row.repository??""),owner:String(row.owner??""),branch:String(row.branch??""),buildPath:String(row.buildPath??""),customGitUrl:String(row.customGitUrl??""),customGitBranch:String(row.customGitBranch??""),customGitBuildPath:String(row.customGitBuildPath??""),triggerType:String(row.triggerType??"push"),autoDeploy:row.autoDeploy===true,enableSubmodules:row.enableSubmodules===true,watchPaths:Array.isArray(row.watchPaths)?row.watchPaths.filter(x=>typeof x==="string").slice(0,50):[],githubId:String(row.githubId??""),gitlabId:String(row.gitlabId??""),bitbucketId:String(row.bitbucketId??""),giteaId:String(row.giteaId??""),buildType:String(row.buildType??""),applicationStatus:String(row.applicationStatus??"")};
+}
+export async function listDokployGitProviders(){
+ const payload=await call("/gitProvider.getAll");if(!Array.isArray(payload))throw new Error("Dokploy gitProvider.getAll returned an unexpected response");
+ return payload.slice(0,100).map(raw=>{const row=obj(raw),github=row.github&&typeof row.github==="object"?obj(row.github):{};return {gitProviderId:String(row.gitProviderId??row.id??""),name:String(row.name??""),providerType:String(row.providerType??row.type??""),githubId:String(github.githubId??""),githubName:String(github.name??""),githubAppName:String(github.githubAppName??"")};}).filter(row=>row.gitProviderId);
+}
+
+export async function listDokployGithubRepositories(githubId:string){
+ const id=dokployId(githubId,"github id"),payload=await call(`/github.getGithubRepositories?githubId=${encodeURIComponent(id)}`);
+ if(!Array.isArray(payload))throw new Error("Dokploy github.getGithubRepositories returned an unexpected response");
+ return payload.slice(0,500).map(raw=>{const row=obj(raw),owner=row.owner&&typeof row.owner==="object"?obj(row.owner):{};return {name:String(row.name??""),fullName:String(row.full_name??row.fullName??""),owner:String(owner.login??row.owner??"")};}).filter(row=>row.name);
+}
+
+export async function inspectDokployGithubProvider(githubId:string){const id=dokployId(githubId,"github id"),row=obj(await call(`/github.one?githubId=${encodeURIComponent(id)}`));return {githubId:String(row.githubId??""),name:String(row.name??""),githubAppName:String(row.githubAppName??""),githubInstallationId:String(row.githubInstallationId??""),githubUrl:String(row.githubUrl??"")};}
+export async function testDokployGithubProvider(githubId:string){const id=dokployId(githubId,"github id"),payload=await call("/github.testConnection","POST",{githubId:id});const row=obj(payload);return {ok:row.success===true||row.ok===true,message:redactText(String(row.message??row.detail??""),500)};}
+
+export async function recoverDokployPublicGithubToHttpsGit(applicationId:string){
+ const id=dokployId(applicationId,"application id"),before=await readDokployApplication(id);
+ if(before.sourceType!=="github")throw new Error("Dokploy application is not using the GitHub source provider");
+ const owner=String(before.owner??""),repository=String(before.repository??""),branch=String(before.branch??"main"),buildPath=String(before.buildPath??"/");
+ if(!/^[A-Za-z0-9_.-]{1,100}$/.test(owner)||!/^[A-Za-z0-9_.-]{1,180}$/.test(repository)||!/^[A-Za-z0-9._\-/#]{1,180}$/.test(branch)||!/^\/?[A-Za-z0-9._\-/]*$/.test(buildPath))throw new Error("unsafe Dokploy GitHub source metadata");
+ const customGitUrl=`https://github.com/${owner}/${repository}.git`,watchPaths=Array.isArray(before.watchPaths)?before.watchPaths.filter(x=>typeof x==="string").slice(0,50):[];
+ await call("/application.saveGitProvider","POST",{applicationId:id,customGitBuildPath:buildPath,customGitUrl,watchPaths,enableSubmodules:before.enableSubmodules===true,customGitBranch:branch,customGitSSHKeyId:null});
+ const after=await readDokployApplication(id);if(after.sourceType!=="git"||after.customGitUrl!==customGitUrl||after.customGitBranch!==branch)throw new Error("Dokploy HTTPS Git recovery could not be verified");
+ await call("/application.deploy","POST",{applicationId:id});return {applicationId:id,sourceType:"git",customGitUrl,branch,redeployQueued:true};
+}
diff --git a/lib/mcp/tools-integrations.ts b/lib/mcp/tools-integrations.ts
index 0397f207..8620945b 100644
--- a/lib/mcp/tools-integrations.ts
+++ b/lib/mcp/tools-integrations.ts
@@ -8,6 +8,7 @@ const OUTPUT={type:"object",properties:{result:{type:"object"}},required:["resul
export const INTEGRATION_TOOLS:McpTool[]=[
{name:"integration_query",title:"Inspect Integration Connections",scope:"read",annotations:{readOnlyHint:true,idempotentHint:true,openWorldHint:false},
description:"Read native MSO credential users, providers, named connections, source/auth guidance and directory resolution. Never returns keys. User profiles are credential owners, not device roles. Resolve before acting when multiple accounts or deployments exist.",
+ chatgptDescription:"Inspect named integrations and routing.",
inputSchema:S({...BASE,view:{type:"string",enum:["snapshot","catalog","users","connections","which","resolve","request"]},source:{type:"string",enum:[...SOURCES]},authMethod:{type:"string",maxLength:64}}),outputSchema:OUTPUT,
meta:{ui:{visibility:["model","app"]},"openai/widgetAccessible":true},run:async a=>({result:await queryIntegrationAction(a)}),
},
@@ -21,7 +22,7 @@ export const INTEGRATION_TOOLS:McpTool[]=[
{name:"integration_execute",title:"Use an Exact Integration Connection",scope:"exec",annotations:{readOnlyHint:false,destructiveHint:true,openWorldHint:true},audit:{action:"infra.write",targetArg:"connection"},limit:{key:"integration.execute",max:30,windowMs:60000},
description:"Execute using an explicit user/provider/named connection. Verify or inspect its route; bounded direct operations reject external backends. Composio tool execution requires an ACTIVE matching connected account and a toolkit-prefixed tool. Native-MCP returns the provider route without copying OAuth tokens. Non-verification operations require confirm=true. No credentials in arguments.",
chatgptDescription:"Run one bounded named-integration operation.",
- inputSchema:S({...BASE,operation:{type:"string",enum:["route","verify","dokploy.projects.list","dokploy.applications.list","dokploy.application.publicEnv.upsert","dokploy.project.ensure","convex.customDomains.list","convex.customDomain.ensure","convex.canonical.get","convex.canonical.set","cloudflare.zones.list","cloudflare.dns.upsert","hostinger.dns.upsert","hostinger.mail.orders.list","hostinger.mail.plan.get","hostinger.mail.list","hostinger.mail.logs.list","hostinger.mail.mutate","composio.tool"]},confirm:{type:"boolean"},tool:{type:"string",maxLength:180},arguments:{type:"object",additionalProperties:true}},["user","provider","connection","operation"]),outputSchema:OUTPUT,
+ inputSchema:S({...BASE,operation:{type:"string",enum:["route","verify","dokploy.projects.list","dokploy.applications.list","dokploy.deployments.list","dokploy.deployment.logs","dokploy.git.recover","dokploy.application.publicEnv.upsert","dokploy.project.ensure","convex.customDomains.list","convex.customDomain.ensure","convex.canonical.get","convex.canonical.set","cloudflare.zones.list","cloudflare.dns.upsert","hostinger.dns.upsert","hostinger.mail.orders.list","hostinger.mail.plan.get","hostinger.mail.list","hostinger.mail.logs.list","hostinger.mail.mutate","composio.tool"]},confirm:{type:"boolean"},tool:{type:"string",maxLength:180},arguments:{type:"object",additionalProperties:true}},["user","provider","connection","operation"]),outputSchema:OUTPUT,
meta:{ui:{visibility:["model","app"]},"openai/widgetAccessible":true},run:async a=>({result:await executeIntegrationAction(a)}),
},
];