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): write Convex deployment env, and an addressable connection reference

Abdurrahman Fakhrul0efc4aecb91e
diff --git a/claude-skills/integrations/SKILL.md b/claude-skills/integrations/SKILL.md
index 7edd13b7..b04a906f 100644
--- a/claude-skills/integrations/SKILL.md
+++ b/claude-skills/integrations/SKILL.md
@@ -34,6 +34,34 @@ Never ask the user to paste a token, API key, password, OAuth code, private setu
5. Use `integration_manage` only for explicit metadata changes and confirmation-gated mutations.
6. Re-read the connection after mutation and report its non-secret state.
+## Pasted integration references
+
+An owner may paste a reference instead of describing an integration. Three forms are equivalent, all
+carrying `user` / `provider` / `connection`:
+
+```
+mso-integration:<user>/<provider>/<connection> <- preferred; not fetchable
+https://<host>/integrations?user=…&provider=…&connection=…
+<user>/<provider>/<connection>
+```
+
+When a prompt contains one:
+
+1. Treat it as the **exact** credential user, provider and connection. Do not ask which integration
+ the owner means, and do not substitute a similarly named connection.
+2. Pass those three values straight into `integration_query` / `integration_execute` /
+ `integration_manage`.
+3. Do **not** fetch the URL form. The `/integrations` page is owner-gated (403, or a login redirect);
+ the query parameters in it are the answer, not a resource to GET.
+4. Provider ids are canonical (`convex`, not the legacy `convex-cloud`). If a pasted id does not
+ resolve, say so and call `integration_query` for the catalog — do not guess a nearby provider.
+
+Failure handling, one round trip only:
+
+- `user_not_found` → `integration_query` for `view=users`, ask once which owner was meant.
+- `connection_not_found` → `integration_query` for that owner's connections, ask once.
+- Never fall back silently to another connection or to the default account.
+
## Tool routing
- `integration_query`: catalog, users, named connections, source/auth instructions, folder/default resolution.
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 05460dda..907c3e1d 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -8,7 +8,7 @@ this is the *what*, and it is what Settings → Account → About shows as “Wh
**Added**
-- `tui` /tabs as a table, with real activity and no invented idle
+- `tui` /tabs as a table, with real activity and no invented idle (#226)
- `tui` mcp and context pane kinds, with an honest unknown (#225)
- `tui` /terminal hands the real terminal to a shell or a one-shot command (#224)
- `skills` add mso-agent-fleet for Orca + OpenCode fan-out (#217)
diff --git a/frontend/slices/integrations/app.test.ts b/frontend/slices/integrations/app.test.ts
index 26c680ff..4c79077c 100644
--- a/frontend/slices/integrations/app.test.ts
+++ b/frontend/slices/integrations/app.test.ts
@@ -1,18 +1,38 @@
-import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
import { managerLocation } from "./app";
-import { integrationsApp } from "./index";
-describe("native Integrations shell app", () => {
- it("has a dockable descriptor and a matching app catalog entry", () => {
- expect(integrationsApp.id).toBe("integrations");
- expect(integrationsApp.noDock).not.toBe(true);
- expect(readFileSync("frontend/slices/app-store/lib/system-catalog.ts", "utf8")).toContain('id: "integrations", title: "Integrations", kind: "app"');
- const manifest = readFileSync("frontend/slices/os-shell/shell.manifest.ts", "utf8");
- expect(manifest).toContain('pin(withSlug(integrationsApp, "connections"))');
+// The integrations window renders an iframe. Every query parameter the user pasted has to survive
+// into that iframe or a deep link silently lands on the generic manager page — which is exactly
+// what happened before: only `transfer=1` was forwarded.
+
+describe("managerLocation", () => {
+ it("forwards the connection deep-link parameters", () => {
+ expect(managerLocation("?user=dita&provider=convex&connection=dita-convex"))
+ .toBe("/integrations/manager?user=dita&provider=convex&connection=dita-convex");
+ });
+
+ it("still forwards transfer", () => {
+ expect(managerLocation("?transfer=1")).toBe("/integrations/manager?transfer=1");
+ });
+
+ it("keeps both when a deep link also asks for transfer", () => {
+ expect(managerLocation("?transfer=1&user=dita&provider=convex&connection=dita-convex"))
+ .toBe("/integrations/manager?transfer=1&user=dita&provider=convex&connection=dita-convex");
});
- it("keeps transfer and private fragment handoffs inside the existing manager", () => {
- expect(managerLocation("?transfer=1&untrusted=ignore", "#example-capability")).toBe("/integrations/manager?transfer=1#example-capability");
- expect(managerLocation("?target=https://untrusted.invalid")).toBe("/integrations/manager");
+
+ it("drops anything that is not part of the allowlist", () => {
+ // `target` carried private capability material historically; it must not ride along.
+ expect(managerLocation("?target=secret-token&user=dita&provider=convex&connection=c"))
+ .toBe("/integrations/manager?user=dita&provider=convex&connection=c");
+ });
+
+ it("emits no query string at all when nothing is forwarded", () => {
+ expect(managerLocation("")).toBe("/integrations/manager");
+ expect(managerLocation("?target=x")).toBe("/integrations/manager");
+ });
+
+ it("preserves the hash", () => {
+ expect(managerLocation("?user=u&provider=p&connection=c", "#row"))
+ .toBe("/integrations/manager?user=u&provider=p&connection=c#row");
});
});
diff --git a/frontend/slices/integrations/app.tsx b/frontend/slices/integrations/app.tsx
index 2d248730..c36fe5de 100644
--- a/frontend/slices/integrations/app.tsx
+++ b/frontend/slices/integrations/app.tsx
@@ -5,10 +5,21 @@ import { Button } from "@/components/ui/button";
import { syncIntegrationFrameTokens } from "./frame-theme";
import { ComposioSessionPanel } from "./composio-session-panel";
-/** Preserve transfer/setup deep links without putting private capabilities in React state. */
+/** Parameters the manager iframe is allowed to receive. Everything else is dropped: this string
+ * becomes an iframe src, and historically `target` carried private capability material. */
+const MANAGER_PARAMS = ["transfer", "user", "provider", "connection"] as const;
+
+/** Preserve transfer/setup and connection deep links without putting private capabilities in React state. */
export function managerLocation(search: string, hash = "") {
- const transfer = new URLSearchParams(search).get("transfer") === "1";
- return "/integrations/manager" + (transfer ? "?transfer=1" : "") + hash;
+ const incoming = new URLSearchParams(search);
+ const forwarded = new URLSearchParams();
+ for (const key of MANAGER_PARAMS) {
+ const value = incoming.get(key);
+ // `transfer` is a flag; the rest are identifiers the reference format guarantees are safe.
+ if (value !== null && value !== "") forwarded.set(key, value);
+ }
+ const query = forwarded.toString();
+ return "/integrations/manager" + (query ? `?${query}` : "") + hash;
}
export default function IntegrationsApp() {
diff --git a/lib/infra/connection-dispatch-convex.test.ts b/lib/infra/connection-dispatch-convex.test.ts
index 3a18c15d..bf240c9f 100644
--- a/lib/infra/connection-dispatch-convex.test.ts
+++ b/lib/infra/connection-dispatch-convex.test.ts
@@ -16,7 +16,7 @@ let execute: typeof import("./connection-dispatch").executeIntegrationAction;
const CLOUD_PAT = "pat_synthetic_cloud_dispatch_1234567";
const ADMIN_KEY = "synthetic_self_hosted_admin_dispatch_1234";
-const operations = ["convex.customDomains.list", "convex.customDomain.ensure", "convex.canonical.get", "convex.canonical.set", "convex.env.presence", "convex.project.deploy", "convex.snapshot.import"];
+const operations = ["convex.customDomains.list", "convex.customDomain.ensure", "convex.canonical.get", "convex.canonical.set", "convex.env.presence", "convex.env.set", "convex.project.deploy", "convex.snapshot.import"];
async function seed(user: string, connection: string, method: string, values: Record<string, string>) {
const { integrationManage } = await import("./connection-manage");
@@ -51,6 +51,7 @@ const args: Record<string, Record<string, unknown>> = {
"convex.canonical.get": { deploymentName: "happy-otter-123" },
"convex.canonical.set": { deploymentName: "happy-otter-123", requestDestination: "convexCloud", url: null },
"convex.env.presence": { deploymentName: "happy-otter-123", names: ["AUTH_SECRET"] },
+ "convex.env.set": { deploymentName: "happy-otter-123", name: "AUTH_SECRET", value: "test-secret", projectPath: "/srv/project" },
"convex.project.deploy": { deploymentName: "happy-otter-123", projectPath: "/srv/project" },
"convex.snapshot.import": { deploymentName: "happy-otter-123", projectPath: "/srv/project", snapshotPath: "/tmp/s.zip", mode: "append" },
};
diff --git a/lib/infra/connection-dispatch.ts b/lib/infra/connection-dispatch.ts
index 79e8c32c..b4a1b174 100644
--- a/lib/infra/connection-dispatch.ts
+++ b/lib/infra/connection-dispatch.ts
@@ -1,4 +1,5 @@
import { isGoogleProvider, GOOGLE_APP_PROVIDER, googlePublicOrigin } from "./google-native-config";
+import { integrationDeepLink } from "./connection-reference";
import { bindGoogleApp, disconnectGoogle, runNativeGoogle, nativeGoogleStatus, googleOperations } from "./google-native";
import { integrationManage } from "./connection-manage";
import { integrationQuery, withIntegrationSelection, resolveIntegration, directConnectionValues } from "./connection-service";
@@ -7,7 +8,7 @@ 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 { listConvexCustomDomains, ensureConvexCustomDomain, getConvexCanonicalUrls, setConvexCanonicalUrl, getConvexEnvPresence, setConvexEnv, 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";
@@ -30,7 +31,7 @@ export async function manageIntegrationAction(raw:Record<string,unknown>){
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})};
+ return{user:route.user,provider:a.provider,connection:route.id,authorization:"owner-browser-required",openPath:integrationDeepLink(googlePublicOrigin(),{user:route.user,provider:String(a.provider),connection:route.id})};
}
if(a.action!=="connection.authorize")return integrationManage(a);
if(a.confirm!==true)throw new IntegrationError("confirmation_required",403);
@@ -47,10 +48,14 @@ export async function executeIntegrationAction(raw:Record<string,unknown>){
// 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"){
+ if(operation==="dokploy.application.publicEnv.upsert"||operation==="convex.env.set"){
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");
+ if(operation==="convex.env.set"){
+ if(Object.keys(args).some(k=>!["deploymentName","name","value","projectPath"].includes(k)))throw new IntegrationError("invalid_tool_arguments");
+ }else{
+ 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};
@@ -87,6 +92,7 @@ export async function executeIntegrationAction(raw:Record<string,unknown>){
"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.env.set":{provider:"convex",fields:["deploymentName","name","value","projectPath"],run:()=>setConvexEnv(args as {deploymentName?:string;name:string;value:string;projectPath?: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"})},
diff --git a/lib/infra/connection-reference.test.ts b/lib/infra/connection-reference.test.ts
new file mode 100644
index 00000000..5e6346e5
--- /dev/null
+++ b/lib/infra/connection-reference.test.ts
@@ -0,0 +1,68 @@
+import { describe, expect, it } from "vitest";
+import {
+ integrationDeepLink,
+ integrationReference,
+ parseIntegrationReference,
+} from "./connection-reference";
+
+// The point of this module is a reference an agent can act on without asking a follow-up question.
+// So the tests pin both halves: the exact strings copied out, and the fact that parsing is strict
+// enough to refuse anything ambiguous.
+
+describe("integration reference", () => {
+ it("builds the paste form from the three identity parts", () => {
+ expect(integrationReference({ user: "dita", provider: "convex", connection: "dita-convex" }))
+ .toBe("mso-integration:dita/convex/dita-convex");
+ });
+
+ it("canonicalises a legacy provider alias, or the reference will not resolve", () => {
+ // `convex-cloud` is the legacy id; the catalog resolves it to `convex`. A reference carrying
+ // the alias makes `catalog.find(p => p.id === provider)` fail and the UI silently fall back to
+ // the first provider in the list.
+ expect(integrationReference({ user: "dita", provider: "convex-cloud", connection: "c" }))
+ .toBe("mso-integration:dita/convex/c");
+ });
+
+ it("builds the clickable form from the same parts", () => {
+ expect(integrationDeepLink("https://mso.example.com", { user: "dita", provider: "convex", connection: "dita-convex" }))
+ .toBe("https://mso.example.com/integrations?user=dita&provider=convex&connection=dita-convex");
+ });
+
+ it("tolerates a trailing slash on the origin instead of emitting a double slash", () => {
+ expect(integrationDeepLink("https://mso.example.com/", { user: "u", provider: "p", connection: "c" }))
+ .toBe("https://mso.example.com/integrations?user=u&provider=p&connection=c");
+ });
+
+ it.each([
+ ["token form", "mso-integration:dita/convex/dita-convex"],
+ ["bare triple", "dita/convex/dita-convex"],
+ ["full URL", "https://mso.example.com/integrations?user=dita&provider=convex&connection=dita-convex"],
+ ["URL with extra params", "https://mso.example.com/integrations?transfer=1&user=dita&provider=convex&connection=dita-convex"],
+ ])("parses the %s, so people can paste whichever they copied", (_label, input) => {
+ expect(parseIntegrationReference(input)).toEqual({ user: "dita", provider: "convex", connection: "dita-convex" });
+ });
+
+ it("canonicalises on parse too", () => {
+ expect(parseIntegrationReference("mso-integration:dita/convex-cloud/dita-convex"))
+ .toEqual({ user: "dita", provider: "convex", connection: "dita-convex" });
+ });
+
+ it.each([
+ ["empty", ""],
+ ["whitespace", " "],
+ ["only two parts", "dita/convex"],
+ ["four parts", "a/b/c/d"],
+ ["empty segment", "dita//dita-convex"],
+ ["URL missing a param", "https://mso.example.com/integrations?user=dita&provider=convex"],
+ ["unknown provider", "mso-integration:dita/not-a-provider/dita-convex"],
+ ["not a URL at all", "https://"],
+ ])("refuses %s", (_label, input) => {
+ expect(parseIntegrationReference(input)).toBeNull();
+ });
+
+ it("round-trips through both forms", () => {
+ const ref = { user: "manef", provider: "convex", connection: "komunitas-tech" };
+ expect(parseIntegrationReference(integrationReference(ref))).toEqual(ref);
+ expect(parseIntegrationReference(integrationDeepLink("https://x.test", ref))).toEqual(ref);
+ });
+});
diff --git a/lib/infra/connection-reference.ts b/lib/infra/connection-reference.ts
new file mode 100644
index 00000000..eb8bb295
--- /dev/null
+++ b/lib/infra/connection-reference.ts
@@ -0,0 +1,92 @@
+// One addressable reference for an integration connection.
+//
+// Two forms, derived from the same identity, because they serve different readers:
+//
+// mso-integration:<user>/<provider>/<connection> <- paste this into an agent prompt
+// https://<origin>/integrations?user=…&provider=…&connection=… <- click this
+//
+// Why two: the URL is fetchable, so an agent handed only a URL will try to GET it, hit the owner
+// gate (403) or a login redirect, and burn a turn learning nothing. The token is deliberately not
+// fetchable — it parses as three path segments and nothing else. The URL exists because a human
+// still wants to click through to the row that was meant.
+//
+// Why all three components and not just the connection id: `connection` ids are per-user
+// (`dita/dita-convex` vs `cloud/admin` can both be named `convex`), and `user` is part of the
+// resolution input. The triple is the smallest thing that resolves unambiguously.
+//
+// Stability, verified in connection-manage.ts:
+// - `connection` id survives rename (rename only touches `label`) -> safe
+// - `user` id does NOT survive `user.rename` (it deletes the old key) -> a reference dies on
+// rename, and that is correct: a stale reference should fail loudly, never resolve to a
+// different user's connection
+// - `uid` (uuid) is never used here: it is regenerated on duplicate/share/import-export, so it
+// is not portable
+import { canonicalProviderId, resolveProviderId } from "./catalog";
+import { IntegrationError } from "./identity";
+
+const TOKEN_PREFIX = "mso-integration:";
+
+export type IntegrationRef = { user: string; provider: string; connection: string };
+
+/** The paste-into-a-prompt form. Unfetchable on purpose. */
+export function integrationReference(input: IntegrationRef): string {
+ return `${TOKEN_PREFIX}${input.user}/${canonicalProviderId(input.provider)}/${input.connection}`;
+}
+
+/** The clickable form. Query shape matches what the Google authorization path already emits. */
+export function integrationDeepLink(origin: string, input: IntegrationRef): string {
+ const base = origin.replace(/\/+$/, "");
+ const query = new URLSearchParams({
+ user: input.user,
+ provider: canonicalProviderId(input.provider),
+ connection: input.connection,
+ });
+ return `${base}/integrations?${query.toString()}`;
+}
+
+/**
+ * Parse a pasted reference. Accepts the token form, a bare `user/provider/connection` triple, or a
+ * URL carrying all three query parameters — because people paste whichever they copied.
+ */
+export function parseIntegrationReference(value: string): IntegrationRef | null {
+ const raw = value.trim();
+ if (!raw) return null;
+
+ if (raw.startsWith(TOKEN_PREFIX)) {
+ const parts = raw.slice(TOKEN_PREFIX.length).split("/");
+ return parts.length === 3 ? triple(parts) : null;
+ }
+
+ if (/^https?:\/\//i.test(raw)) {
+ try {
+ const params = new URL(raw).searchParams;
+ const user = params.get("user"), provider = params.get("provider"), connection = params.get("connection");
+ return user && provider && connection ? triple([user, provider, connection]) : null;
+ } catch {
+ return null;
+ }
+ }
+
+ // A bare triple only. Anything containing a scheme was handled above; do not let a malformed URL
+ // fall through and be read as `provider/model/path`.
+ const parts = raw.split("/");
+ return parts.length === 3 && !raw.includes("://") ? triple(parts) : null;
+}
+
+/** The identity regex forbids `/`, so three segments never need escaping. */
+function triple(parts: string[]): IntegrationRef | null {
+ const [user, provider, connection] = parts.map((part) => part.trim());
+ if (!user || !provider || !connection) return null;
+ try {
+ // Reject anything the store would refuse anyway, so a malformed paste fails here with a clear
+ // answer instead of surfacing as `user_not_found` three calls later.
+ // `canonicalProviderId` only folds the legacy alias; `resolveProviderId` is what actually
+ // rejects an id the catalog does not know.
+ const id = resolveProviderId(provider);
+ if (!id) return null;
+ return { user, provider: id, connection };
+ } catch (error) {
+ if (error instanceof IntegrationError) return null;
+ throw error;
+ }
+}
diff --git a/lib/infra/connection-registry.test.ts b/lib/infra/connection-registry.test.ts
index 2e6ff183..512ed131 100644
--- a/lib/infra/connection-registry.test.ts
+++ b/lib/infra/connection-registry.test.ts
@@ -97,6 +97,7 @@ describe("integration connection registry", () => {
"convex.customDomain.ensure",
"convex.customDomains.list",
"convex.env.presence",
+ "convex.env.set",
"convex.project.deploy",
"convex.snapshot.import",
]);
diff --git a/lib/infra/connection-registry.ts b/lib/infra/connection-registry.ts
index fa9ccee4..58ea508e 100644
--- a/lib/infra/connection-registry.ts
+++ b/lib/infra/connection-registry.ts
@@ -3,6 +3,7 @@ import { isGoogleProvider, GOOGLE_APP_PROVIDER, googleRedirectUri, googlePublicO
import { canonicalProviderId, convexDeploymentKind, listInfraProviderDefinitions, getInfraProviderDefinition, resolveProviderId } from "./catalog";
import { setupFields, setupGuidance, setupMethods, type SetupMethod } from "./setup-guidance";
import { IntegrationError, type ConnectionSource, type IntegrationConnection } from "./identity";
+import { integrationReference } from "./connection-reference";
/** Convex keeps every pre-collapse method id; `admin` is the self-hosted shape. */
const CONVEX_METHODS = ["personal", "deployment", "admin"] as const;
/**
@@ -62,7 +63,7 @@ function sourceLabel(provider:string,id:ConnectionSource){
export function connectionCatalog(){return listInfraProviderDefinitions().map(p=>({id:p.id,title:p.title,description:p.description,...googleCatalogInfo(p.id),sources:connectionSources(p.id).map(id=>({id,label:sourceLabel(p.id,id),methods:connectionMethods(p.id,id)}))}));}
export function connectionSummary(user:string,c:IntegrationConnection,isDefault=false,values:Record<string,string>=c.values){
const method=connectionMethod(c.provider,c.source,c.authMethod),missing=method.fields.filter(f=>f.required&&!values[f.key]).map(f=>f.key);
- return {user,id:c.id,label:c.label,provider:c.provider,source:c.source,authMethod:c.authMethod,scope:c.scope,revision:c.revision,isDefault,missing,fields:method.fields.map(f=>({...f,stored:Boolean(values[f.key])})),state:c.source==="direct"?(missing.length?"incomplete":c.lastCheck?(c.lastCheck.revision===c.revision?c.lastCheck.result:"configured"):c.verifiedAt?"verified":"configured"):c.external?.status??"authorization-required",verifiedAt:c.verifiedAt??null,lastCheck:c.lastCheck?.revision===c.revision?c.lastCheck:null,sharedFrom:c.sharedFrom??null,external:c.external??null};
+ return {user,id:c.id,label:c.label,provider:c.provider,reference:integrationReference({user,provider:c.provider,connection:c.id}),source:c.source,authMethod:c.authMethod,scope:c.scope,revision:c.revision,isDefault,missing,fields:method.fields.map(f=>({...f,stored:Boolean(values[f.key])})),state:c.source==="direct"?(missing.length?"incomplete":c.lastCheck?(c.lastCheck.revision===c.revision?c.lastCheck.result:"configured"):c.verifiedAt?"verified":"configured"):c.external?.status??"authorization-required",verifiedAt:c.verifiedAt??null,lastCheck:c.lastCheck?.revision===c.revision?c.lastCheck:null,sharedFrom:c.sharedFrom??null,external:c.external??null};
}
export const composioDefinition=(provider:string)=>COMPOSIO[provider];
export const nativeDefinition=(provider:string)=>NATIVE[provider];
diff --git a/lib/infra/connection-ui.ts b/lib/infra/connection-ui.ts
index 12af5ad0..583f49ea 100644
--- a/lib/infra/connection-ui.ts
+++ b/lib/infra/connection-ui.ts
@@ -175,7 +175,7 @@ function mountConnectionManager(root,catalog,bridge,initial={}){
const rows=snapshot.connections.filter(c=>c.provider===provider.id);if(rows.length){const count=rows.filter(ready).length;detail.append(n("p",rows.length+" connection"+(rows.length===1?"":"s")+" · "+count+" verified","identity-summary-line"));}
if(!rows.length){const empty=n("div",undefined,"identity-empty");empty.append(n("h3","Connect "+provider.title),n("p",user?"Add an account to start using "+provider.title+" in your projects.":bridge.manage?"Select a credential owner to add an account.":"Read the setup guide below, then sign in to connect your account."));const start=b("Add "+provider.title+" account",newConnection,"primary");start.disabled=!user||!bridge.manage;if(bridge.manage)empty.append(start);detail.append(empty);const help=n("details");help.append(n("summary","Connection methods & setup guides"));for(const s of provider.sources)for(const m of s.methods){const info=n("section");info.append(n("h3",s.label+" · "+m.label));guide(m,info);help.append(info)}detail.append(help)}
- for(const c of rows){const card=n("article",undefined,"connection-card");const top=n("header",undefined,"connection-heading"),name=n("div");name.append(n("h3",c.label),n("small",c.id));const state=n("span",stateLabel(c),"connection-state");state.dataset.ready=String(ready(c));top.append(name,state);card.append(top);const tags=n("div",undefined,"identity-tags");for(const value of [human(c.source),human(c.authMethod),c.sharedFrom?"Shared from "+c.sharedFrom.user:"",c.isDefault?"Default account":""])if(value)tags.append(n("span",value));card.append(tags);const actions=n("div",undefined,"identity-actions"),more=n("details",undefined,"identity-tools"),secondary=n("div",undefined,"identity-actions");more.append(n("summary","More"));more.append(secondary);
+ for(const c of rows){const card=n("article",undefined,"connection-card");const top=n("header",undefined,"connection-heading"),name=n("div");name.append(n("h3",c.label),n("small",c.id));const state=n("span",stateLabel(c),"connection-state");state.dataset.ready=String(ready(c));top.append(name,state);if(initial.connection===c.id)card.dataset.reference="focused";card.append(top);const tags=n("div",undefined,"identity-tags");for(const value of [human(c.source),human(c.authMethod),c.sharedFrom?"Shared from "+c.sharedFrom.user:"",c.isDefault?"Default account":""])if(value)tags.append(n("span",value));card.append(tags);const actions=n("div",undefined,"identity-actions"),more=n("details",undefined,"identity-tools"),secondary=n("div",undefined,"identity-actions");more.append(n("summary","More"));more.append(secondary);
if(provider.nativeGoogle&&!provider.configurationOnly){mountNativeGoogleConnection(card,c,{n,b,user,provider,catalog,snapshot,bridge,status,reload,selectProvider});detail.append(card);continue}
const open=b(c.source==="direct"?(c.fields.some(f=>f.stored)?"Update credentials":"Finish setup"):"Authorize",()=>{if(c.source==="direct")void bridge.openSetup({user,provider:provider.id,connection:c.id}).catch(e=>status.textContent=textError(e));else external(c)});open.disabled=!bridge.manage;if(!c.sharedFrom)actions.append(open);
const verify=b("Verify",async()=>{try{status.textContent="Checking selected connection…";const result=await bridge.execute({user,provider:provider.id,connection:c.id,operation:"verify"});await reload();status.textContent=(result.ok===true?"Verified: ":"Status: ")+result.detail}catch(e){status.textContent=textError(e)}});verify.disabled=!bridge.execute;actions.append(verify);
diff --git a/lib/infra/convex-cloud.ts b/lib/infra/convex-cloud.ts
index c22b2fca..4b9ee505 100644
--- a/lib/infra/convex-cloud.ts
+++ b/lib/infra/convex-cloud.ts
@@ -8,5 +8,6 @@ export {
} from "./convex-canonical";
export { getConvexEnvPresence } from "./convex-env-presence";
+export { setConvexEnv } from "./convex-env-set";
export { deployConvexCloudProject, importConvexCloudSnapshot } from "./convex-cloud-runner";
diff --git a/lib/infra/convex-env-set.test.ts b/lib/infra/convex-env-set.test.ts
new file mode 100644
index 00000000..c5b582e4
--- /dev/null
+++ b/lib/infra/convex-env-set.test.ts
@@ -0,0 +1,197 @@
+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", KEY = "prod:happy-otter-123|synthetic_deploy_key_1234567890";
+let root: string, project: string;
+
+beforeEach(async () => {
+ root = await fs.mkdtemp(path.join(os.tmpdir(), "mso-convex-env-set-"));
+ 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");
+ 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 });
+ 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(connectionValues: Record<string, string> = { personalToken: PAT }) {
+ 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", connectionValues));
+ return withIntegrationSelection;
+}
+
+const json = (body: unknown, status = 200) => new Response(JSON.stringify(body), { status, headers: { "content-type": "application/json" } });
+
+it("successfully sets env variable and always revokes the deploy key", async () => {
+ const withSelection = await seeded();
+ let deleted = false;
+ const SECRET_VAL = "super-secret-client-id-xyz";
+ 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:env:view", "deployment:env:write"] });
+ return json({ deployKey: KEY });
+ }
+ if (url.endsWith("/delete_deploy_key")) { deleted = true; return json({}); }
+ return json({ error: "unexpected" }, 500);
+ });
+ let secretFilePath = "";
+ const runCli = vi.fn(async (_exe, args, options) => {
+ // The value must never be an argv element: /proc/<pid>/cmdline is world-readable while the CLI
+ // runs. It travels in a 0600 file via --from-file, and that file is removed afterwards.
+ expect(args).toEqual(["env", "set", "--from-file", expect.stringMatching(/mso-convex-env-/)]);
+ expect(args.join(" ")).not.toContain(SECRET_VAL);
+ secretFilePath = args[3];
+ const onDisk = await fs.readFile(secretFilePath, "utf8");
+ expect(onDisk).toBe(`AUTH_GOOGLE_ID=${SECRET_VAL}\n`);
+ const mode = (await fs.stat(secretFilePath)).mode & 0o777;
+ expect(mode, "the temp file must not be readable by other users").toBe(0o600);
+ expect(options.env.CONVEX_DEPLOY_KEY).toBe(KEY);
+ return { code: 0, stdout: "successfully set AUTH_GOOGLE_ID", stderr: "", durationMs: 10 };
+ });
+
+ const { setConvexEnv } = await import("./convex-env-set");
+ const result = await withSelection({ user: "alice", connection: "admin" }, () =>
+ setConvexEnv({ deploymentName: "happy-otter-123", name: "AUTH_GOOGLE_ID", value: SECRET_VAL, projectPath: project }, { fetchImpl, runCli })
+ );
+ expect(result).toEqual({ deploymentName: "happy-otter-123", name: "AUTH_GOOGLE_ID", set: true });
+ expect(deleted).toBe(true);
+ await expect(fs.stat(secretFilePath)).rejects.toMatchObject({ code: "ENOENT" });
+ expect(JSON.stringify(result)).not.toContain(SECRET_VAL);
+ expect(JSON.stringify(result)).not.toContain(KEY);
+});
+
+it("always revokes deploy key even when writing fails and redacts value from error", async () => {
+ const withSelection = await seeded();
+ let deleted = false;
+ const SECRET_VAL = "leaked-secret-value-123";
+ const fetchImpl = vi.fn(async (input: RequestInfo | URL) => {
+ const url = String(input);
+ if (url.endsWith("/create_deploy_key")) return json({ deployKey: 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: `failed to set variable with ${SECRET_VAL}`, durationMs: 10 }));
+
+ const { setConvexEnv } = await import("./convex-env-set");
+ let caught: unknown;
+ try {
+ await withSelection({ user: "alice", connection: "admin" }, () =>
+ setConvexEnv({ deploymentName: "happy-otter-123", name: "AUTH_GOOGLE_ID", value: SECRET_VAL, projectPath: project }, { fetchImpl, runCli })
+ );
+ } catch (error) { caught = error; }
+
+ expect(deleted).toBe(true);
+ expect(caught).toBeDefined();
+ expect((caught as { code: string }).code).toBe("convex_cloud_env_set_failed");
+ expect(JSON.stringify(caught)).not.toContain(SECRET_VAL);
+ expect(JSON.stringify(caught)).not.toContain(KEY);
+});
+
+it("redacts secret value when child process throws an unexpected error", async () => {
+ const withSelection = await seeded();
+ let deleted = false;
+ const SECRET_VAL = "unhandled-secret-content";
+ const fetchImpl = vi.fn(async (input: RequestInfo | URL) => {
+ const url = String(input);
+ if (url.endsWith("/create_deploy_key")) return json({ deployKey: KEY });
+ if (url.endsWith("/delete_deploy_key")) { deleted = true; return json({}); }
+ return json({ error: "unexpected" }, 500);
+ });
+ const runCli = vi.fn(async () => { throw new Error(`crash with ${SECRET_VAL}`); });
+
+ const { setConvexEnv } = await import("./convex-env-set");
+ let caught: unknown;
+ try {
+ await withSelection({ user: "alice", connection: "admin" }, () =>
+ setConvexEnv({ deploymentName: "happy-otter-123", name: "AUTH_GOOGLE_ID", value: SECRET_VAL, projectPath: project }, { fetchImpl, runCli })
+ );
+ } catch (error) { caught = error; }
+
+ expect(deleted).toBe(true);
+ expect(caught).toBeDefined();
+ expect((caught as Error).message).not.toContain(SECRET_VAL);
+});
+
+it("refuses malformed or invalid env names without calling cloud APIs", async () => {
+ const withSelection = await seeded();
+ const fetchImpl = vi.fn();
+ const { setConvexEnv } = await import("./convex-env-set");
+
+ for (const badName of ["", "BAD-NAME", "123_START_NUM", "has spaces", "a".repeat(129)]) {
+ await expect(
+ withSelection({ user: "alice", connection: "admin" }, () =>
+ setConvexEnv({ deploymentName: "happy-otter-123", name: badName, value: "valid-value", projectPath: project }, { fetchImpl })
+ )
+ ).rejects.toMatchObject({ code: "invalid_convex_env_name" });
+ }
+ expect(fetchImpl).not.toHaveBeenCalled();
+});
+
+it("refuses values larger than 8KiB without calling cloud APIs", async () => {
+ const withSelection = await seeded();
+ const fetchImpl = vi.fn();
+ const { setConvexEnv } = await import("./convex-env-set");
+ const tooLarge = "x".repeat(8 * 1024 + 1);
+
+ await expect(
+ withSelection({ user: "alice", connection: "admin" }, () =>
+ setConvexEnv({ deploymentName: "happy-otter-123", name: "VALID_NAME", value: tooLarge, projectPath: project }, { fetchImpl })
+ )
+ ).rejects.toMatchObject({ code: "convex_env_value_too_large" });
+ expect(fetchImpl).not.toHaveBeenCalled();
+});
+
+it("refuses when deploymentName is missing from input and connection", async () => {
+ const withSelection = await seeded();
+ const fetchImpl = vi.fn();
+ const { setConvexEnv } = await import("./convex-env-set");
+
+ await expect(
+ withSelection({ user: "alice", connection: "admin" }, () =>
+ setConvexEnv({ deploymentName: "", name: "VALID_NAME", value: "test-val", projectPath: project }, { fetchImpl })
+ )
+ ).rejects.toMatchObject({ code: "convex_deployment_name_required", status: 409 });
+
+ await expect(
+ withSelection({ user: "alice", connection: "admin" }, () =>
+ setConvexEnv({ deploymentName: " ", name: "VALID_NAME", value: "test-val", projectPath: project }, { fetchImpl })
+ )
+ ).rejects.toMatchObject({ code: "convex_deployment_name_required", status: 409 });
+
+ await expect(
+ withSelection({ user: "alice", connection: "admin" }, () =>
+ setConvexEnv({ name: "VALID_NAME", value: "test-val", projectPath: project }, { fetchImpl })
+ )
+ ).rejects.toMatchObject({ code: "convex_deployment_name_required", status: 409 });
+ expect(fetchImpl).not.toHaveBeenCalled();
+});
+
+it("refuses malformed deploymentName with invalid_convex_deployment_name", async () => {
+ const withSelection = await seeded();
+ const fetchImpl = vi.fn();
+ const { setConvexEnv } = await import("./convex-env-set");
+
+ await expect(
+ withSelection({ user: "alice", connection: "admin" }, () =>
+ setConvexEnv({ deploymentName: "-invalid-start", name: "VALID_NAME", value: "test-val", projectPath: project }, { fetchImpl })
+ )
+ ).rejects.toMatchObject({ code: "invalid_convex_deployment_name" });
+ expect(fetchImpl).not.toHaveBeenCalled();
+});
diff --git a/lib/infra/convex-env-set.ts b/lib/infra/convex-env-set.ts
new file mode 100644
index 00000000..8db2cc4e
--- /dev/null
+++ b/lib/infra/convex-env-set.ts
@@ -0,0 +1,177 @@
+import { randomUUID } from "node:crypto";
+import { promises as fs } from "node:fs";
+import os from "node:os";
+import path from "node:path";
+import { obj } from "./http";
+import { IntegrationError } from "./identity";
+import { readInfraProvider } from "./store";
+import { currentIntegrationSelection } from "./connection-service";
+import {
+ convexAuthHeaders,
+ convexCheckedJson,
+ convexDeploymentName,
+ convexManagementUrl,
+ type FetchLike,
+} from "./convex-cloud-core";
+import {
+ convexCliEnv,
+ convexProjectContext,
+ redactConvexCliText,
+ runConvexCli,
+ type RunConvexCli,
+} from "./convex-cloud-cli-runner";
+
+export type ConvexEnvSetDeps = {
+ fetchImpl?: FetchLike;
+ runCli?: RunConvexCli;
+};
+
+const ENV_NAME = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
+const MAX_ENV_VALUE_BYTES = 8 * 1024;
+const ENV_SET_TIMEOUT_MS = 60_000;
+
+function validateEnvName(value: unknown): string {
+ if (typeof value !== "string" || !ENV_NAME.test(value.trim()))
+ throw new IntegrationError("invalid_convex_env_name");
+ return value.trim();
+}
+
+function validateEnvValue(value: unknown): string {
+ if (typeof value !== "string")
+ throw new IntegrationError("invalid_convex_env_value");
+ if (Buffer.byteLength(value, "utf8") > MAX_ENV_VALUE_BYTES)
+ throw new IntegrationError("convex_env_value_too_large");
+ return value;
+}
+
+function redactValueFromError(error: unknown, value: string): void {
+ if (!error || !value || typeof error !== "object") return;
+ const anyErr = error as Record<string, unknown>;
+ if (typeof anyErr.message === "string" && anyErr.message.includes(value)) {
+ anyErr.message = anyErr.message.split(value).join("[REDACTED_VALUE]");
+ }
+ if (typeof anyErr.detail === "string" && anyErr.detail.includes(value)) {
+ anyErr.detail = anyErr.detail.split(value).join("[REDACTED_VALUE]");
+ }
+}
+
+export async function setConvexEnv(
+ input: {
+ deploymentName?: string;
+ name: string;
+ value: string;
+ projectPath?: string;
+ },
+ deps: ConvexEnvSetDeps = {},
+) {
+ const name = validateEnvName(input.name);
+ const value = validateEnvValue(input.value);
+
+ const providerValues = await readInfraProvider("convex-cloud");
+ const token = providerValues.personalToken;
+ if (!token) throw new IntegrationError("convex_personal_token_required", 409);
+
+ const candidateDeployment =
+ typeof input.deploymentName === "string" && input.deploymentName.trim().length > 0
+ ? input.deploymentName.trim()
+ : typeof providerValues.deploymentName === "string" && providerValues.deploymentName.trim().length > 0
+ ? providerValues.deploymentName.trim()
+ : "";
+
+ if (!candidateDeployment)
+ throw new IntegrationError("convex_deployment_name_required", 409);
+
+ const deployment = convexDeploymentName(candidateDeployment);
+ const keyName = `mso-env-set-${randomUUID()}`;
+ const fetchImpl = deps.fetchImpl ?? fetch;
+ const execute = deps.runCli ?? runConvexCli;
+
+ const created = obj(
+ await convexCheckedJson(
+ "convex_cloud",
+ convexManagementUrl(deployment, "create_deploy_key"),
+ {
+ method: "POST",
+ headers: convexAuthHeaders(token, "Bearer"),
+ body: JSON.stringify({
+ name: keyName,
+ allowedActions: ["deployment:env:view", "deployment:env:write"],
+ }),
+ },
+ fetchImpl,
+ ),
+ );
+
+ const deployKey = created.deployKey;
+ if (
+ typeof deployKey !== "string" ||
+ deployKey.length < 20 ||
+ /[\x00-\x20\x7f]/.test(deployKey)
+ )
+ throw new IntegrationError("invalid_convex_deploy_key_response", 502);
+
+ let primary: unknown;
+ let secretFile: string | undefined;
+ try {
+ const projectPath = input.projectPath ?? currentIntegrationSelection().cwd;
+ const { project, executable } = await convexProjectContext(projectPath);
+ // The value must NOT travel as an argv element: any process on the host can read
+ // /proc/<pid>/cmdline while the CLI runs, and `env set NAME <value>` puts the secret there.
+ // `--from-file` keeps it in a 0600 file that is removed in the finally below.
+ secretFile = path.join(os.tmpdir(), `mso-convex-env-${randomUUID()}`);
+ await fs.writeFile(secretFile, `${name}=${value}\n`, { mode: 0o600, flag: "wx" });
+ const result = await execute(executable, ["env", "set", "--from-file", secretFile], {
+ cwd: project,
+ env: convexCliEnv(deployKey),
+ timeoutMs: ENV_SET_TIMEOUT_MS,
+ });
+ if (result.code !== 0) {
+ const redacted = redactConvexCliText(
+ [result.stderr, result.stdout].filter(Boolean).join("\n"),
+ deployKey,
+ )
+ .split(value)
+ .join("[REDACTED_VALUE]");
+ const error = new IntegrationError("convex_cloud_env_set_failed", 502);
+ Object.assign(error, {
+ detail: redacted || `convex env set exited ${result.code}`,
+ });
+ throw error;
+ }
+ } catch (error) {
+ primary = error;
+ } finally {
+ if (secretFile) await fs.rm(secretFile, { force: true }).catch(() => undefined);
+ }
+
+ try {
+ await convexCheckedJson(
+ "convex_cloud",
+ convexManagementUrl(deployment, "delete_deploy_key"),
+ {
+ method: "POST",
+ headers: convexAuthHeaders(token, "Bearer"),
+ body: JSON.stringify({ id: keyName }),
+ },
+ fetchImpl,
+ );
+ } catch {
+ throw new IntegrationError(
+ primary
+ ? "convex_operation_and_ephemeral_cleanup_failed"
+ : "convex_ephemeral_cleanup_failed",
+ 502,
+ );
+ }
+
+ if (primary) {
+ redactValueFromError(primary, value);
+ throw primary;
+ }
+
+ return {
+ deploymentName: deployment,
+ name,
+ set: true,
+ };
+}
diff --git a/lib/infra/setup-browser.ts b/lib/infra/setup-browser.ts
index 333967df..b01573d2 100644
--- a/lib/infra/setup-browser.ts
+++ b/lib/infra/setup-browser.ts
@@ -1,6 +1,6 @@
export const INTEGRATION_BROWSER_SCRIPT=String.raw`
(async()=>{
- const root=document.getElementById("setup"),endpoint=location.origin+"/api/integrations/setup",params=new URLSearchParams(location.search);let cleanup=()=>{},state={...(params.get("user")?{user:params.get("user")}:{ }),...(params.get("provider")?{provider:params.get("provider")}:{ }),...(params.get("section")==="ai-providers"?{section:"ai-providers"}:{})},authController,wantsTransfer=params.get("transfer")==="1";
+ const root=document.getElementById("setup"),endpoint=location.origin+"/api/integrations/setup",params=new URLSearchParams(location.search);let cleanup=()=>{},state={...(params.get("user")?{user:params.get("user")}:{ }),...(params.get("provider")?{provider:params.get("provider")}:{ }),...(params.get("section")==="ai-providers"?{section:"ai-providers"}:{}),...(params.get("connection")?{connection:params.get("connection")}:{})},authController,wantsTransfer=params.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})});
diff --git a/lib/infra/types.ts b/lib/infra/types.ts
index 6f28b452..fc335739 100644
--- a/lib/infra/types.ts
+++ b/lib/infra/types.ts
@@ -24,6 +24,7 @@ export const CONVEX_OPERATION_IDS = [
"convex.canonical.get",
"convex.canonical.set",
"convex.env.presence",
+ "convex.env.set",
"convex.project.deploy",
"convex.snapshot.import",
] as const;
@@ -79,6 +80,12 @@ export const CONVEX_OPERATION_SUPPORT: readonly ConvexOperationSupport[] = [
selfHosted: "unsupported",
reason: "Reads environment names with an ephemeral deploy key minted by the Convex Cloud management API; no self-hosted equivalent is wired yet.",
},
+ {
+ operation: "convex.env.set",
+ cloud: "supported",
+ selfHosted: "unsupported",
+ reason: "Sets environment variables with an ephemeral deploy key minted by the Convex Cloud management API; no self-hosted equivalent is wired yet.",
+ },
{
operation: "convex.project.deploy",
cloud: "supported",
diff --git a/lib/mcp/tools-integrations.ts b/lib/mcp/tools-integrations.ts
index 5e476a3a..93eb2ba4 100644
--- a/lib/mcp/tools-integrations.ts
+++ b/lib/mcp/tools-integrations.ts
@@ -23,7 +23,7 @@ export const INTEGRATION_TOOLS:McpTool[]=[
{name:"integration_execute",title:"Use Integration",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. Native Google supports the bounded read operations listed in its catalog without Composio. Non-verification operations require confirm=true. No credentials in arguments.",
chatgptDescription:"Use a named connection.",
- 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","mcp.tools.list","mcp.tool","composio.tool","google.bind","google.disconnect","google.operations.list",...GOOGLE_READ_OPERATIONS.map(operation=>operation.name)]},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.env.set","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","mcp.tools.list","mcp.tool","composio.tool","google.bind","google.disconnect","google.operations.list",...GOOGLE_READ_OPERATIONS.map(operation=>operation.name)]},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)}),
},
];