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(integrations): add safe Convex Cloud deploy runner

Rahman2160f4ae62fc
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 8210fe13..8d56f792 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 safe Convex Cloud deploy runner
- `workflows` add reviewed external editor tabs
- `organization` add internal project flows with callable CRUD
diff --git a/lib/infra/connection-dispatch.ts b/lib/infra/connection-dispatch.ts
index a029072e..79fe8e40 100644
--- a/lib/infra/connection-dispatch.ts
+++ b/lib/infra/connection-dispatch.ts
@@ -3,7 +3,7 @@ import { integrationQuery, withIntegrationSelection, resolveIntegration } from "
import { authorizeIntegration, composioConnectionCall } from "./connection-external";
import { IntegrationError, identity, metadataOnly, type ConnectionSelector } from "./identity";
import { importConvexCliPersonalConnection } from "./convex-cli-import";
-import { listConvexCustomDomains, ensureConvexCustomDomain, getConvexCanonicalUrls, setConvexCanonicalUrl, getConvexEnvPresence } from "./convex-cloud";
+import { listConvexCustomDomains, ensureConvexCustomDomain, getConvexCanonicalUrls, setConvexCanonicalUrl, getConvexEnvPresence, deployConvexCloudProject, importConvexCloudSnapshot } from "./convex-cloud";
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 } from "./catalog";
export const safeActionInput=(input:Record<string,unknown>)=>Object.fromEntries(Object.entries(input).filter(([key])=>key!=="workflow_id"));
@@ -55,6 +55,8 @@ export async function executeIntegrationAction(raw:Record<string,unknown>){
"convex.canonical.get":{provider:"convex-cloud",fields:["deploymentName"],run:()=>getConvexCanonicalUrls(String((args as Record<string,unknown>).deploymentName))},
"convex.env.presence":{provider:"convex-cloud",fields:["deploymentName","names"],run:()=>getConvexEnvPresence(args as {deploymentName:string;names:string[]})},
"convex.canonical.set":{provider:"convex-cloud",fields:["deploymentName","requestDestination","url"],run:()=>setConvexCanonicalUrl(args as {deploymentName:string;requestDestination:"convexCloud"|"convexSite";url?:string|null})},
+ "convex.project.deploy":{provider:"convex-cloud",fields:["deploymentName","projectPath"],run:()=>deployConvexCloudProject(args as {deploymentName:string;projectPath:string})},
+ "convex.snapshot.import":{provider:"convex-cloud",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])},
diff --git a/lib/infra/convex-cloud-cli-runner.ts b/lib/infra/convex-cloud-cli-runner.ts
new file mode 100644
index 00000000..eebdf892
--- /dev/null
+++ b/lib/infra/convex-cloud-cli-runner.ts
@@ -0,0 +1,171 @@
+import { createHash } from "node:crypto";
+import { spawn } from "node:child_process";
+import { createReadStream, promises as fs } from "node:fs";
+import path from "node:path";
+import { childEnv } from "@/lib/host/child-env";
+import { resolveReadable } from "@/lib/host/paths";
+import { IntegrationError } from "./identity";
+
+export type ConvexCliResult = {
+ code: number;
+ stdout: string;
+ stderr: string;
+ durationMs: number;
+};
+
+export type RunConvexCli = (
+ executable: string,
+ args: string[],
+ options: { cwd: string; env: Record<string, string>; timeoutMs: number },
+) => Promise<ConvexCliResult>;
+
+const MAX_CLI_OUTPUT = 64 * 1024;
+const MAX_SNAPSHOT_BYTES = 2 * 1024 * 1024 * 1024;
+
+function appendBounded(current: string, chunk: Buffer | string): string {
+ const text = current + chunk.toString();
+ return text.length <= MAX_CLI_OUTPUT
+ ? text
+ : text.slice(text.length - MAX_CLI_OUTPUT);
+}
+
+export function redactConvexCliText(text: string, deployKey: string): string {
+ if (!text) return "";
+ return text
+ .split(deployKey)
+ .join("[REDACTED_DEPLOY_KEY]")
+ .replace(
+ /(?:prod|dev|preview|project):[A-Za-z0-9:_-]+\|[A-Za-z0-9+/=_-]{16,}/g,
+ "[REDACTED_DEPLOY_KEY]",
+ )
+ .slice(-8_000);
+}
+
+export const runConvexCli: RunConvexCli = async (
+ executable,
+ args,
+ options,
+) =>
+ new Promise<ConvexCliResult>((resolve, reject) => {
+ const started = Date.now();
+ const child = spawn(executable, args, {
+ cwd: options.cwd,
+ env: options.env as NodeJS.ProcessEnv,
+ shell: false,
+ stdio: ["pipe", "pipe", "pipe"],
+ });
+ child.stdin.end();
+ let stdout = "";
+ let stderr = "";
+ child.stdout.on("data", (chunk: Buffer) => {
+ stdout = appendBounded(stdout, chunk);
+ });
+ child.stderr.on("data", (chunk: Buffer) => {
+ stderr = appendBounded(stderr, chunk);
+ });
+ const timer = setTimeout(() => {
+ child.kill("SIGTERM");
+ setTimeout(() => child.kill("SIGKILL"), 2_000).unref();
+ }, options.timeoutMs);
+ child.once("error", (error: Error) => {
+ clearTimeout(timer);
+ reject(error);
+ });
+ child.once("close", (code: number | null) => {
+ clearTimeout(timer);
+ resolve({
+ code: code ?? -1,
+ stdout,
+ stderr,
+ durationMs: Date.now() - started,
+ });
+ });
+ });
+
+export async function convexProjectContext(projectPath: unknown) {
+ if (typeof projectPath !== "string" || !projectPath.trim())
+ throw new IntegrationError("invalid_project_path");
+ const project = await resolveReadable(projectPath.trim()).catch(() => {
+ throw new IntegrationError("invalid_project_path");
+ });
+ const stat = await fs.stat(project).catch(() => null);
+ if (!stat?.isDirectory()) throw new IntegrationError("invalid_project_path");
+ if (typeof process.getuid === "function" && stat.uid !== process.getuid())
+ throw new IntegrationError("invalid_project_path");
+
+ const convexDir = path.join(project, "convex");
+ if (!(await fs.stat(convexDir).catch(() => null))?.isDirectory())
+ throw new IntegrationError("convex_project_required", 409);
+
+ const executable = path.join(project, "node_modules", ".bin", "convex");
+ const cli = await fs.stat(executable).catch(() => null);
+ if (!cli?.isFile())
+ throw new IntegrationError("convex_cli_required", 409);
+
+ return { project, executable };
+}
+
+export async function convexSnapshotContext(snapshotPath: unknown) {
+ if (typeof snapshotPath !== "string" || !snapshotPath.trim())
+ throw new IntegrationError("invalid_snapshot_path");
+ const snapshot = await resolveReadable(snapshotPath.trim()).catch(() => {
+ throw new IntegrationError("invalid_snapshot_path");
+ });
+ if (!snapshot.toLowerCase().endsWith(".zip"))
+ throw new IntegrationError("convex_snapshot_zip_required");
+ const stat = await fs.stat(snapshot).catch(() => null);
+ if (!stat?.isFile() || stat.size <= 0 || stat.size > MAX_SNAPSHOT_BYTES)
+ throw new IntegrationError("invalid_snapshot_path");
+ if (typeof process.getuid === "function" && stat.uid !== process.getuid())
+ throw new IntegrationError("invalid_snapshot_path");
+
+ const head = Buffer.alloc(4);
+ const handle = await fs.open(snapshot, "r");
+ try {
+ await handle.read(head, 0, 4, 0);
+ } finally {
+ await handle.close().catch(() => undefined);
+ }
+ if (
+ head[0] !== 0x50 ||
+ head[1] !== 0x4b ||
+ ![0x03, 0x05, 0x07].includes(head[2])
+ )
+ throw new IntegrationError("convex_snapshot_zip_required");
+
+ const hash = createHash("sha256");
+ for await (const chunk of createReadStream(snapshot)) hash.update(chunk);
+ return { snapshot, size: stat.size, sha256: hash.digest("hex") };
+}
+
+export function convexCliEnv(deployKey: string): Record<string, string> {
+ const env = childEnv();
+ delete env.CONVEX_DEPLOYMENT;
+ delete env.CONVEX_SELF_HOSTED_URL;
+ delete env.CONVEX_SELF_HOSTED_ADMIN_KEY;
+ delete env.CONVEX_OVERRIDE_ACCESS_TOKEN;
+ env.CONVEX_DEPLOY_KEY = deployKey;
+ env.CI = "1";
+ return env;
+}
+
+export function throwConvexCliFailure(
+ operation: "deploy" | "import",
+ result: ConvexCliResult,
+ deployKey: string,
+): never {
+ const redacted = redactConvexCliText(
+ [result.stderr, result.stdout].filter(Boolean).join("\n"),
+ deployKey,
+ );
+ const error = new IntegrationError(
+ operation === "deploy"
+ ? "convex_cloud_deploy_failed"
+ : "convex_cloud_import_failed",
+ 502,
+ );
+ Object.assign(error, {
+ detail: redacted || `convex ${operation} exited ${result.code}`,
+ });
+ throw error;
+}
diff --git a/lib/infra/convex-cloud-key.ts b/lib/infra/convex-cloud-key.ts
new file mode 100644
index 00000000..6c84acdc
--- /dev/null
+++ b/lib/infra/convex-cloud-key.ts
@@ -0,0 +1,80 @@
+import { randomUUID } from "node:crypto";
+import { obj } from "./http";
+import { IntegrationError } from "./identity";
+import { readInfraProvider } from "./store";
+import {
+ convexAuthHeaders,
+ convexCheckedJson,
+ convexManagementUrl,
+ type FetchLike,
+} from "./convex-cloud-core";
+
+export async function convexCloudPersonalToken(): Promise<string> {
+ const token = (await readInfraProvider("convex-cloud")).personalToken;
+ if (!token) throw new IntegrationError("convex_personal_token_required", 409);
+ return token;
+}
+
+function validDeployKey(value: unknown): value is string {
+ return (
+ typeof value === "string" &&
+ value.length >= 20 &&
+ !/[\x00-\x20\x7f]/.test(value)
+ );
+}
+
+export async function withConvexEphemeralDeployKey<T>(
+ deployment: string,
+ token: string,
+ allowedActions: string[],
+ fn: (deployKey: string) => Promise<T>,
+ fetchImpl: FetchLike,
+): Promise<T> {
+ const name = `mso-runner-${randomUUID()}`;
+ const created = obj(
+ await convexCheckedJson(
+ "convex_cloud",
+ convexManagementUrl(deployment, "create_deploy_key"),
+ {
+ method: "POST",
+ headers: convexAuthHeaders(token, "Bearer"),
+ body: JSON.stringify({ name, allowedActions }),
+ },
+ fetchImpl,
+ ),
+ );
+ const deployKey = created.deployKey;
+ if (!validDeployKey(deployKey))
+ throw new IntegrationError("invalid_convex_deploy_key_response", 502);
+
+ let result: T | undefined;
+ let primary: unknown;
+ try {
+ result = await fn(deployKey);
+ } catch (error) {
+ primary = error;
+ }
+
+ try {
+ await convexCheckedJson(
+ "convex_cloud",
+ convexManagementUrl(deployment, "delete_deploy_key"),
+ {
+ method: "POST",
+ headers: convexAuthHeaders(token, "Bearer"),
+ body: JSON.stringify({ id: name }),
+ },
+ fetchImpl,
+ );
+ } catch {
+ throw new IntegrationError(
+ primary
+ ? "convex_operation_and_ephemeral_cleanup_failed"
+ : "convex_ephemeral_cleanup_failed",
+ 502,
+ );
+ }
+
+ if (primary) throw primary;
+ return result as T;
+}
diff --git a/lib/infra/convex-cloud-runner.test.ts b/lib/infra/convex-cloud-runner.test.ts
new file mode 100644
index 00000000..ff9f5a1f
--- /dev/null
+++ b/lib/infra/convex-cloud-runner.test.ts
@@ -0,0 +1,213 @@
+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";
+const PAT = "pat_synthetic_12345678901234567890";
+const DEPLOY_KEY =
+ "prod:happy-otter-123|synthetic_deploy_key_1234567890abcdef";
+let root: string;
+let project: string;
+let snapshot: string;
+beforeEach(async () => {
+ root = await fs.mkdtemp(path.join(os.tmpdir(), "mso-convex-runner-"));
+ process.env.OS_INFRA_STORE = path.join(root, "infra.json");
+ process.env.OS_FS_READ_ROOTS = root;
+ process.env.OS_FS_WRITE_ROOTS = root;
+ project = path.join(root, "project");
+ snapshot = path.join(root, "merged.zip");
+ await fs.mkdir(path.join(project, "convex"), { recursive: true });
+ await fs.mkdir(path.join(project, "node_modules", ".bin"), { recursive: true });
+ await fs.writeFile(
+ path.join(project, "node_modules", ".bin", "convex"),
+ "#!/bin/sh\nexit 0\n",
+ { mode: 0o755 },
+ );
+ // ZIP empty-archive signature; the runner validates the archive magic before import.
+ await fs.writeFile(
+ snapshot,
+ Buffer.from([
+ 0x50, 0x4b, 0x05, 0x06, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ ]),
+ { mode: 0o600 },
+ );
+ vi.resetModules();
+});
+afterEach(async () => {
+ delete process.env.OS_INFRA_STORE;
+ delete process.env.OS_FS_READ_ROOTS;
+ delete process.env.OS_FS_WRITE_ROOTS;
+ 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: "convex-cloud",
+ connection: "admin",
+ authMethod: "personal",
+ source: "direct",
+ confirm: true,
+ });
+ const { withIntegrationSelection } = await import("./connection-service");
+ const { setInfraProvider } = await import("./store");
+ await withIntegrationSelection({ user: "alice", connection: "admin" }, () =>
+ setInfraProvider("convex-cloud", { personalToken: PAT }),
+ );
+ return withIntegrationSelection;
+}
+const json = (body: unknown, status = 200) =>
+ new Response(body === null ? null : JSON.stringify(body), {
+ status,
+ headers: { "content-type": "application/json" },
+ });
+it("deploys with an ephemeral deploy-only key and always revokes it", async () => {
+ const withSelection = await seeded();
+ let deleted = false;
+ const fetchImpl = vi.fn(
+ async (input: RequestInfo | URL, init?: RequestInit) => {
+ const url = String(input);
+ if (url.endsWith("/create_deploy_key")) {
+ expect(JSON.parse(String(init?.body))).toMatchObject({
+ allowedActions: ["deployment:deploy"],
+ });
+ expect(new Headers(init?.headers).get("authorization")).toBe(
+ `Bearer ${PAT}`,
+ );
+ return json({ deployKey: DEPLOY_KEY });
+ }
+ if (url.endsWith("/delete_deploy_key")) {
+ deleted = true;
+ return json({});
+ }
+ return json({ error: "unexpected" }, 500);
+ },
+ );
+ const runCli = vi.fn(async (_exe, args, options) => {
+ expect(args).toEqual(["deploy", "--yes"]);
+ expect(options.cwd).toBe(project);
+ expect(options.env.CONVEX_DEPLOY_KEY).toBe(DEPLOY_KEY);
+ expect(options.env.CONVEX_SELF_HOSTED_URL).toBeUndefined();
+ return { code: 0, stdout: "deployed", stderr: "", durationMs: 12 };
+ });
+ const { deployConvexCloudProject } = await import("./convex-cloud-runner");
+ const result = await withSelection(
+ { user: "alice", connection: "admin" },
+ () =>
+ deployConvexCloudProject(
+ { deploymentName: "happy-otter-123", projectPath: project },
+ { fetchImpl, runCli },
+ ),
+ );
+ expect(result).toMatchObject({
+ deploymentName: "happy-otter-123",
+ projectPath: project,
+ deployed: true,
+ });
+ expect(deleted).toBe(true);
+ expect(JSON.stringify(result)).not.toContain(DEPLOY_KEY);
+ expect(JSON.stringify(result)).not.toContain(PAT);
+});
+it("imports only with explicit mode and a data-scoped ephemeral key", async () => {
+ const withSelection = await seeded();
+ let deleted = false;
+ const fetchImpl = vi.fn(
+ async (input: RequestInfo | URL, init?: RequestInit) => {
+ const url = String(input);
+ if (url.endsWith("/create_deploy_key")) {
+ expect(JSON.parse(String(init?.body))).toMatchObject({
+ allowedActions: ["deployment:data:view", "deployment:data:write"],
+ });
+ return json({ deployKey: DEPLOY_KEY });
+ }
+ if (url.endsWith("/delete_deploy_key")) {
+ deleted = true;
+ return json({});
+ }
+ return json({ error: "unexpected" }, 500);
+ },
+ );
+ const runCli = vi.fn(async (_exe, args, options) => {
+ expect(args).toEqual(["import", snapshot, "--replace-all", "--yes"]);
+ expect(options.env.CONVEX_DEPLOY_KEY).toBe(DEPLOY_KEY);
+ return { code: 0, stdout: "imported", stderr: "", durationMs: 21 };
+ });
+ const { importConvexCloudSnapshot } = await import("./convex-cloud-runner");
+ const result = await withSelection(
+ { user: "alice", connection: "admin" },
+ () =>
+ importConvexCloudSnapshot(
+ {
+ deploymentName: "happy-otter-123",
+ projectPath: project,
+ snapshotPath: snapshot,
+ mode: "replace-all",
+ },
+ { fetchImpl, runCli },
+ ),
+ );
+ expect(result.imported).toBe(true);
+ expect(result.mode).toBe("replace-all");
+ expect(result.snapshot.bytes).toBe(22);
+ expect(result.snapshot.sha256).toMatch(/^[a-f0-9]{64}$/);
+ expect(deleted).toBe(true);
+ expect(JSON.stringify(result)).not.toContain(DEPLOY_KEY);
+});
+it("revokes the ephemeral key when the CLI operation fails", async () => {
+ const withSelection = await seeded();
+ let deleted = false;
+ const fetchImpl = vi.fn(async (input: RequestInfo | URL) => {
+ const url = String(input);
+ if (url.endsWith("/create_deploy_key"))
+ return json({ deployKey: DEPLOY_KEY });
+ if (url.endsWith("/delete_deploy_key")) {
+ deleted = true;
+ return json({});
+ }
+ return json({ error: "unexpected" }, 500);
+ });
+ const runCli = vi.fn(async () => ({
+ code: 1,
+ stdout: "",
+ stderr: `failure ${DEPLOY_KEY}`,
+ durationMs: 5,
+ }));
+ const { deployConvexCloudProject } = await import("./convex-cloud-runner");
+ await expect(
+ withSelection({ user: "alice", connection: "admin" }, () =>
+ deployConvexCloudProject(
+ { deploymentName: "happy-otter-123", projectPath: project },
+ { fetchImpl, runCli },
+ ),
+ ),
+ ).rejects.toMatchObject({ code: "convex_cloud_deploy_failed" });
+ expect(deleted).toBe(true);
+});
+it("rejects non-zip snapshots before minting a write key", async () => {
+ const withSelection = await seeded();
+ const bad = path.join(root, "not-a-zip.txt");
+ await fs.writeFile(bad, "not zip");
+ const fetchImpl = vi.fn();
+ const { importConvexCloudSnapshot } = await import("./convex-cloud-runner");
+ await expect(
+ withSelection({ user: "alice", connection: "admin" }, () =>
+ importConvexCloudSnapshot(
+ {
+ deploymentName: "happy-otter-123",
+ projectPath: project,
+ snapshotPath: bad,
+ mode: "replace-all",
+ },
+ { fetchImpl },
+ ),
+ ),
+ ).rejects.toMatchObject({ code: "convex_snapshot_zip_required" });
+ expect(fetchImpl).not.toHaveBeenCalled();
+});
diff --git a/lib/infra/convex-cloud-runner.ts b/lib/infra/convex-cloud-runner.ts
new file mode 100644
index 00000000..90c52be8
--- /dev/null
+++ b/lib/infra/convex-cloud-runner.ts
@@ -0,0 +1,105 @@
+import { convexDeploymentName, type FetchLike } from "./convex-cloud-core";
+import {
+ convexCliEnv,
+ convexProjectContext,
+ convexSnapshotContext,
+ runConvexCli,
+ throwConvexCliFailure,
+ type RunConvexCli,
+} from "./convex-cloud-cli-runner";
+import {
+ convexCloudPersonalToken,
+ withConvexEphemeralDeployKey,
+} from "./convex-cloud-key";
+import { IntegrationError } from "./identity";
+
+type RunnerDeps = {
+ fetchImpl?: FetchLike;
+ runCli?: RunConvexCli;
+};
+
+const DEPLOY_TIMEOUT_MS = 4 * 60_000;
+const IMPORT_TIMEOUT_MS = 8 * 60_000;
+
+export async function deployConvexCloudProject(
+ input: { deploymentName: string; projectPath: string },
+ deps: RunnerDeps = {},
+) {
+ const deployment = convexDeploymentName(input.deploymentName);
+ const token = await convexCloudPersonalToken();
+ const { project, executable } = await convexProjectContext(input.projectPath);
+ const fetchImpl = deps.fetchImpl ?? fetch;
+ const execute = deps.runCli ?? runConvexCli;
+
+ return withConvexEphemeralDeployKey(
+ deployment,
+ token,
+ ["deployment:deploy"],
+ async (deployKey) => {
+ const result = await execute(executable, ["deploy", "--yes"], {
+ cwd: project,
+ env: convexCliEnv(deployKey),
+ timeoutMs: DEPLOY_TIMEOUT_MS,
+ });
+ if (result.code !== 0) throwConvexCliFailure("deploy", result, deployKey);
+ return {
+ deploymentName: deployment,
+ projectPath: project,
+ deployed: true,
+ durationMs: result.durationMs,
+ };
+ },
+ fetchImpl,
+ );
+}
+
+export async function importConvexCloudSnapshot(
+ input: {
+ deploymentName: string;
+ projectPath: string;
+ snapshotPath: string;
+ mode: "replace-all" | "append";
+ },
+ deps: RunnerDeps = {},
+) {
+ const deployment = convexDeploymentName(input.deploymentName);
+ if (input.mode !== "replace-all" && input.mode !== "append")
+ throw new IntegrationError("invalid_convex_import_mode");
+ const token = await convexCloudPersonalToken();
+ const { project, executable } = await convexProjectContext(input.projectPath);
+ const snap = await convexSnapshotContext(input.snapshotPath);
+ const fetchImpl = deps.fetchImpl ?? fetch;
+ const execute = deps.runCli ?? runConvexCli;
+
+ return withConvexEphemeralDeployKey(
+ deployment,
+ token,
+ ["deployment:data:view", "deployment:data:write"],
+ async (deployKey) => {
+ const modeFlag = input.mode === "replace-all" ? "--replace-all" : "--append";
+ const result = await execute(
+ executable,
+ ["import", snap.snapshot, modeFlag, "--yes"],
+ {
+ cwd: project,
+ env: convexCliEnv(deployKey),
+ timeoutMs: IMPORT_TIMEOUT_MS,
+ },
+ );
+ if (result.code !== 0) throwConvexCliFailure("import", result, deployKey);
+ return {
+ deploymentName: deployment,
+ projectPath: project,
+ imported: true,
+ mode: input.mode,
+ snapshot: {
+ path: snap.snapshot,
+ bytes: snap.size,
+ sha256: snap.sha256,
+ },
+ durationMs: result.durationMs,
+ };
+ },
+ fetchImpl,
+ );
+}
diff --git a/lib/infra/convex-cloud.ts b/lib/infra/convex-cloud.ts
index aaad2bfa..c22b2fca 100644
--- a/lib/infra/convex-cloud.ts
+++ b/lib/infra/convex-cloud.ts
@@ -8,3 +8,5 @@ export {
} from "./convex-canonical";
export { getConvexEnvPresence } from "./convex-env-presence";
+
+export { deployConvexCloudProject, importConvexCloudSnapshot } from "./convex-cloud-runner";
diff --git a/lib/mcp/tools-integrations.ts b/lib/mcp/tools-integrations.ts
index ec024b38..7b10f2fb 100644
--- a/lib/mcp/tools-integrations.ts
+++ b/lib/mcp/tools-integrations.ts
@@ -22,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 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 an operation for exact user/provider/connection. Route or verify first; mutations need confirm=true.",
- inputSchema:S({...BASE,operation:{type:"string",enum:["route","verify","dokploy.projects.list","dokploy.applications.list","dokploy.gitProviders.list","dokploy.github.repositories.list","dokploy.application.ensureGithub","dokploy.domain.ensure","dokploy.deployments.list","dokploy.deployment.logs","dokploy.git.recover","dokploy.application.deploy","dokploy.dockerfile","dokploy.application.publicEnv.upsert","dokploy.project.ensure","convex.customDomains.list","convex.customDomain.ensure","convex.canonical.get","convex.env.presence","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.gitProviders.list","dokploy.github.repositories.list","dokploy.application.ensureGithub","dokploy.domain.ensure","dokploy.deployments.list","dokploy.deployment.logs","dokploy.git.recover","dokploy.application.deploy","dokploy.dockerfile","dokploy.application.publicEnv.upsert","dokploy.project.ensure","convex.customDomains.list","convex.customDomain.ensure","convex.canonical.get","convex.env.presence","convex.canonical.set","convex.project.deploy","convex.snapshot.import","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)}),
},
];