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 Linear provider and route Composio key kinds by header

rahmanef63247d33fa3a00
diff --git a/app/api/integrations/setup/route.ts b/app/api/integrations/setup/route.ts
index c2d6d7d1..8b5bfaee 100644
--- a/app/api/integrations/setup/route.ts
+++ b/app/api/integrations/setup/route.ts
@@ -35,6 +35,7 @@ export async function POST(req: NextRequest) {
return NextResponse.json({ ok: true, verified: true, provider: result.provider }, { headers });
} catch (error) {
const safe = error instanceof SetupError || error instanceof IntegrationError ? error : new SetupError("setup_unavailable", 503);
- return NextResponse.json({ error: safe.code }, { status: safe.status, headers });
+ const detail = safe instanceof SetupError ? safe.detail : undefined;
+ return NextResponse.json({ error: safe.code, ...(detail ? { detail } : {}) }, { status: safe.status, headers });
}
}
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index efd5e34b..7de6a3b3 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -4,6 +4,16 @@
Newest first. `docs/PROGRESS.md` is the source of truth for *why* a change was made;
this is the *what*, and it is what Settings → Account → About shows as “What's new”.
+## 2026-10-21
+
+**Added**
+
+- `infra` add Linear provider and route Composio key kinds by header
+
+**Fixed**
+
+- `deps` pin vite 8.2.4 to clear GHSA-587h-7wmj-h5pm
+
## 2026-10-20
**Fixed**
@@ -1505,35 +1515,3 @@ this is the *what*, and it is what Settings → Account → About shows as “Wh
**Docs**
- `progress` log the shell-spec pass, the springs, and the backup
-
-## 2026-08-10
-
-**Added**
-
-- give Alfa the reach MCP has, and a gate so they cannot drift apart again
-- `mcp` managed-app logs and lifecycle, tiered by blast radius not by layer
-- `mcp` an MCP server so ChatGPT, Claude.ai or Cursor can drive this VPS
-
-**Fixed**
-
-- `cli` four missing verbs, a prod-breaking build, and a silently-wrong --base
-- close the four cheap findings from the tool-surface parity audit
-- `mcp` the audit trail was recording refused commands as successes
-- `audit` stop a test run appending to the owner's forensic trail
-- `mcp` record what an MCP token did — the trail it was bypassing
-- `a11y,perf` name the dock icons, announce login errors, stop the resize storm
-- `perf,ux` halve the boot API calls, unstick the dead chunk spinner, cut 9 orphans
-
-**Faster**
-
-- get the shell chrome and the Alfa catalog out of first load
-
-**Changed**
-
-- delete five retired subsystems nothing could reach
-
-**Docs**
-
-- `progress` log the three-surface parity audit and what it fixed
-- `progress` log the MCP server and what was verified live
-- cut five finished plans, trim PROGRESS's tail, log the audit follow-up
diff --git a/lib/infra/additional-doctor.test.ts b/lib/infra/additional-doctor.test.ts
index a1538beb..3074e7e3 100644
--- a/lib/infra/additional-doctor.test.ts
+++ b/lib/infra/additional-doctor.test.ts
@@ -36,6 +36,7 @@ describe("additional native credential providers", () => {
["clerk", "https://api.clerk.com/v1/users?limit=1", { apiKey: KEY }],
["supabase", "https://api.supabase.com/v1/projects", { managementToken: KEY }],
["convex-cloud", "https://api.convex.dev/v1/list_personal_access_tokens?limit=1", { personalToken: KEY }],
+ ["linear", "https://api.linear.app/graphql", { apiKey: KEY }],
])("checks %s at a fixed provider-owned endpoint", async (id, endpoint, values) => {
const mock = vi.fn(async (_input: RequestInfo | URL, _init?: RequestInit) => new Response("[]", { status: 200 })); vi.stubGlobal("fetch", mock);
const result = await doctorAdditionalProvider(id as string, values as Record<string, string>);
diff --git a/lib/infra/additional-doctor.ts b/lib/infra/additional-doctor.ts
index 90ca6d0f..d1e8307c 100644
--- a/lib/infra/additional-doctor.ts
+++ b/lib/infra/additional-doctor.ts
@@ -155,6 +155,26 @@ export async function doctorAdditionalProvider(id: string, values: Record<string
const username = typeof body.username === "string" && body.username.length <= 80 ? " as " + body.username : "";
return "authenticated; bot identity verified" + username;
}
+ case "linear": {
+ if (!present(values.apiKey)) return null;
+ // Linear personal API keys go in Authorization verbatim (no "Bearer"), and
+ // the viewer query proves the key belongs to a real account. The endpoint
+ // is fixed so an operator-supplied URL can never redirect credentials.
+ let response;
+ try {
+ response = await request("https://api.linear.app/graphql", {
+ method: "POST",
+ headers: { authorization: values.apiKey, "content-type": "application/json", accept: "application/json" },
+ body: JSON.stringify({ query: "query { viewer { id name } }" }),
+ });
+ } catch { throw new Error("Linear request failed"); }
+ if (response.status === 401 || response.status === 403) throw new Error("Linear rejected this API key");
+ if (!response.ok) throw new Error(`Linear HTTP ${response.status}`);
+ const viewer = obj(obj(response.body).data)?.viewer;
+ const name = obj(viewer).name;
+ const label = typeof name === "string" && name.length > 0 && name.length <= 120 && !name.includes(values.apiKey) ? " as " + name : "";
+ return "authenticated; viewer verified" + label;
+ }
case "doku":
return doctorDoku(values);
case "convex-cloud": {
diff --git a/lib/infra/additional-providers.ts b/lib/infra/additional-providers.ts
index 436438e3..7433a103 100644
--- a/lib/infra/additional-providers.ts
+++ b/lib/infra/additional-providers.ts
@@ -161,6 +161,15 @@ export const ADDITIONAL_PROVIDERS = {
links:[{label:"DOKU MCP guide",url:"https://developers.doku.com/accept-payments/doku-mcp-server"}],
},
] },
+ linear: {
+ id: "linear",
+ title: "Linear",
+ description: "Verify a Linear personal API key and read the authenticated viewer.",
+ feature: false,
+ fields: [
+ { key: "apiKey", label: "Personal API key", secret: true, required: true, placeholder: "lin_api_…", description: "Linear personal API key sent only as the raw Authorization header to Linear's fixed GraphQL endpoint. Linear OAuth app secrets and MCP tokens are different credentials and are not accepted here.", links: [{ label: "Linear API keys", url: "https://linear.app/settings/account/security" }] },
+ ],
+ },
"openai-app": {
id: "openai-app",
title: "OpenAI / ChatGPT App",
@@ -188,4 +197,5 @@ export const ADDITIONAL_GUIDANCE = {
discord: { url: "https://discord.com/developers/applications", reference: "https://discord.com/developers/docs/quick-start/getting-started", steps: ["Open the intended application in the Discord Developer Portal.", "Create/reset the bot token only if needed and enter it in this private Integrations form.", "For inbound interactions also copy the Application ID and Interactions Endpoint public key.", "MSO verifies the bot token through the Discord REST API; signed interactions are verified separately at the public channel endpoint."] },
doku: { url: "https://developers.doku.com/accept-payments/doku-mcp-server", reference: "https://developers.doku.com/accept-payments/doku-mcp-server", steps: ["Open DOKU's official MCP Server guide and choose Sandbox first unless this project is explicitly approved for production payments.", "Obtain the DOKU Client ID and MCP API Key for that environment.", "Enter them only in this private setup form; do not paste them into chat, Baton notes, RR, Git, or project MCP JSON.", "MSO calls the fixed official DOKU MCP endpoint with a read-only MCP initialize request before saving the connection."] },
"openai-app": { url: "https://chatgpt.com/", reference: "https://help.openai.com/en/articles/12584461-developer-mode-and-mcp-apps-in-chatgpt", steps: ["Enable ChatGPT developer mode, then create/register the remote MCP app for this MSO installation and complete Scan Tools + OAuth.", "Open the registered app details. Copy the App ID shown there, or copy the technical plugin_asdk_app_… id from the browser URL; do not use the Version ID as the app binding.", "Enter the App ID only in this private Integrations form. MSO normalizes plugin_asdk_app_… to canonical asdk_app_… and never returns the stored value through tool/model responses.", "Use the private plugin staging/link command when packaging. Keep the repository .app.json empty so a maintainer-specific App ID is never committed or distributed to other users."] },
+ linear: { url: "https://linear.app/settings/account/security", reference: "https://linear.app/developers/graphql", steps: ["Open Linear → Settings → Account → Security & login → Personal API keys.", "Create a key for this MSO connection only; a workspace-scoped OAuth app or the Linear MCP OAuth session will not work here.", "Grant only the workspace access this connection needs, and set an expiry if the workspace allows it.", "Paste the key into this private form only. MSO calls the fixed https://api.linear.app/graphql viewer query before saving and never returns the key through tools or model responses."] },
} as const satisfies Record<AdditionalProviderId, { url: string; reference: string; steps: readonly string[] }>;
diff --git a/lib/infra/catalog.ts b/lib/infra/catalog.ts
index 8fffe15e..6010982c 100644
--- a/lib/infra/catalog.ts
+++ b/lib/infra/catalog.ts
@@ -36,7 +36,7 @@ const definitions: Record<InfraProviderId, InfraProviderDefinition> = {
description: "Connect a Composio project key or organization key for native MSO automation.",
feature: false,
fields: [
- { key: "apiKey", label: "Project API key", secret: true, required: false, description: "Project key sent only as x-api-key to /api/v3.1/tools?limit=1." },
+ { key: "apiKey", label: "Project or user API key", secret: true, required: false, description: "ak_… project key (or a scoped project key) sent as x-api-key; uak_… user key, written by `composio login`, sent as x-user-api-key. Header chosen automatically from the key prefix." },
{ key: "orgApiKey", label: "Organization API key", secret: true, required: false, description: "Organization key sent only as x-org-api-key to /api/v3.1/org/owner/project/list." },
],
},
@@ -132,6 +132,10 @@ export function normalizeInfraValues(id: InfraProviderId, raw: Record<string, un
if (out.mailApiToken && out.mailApiToken.length < 24) throw new Error("Hostinger Mail API token is too short");
if (out.mailOrderId && !/^[A-Za-z0-9._-]{3,128}$/.test(out.mailOrderId)) throw new Error("Invalid Hostinger Mail order ID");
}
+ if (id === "linear") {
+ // Personal API keys are opaque single-line values; the doctor proves the rest.
+ if (out.apiKey && (out.apiKey.length < 20 || out.apiKey.length > 4096 || /[\s\x00-\x1f\x7f]/.test(out.apiKey))) throw new Error("Linear API key must be an opaque single-line value (20–4096 characters)");
+ }
if (id === GOOGLE_APP_PROVIDER || isGoogleProvider(id)) return normalizeGoogleConfig(id, out);
return out;
}
diff --git a/lib/infra/composio.test.ts b/lib/infra/composio.test.ts
new file mode 100644
index 00000000..63c54f0f
--- /dev/null
+++ b/lib/infra/composio.test.ts
@@ -0,0 +1,31 @@
+import { afterEach, describe, expect, it, vi } from "vitest";
+vi.mock("server-only", () => ({}));
+import { composioAuthHeader, doctorComposio } from "./composio";
+
+afterEach(() => vi.unstubAllGlobals());
+
+describe("composio credential routing", () => {
+ it("routes each key kind to its own header", () => {
+ expect(composioAuthHeader({ apiKey: "ak_project" })).toEqual({ header: { "x-api-key": "ak_project" }, kind: "project" });
+ expect(composioAuthHeader({ apiKey: "uak_user" })).toEqual({ header: { "x-user-api-key": "uak_user" }, kind: "user" });
+ expect(composioAuthHeader({ orgApiKey: "org_admin", apiKey: "ak_project" })).toEqual({ header: { "x-org-api-key": "org_admin" }, kind: "organization" });
+ expect(composioAuthHeader({})).toBeNull();
+ });
+
+ it("validates a user key at the session endpoint, never as x-api-key", async () => {
+ const mock = vi.fn(async (_input: RequestInfo | URL, init?: RequestInit) => {
+ const headers = new Headers(init?.headers);
+ expect(headers.get("x-user-api-key")).toBe("uak_synthetic_user_key");
+ expect(headers.has("x-api-key")).toBe(false);
+ return new Response("{}", { status: 200 });
+ });
+ vi.stubGlobal("fetch", mock);
+ await expect(doctorComposio({ apiKey: "uak_synthetic_user_key" })).resolves.toBe("Composio user key accepted");
+ expect(String(mock.mock.calls[0]?.[0])).toBe("https://backend.composio.dev/api/v3.1/auth/session/info");
+ });
+
+ it("reports a rejected key instead of claiming success", async () => {
+ vi.stubGlobal("fetch", vi.fn(async () => new Response("{}", { status: 401 })));
+ await expect(doctorComposio({ apiKey: "uak_synthetic_user_key" })).rejects.toThrow("Composio rejected this user key (401)");
+ });
+});
diff --git a/lib/infra/composio.ts b/lib/infra/composio.ts
index 024f4417..1e2600ef 100644
--- a/lib/infra/composio.ts
+++ b/lib/infra/composio.ts
@@ -3,14 +3,37 @@ import { readInfraProvider } from "./store";
import { request } from "./http";
const API = "https://backend.composio.dev/api/v3.1";
+
+/**
+ * Composio has four key kinds and each needs its own header. Project and scoped
+ * project keys use x-api-key; organization keys use x-org-api-key; a user key
+ * (uak_..., written by `composio login`) uses x-user-api-key. Sending a user key
+ * as x-api-key is rejected with 401, which used to make every save fail.
+ */
+export function composioAuthHeader(values: InfraProviderValues): { header: Record<string, string>; kind: "organization" | "user" | "project" } | null {
+ const orgKey = values.orgApiKey?.trim();
+ if (orgKey) return { header: { "x-org-api-key": orgKey }, kind: "organization" };
+ const key = values.apiKey?.trim();
+ if (!key) return null;
+ if (key.startsWith("uak_")) return { header: { "x-user-api-key": key }, kind: "user" };
+ return { header: { "x-api-key": key }, kind: "project" };
+}
+
export async function doctorComposio(candidate?: InfraProviderValues): Promise<string | null> {
const values = candidate ?? await readInfraProvider("composio");
- const key = values.apiKey;
- const orgKey = values.orgApiKey;
- if (!key && !orgKey) return null;
- const target = orgKey ? "/org/owner/project/list" : "/tools?limit=1";
- const header: Record<string, string> = orgKey ? { "x-org-api-key": orgKey } : { "x-api-key": key! };
- const response = await request(`${API}${target}`, { headers: header });
+ const auth = composioAuthHeader(values);
+ if (!auth) return null;
+ // Session-info proves the key kind and works for all three kinds; tool listing
+ // additionally proves project reach for keys that carry it.
+ const target = auth.kind === "organization" ? "/org/owner/project/list" : auth.kind === "user" ? "/auth/session/info" : "/tools?limit=1";
+ const response = await request(`${API}${target}`, { headers: auth.header });
+ if (response.status === 401 || response.status === 403) {
+ throw new Error(`Composio rejected this ${auth.kind} key (${response.status})`);
+ }
if (!response.ok) throw new Error(`Composio validation failed (${response.status})`);
- return orgKey ? "Composio organization key accepted" : "Composio project key accepted";
+ return auth.kind === "organization"
+ ? "Composio organization key accepted"
+ : auth.kind === "user"
+ ? "Composio user key accepted"
+ : "Composio project key accepted";
}
diff --git a/lib/infra/connection-external.ts b/lib/infra/connection-external.ts
index fa7329ad..89eaffe8 100644
--- a/lib/infra/connection-external.ts
+++ b/lib/infra/connection-external.ts
@@ -4,9 +4,11 @@ import { selectConnection, IntegrationError, assertNotBusy, type ConnectionSelec
import { composioDefinition, nativeDefinition } from "./connection-registry";
import { summaryIn } from "./connection-service";
import { request, obj } from "./http";
+import { composioAuthHeader } from "./composio";
const BASE="https://backend.composio.dev/api/v3.1";
-async function api(key:string,endpoint:string,body?:unknown){
- let result;try{result=await request(BASE+endpoint,{method:body===undefined?"GET":"POST",headers:{"x-api-key":key,accept:"application/json","content-type":"application/json"},...(body===undefined?{}:{body:JSON.stringify(body)})});}catch{throw new IntegrationError("composio_unreachable",502);}
+async function api(values:Record<string,string>,endpoint:string,body?:unknown){
+ const auth=composioAuthHeader(values);if(!auth)throw new IntegrationError("composio_project_key_required",409);
+ let result;try{result=await request(BASE+endpoint,{method:body===undefined?"GET":"POST",headers:{...auth.header,accept:"application/json","content-type":"application/json"},...(body===undefined?{}:{body:JSON.stringify(body)})});}catch{throw new IntegrationError("composio_unreachable",502);}
if(!result.ok)throw new IntegrationError(`composio_http_${result.status}`,502);return obj(result.body);
}
async function context(provider:string,selection:ConnectionSelector,brokerId?:string){
@@ -14,7 +16,7 @@ async function context(provider:string,selection:ConnectionSelector,brokerId?:st
const d=await readIntegrationState(),r=selectConnection(d,provider,selection),c=r.connection;
if(c.source!=="composio")throw new IntegrationError("composio_source_required");
const broker=selectConnection(d,"composio",{user:r.user,connection:brokerId??c.external?.brokerConnection,source:"direct",authMethod:"project"}).connection;
- if(!broker.values.apiKey)throw new IntegrationError("composio_project_key_required",409);
+ if(!broker.values.apiKey&&!broker.values.orgApiKey)throw new IntegrationError("composio_project_key_required",409);
return{d,r,c,broker,definition:composioDefinition(provider)!};
}
async function authorizeUnlocked(provider:string,selection:ConnectionSelector,options:{authConfigId?:string;brokerConnection?:string;createManaged?:boolean}={}){
@@ -22,18 +24,18 @@ async function authorizeUnlocked(provider:string,selection:ConnectionSelector,op
if(c.external?.connectedAccountId)throw new IntegrationError("already_linked_sync_first",409);
const scheme=c.authMethod==="oauth2"?"OAUTH2":"API_KEY";let config:Record<string,unknown>;
const configId=options.authConfigId??c.external?.authConfigId;
- if(configId){config=await api(broker.values.apiKey,`/auth_configs/${encodeURIComponent(configId)}`);}
+ if(configId){config=await api(broker.values,`/auth_configs/${encodeURIComponent(configId)}`);}
else{
- const result=await api(broker.values.apiKey,`/auth_configs?toolkit_slug=${encodeURIComponent(definition.toolkit)}&show_disabled=false&limit=50`);
+ const result=await api(broker.values,`/auth_configs?toolkit_slug=${encodeURIComponent(definition.toolkit)}&show_disabled=false&limit=50`);
const rows=(Array.isArray(result.items)?result.items:[]).map(obj).filter(x=>obj(x.toolkit).slug===definition.toolkit&&(x.auth_scheme??obj(x.auth_config).auth_scheme)===scheme&&(!x.status||x.status==="ENABLED"));
if(rows.length>1)throw new IntegrationError("choose_auth_config_id",409);
if(rows.length)config=rows[0];
- else if(definition.managed&&options.createManaged){const result=await api(broker.values.apiKey,"/auth_configs",{toolkit:{slug:definition.toolkit}});config={...obj(result.auth_config),toolkit:result.toolkit};}
+ else if(definition.managed&&options.createManaged){const result=await api(broker.values,"/auth_configs",{toolkit:{slug:definition.toolkit}});config={...obj(result.auth_config),toolkit:result.toolkit};}
else throw new IntegrationError("matching_auth_config_required",409);
}
const nested=obj(config.auth_config),actual=String(config.id??nested.id??""),toolkit=String(obj(config.toolkit).slug??"");
if(!actual||toolkit!==definition.toolkit||(config.auth_scheme??nested.auth_scheme)!==scheme||(config.status&&config.status!=="ENABLED"))throw new IntegrationError("auth_config_mismatch",409);
- const namespace=await readIntegrationState();const remoteUserId=`mso:${namespace.instanceId}:${namespace.users[r.user].uid}`,linked=await api(broker.values.apiKey,"/connected_accounts/link",{auth_config_id:actual,user_id:remoteUserId,alias:c.uid});
+ const namespace=await readIntegrationState();const remoteUserId=`mso:${namespace.instanceId}:${namespace.users[r.user].uid}`,linked=await api(broker.values,"/connected_accounts/link",{auth_config_id:actual,user_id:remoteUserId,alias:c.uid});
const id=linked.connected_account_id??linked.id;let url:URL;try{url=new URL(String(linked.redirect_url));}catch{throw new IntegrationError("invalid_authorization_link",502);}
if(typeof id!=="string"||!id||url.protocol!=="https:"||url.username||url.password||!["connect.composio.dev","backend.composio.dev","platform.composio.dev"].includes(url.hostname))throw new IntegrationError("invalid_authorization_link",502);
const safe=await mutateIntegrationState(d=>{const now=selectConnection(d,provider,selection).connection;if(now.uid!==c.uid||now.revision!==c.revision)throw new IntegrationError("connection_changed",409);now.external={connectedAccountId:id,authConfigId:actual,brokerConnection:broker.id,toolkit:definition.toolkit,remoteUserId,status:"INITIALIZING",checkedAt:Date.now()};now.revision++;return summaryIn(d,r.user,now);});
@@ -45,7 +47,7 @@ export async function verifyExternalIntegration(provider:string,selection:Connec
if(r.connection.source==="native-mcp")return{id:provider,ok:null,detail:"Authorize and verify through the provider-owned MCP client; no local credential fallback",user:r.user,connection:r.connection.id,endpoint:nativeDefinition(provider)?.url};
const {c,broker,definition}=await context(provider,selection);const id=c.external?.connectedAccountId;
if(!id)return{id:provider,ok:null,detail:"authorization required",user:r.user,connection:c.id};
- const raw=await api(broker.values.apiKey,`/connected_accounts/${encodeURIComponent(id)}`);
+ const raw=await api(broker.values,`/connected_accounts/${encodeURIComponent(id)}`);
if(raw.id!==id||obj(raw.toolkit).slug!==definition.toolkit||(c.external?.remoteUserId&&raw.user_id!==c.external.remoteUserId)||(c.external?.authConfigId&&obj(raw.auth_config).id!==c.external.authConfigId))throw new IntegrationError("connected_account_identity_mismatch",409);
const state=typeof raw.status==="string"&&/^[A-Z_]{1,40}$/.test(raw.status)?raw.status:"UNKNOWN";
await mutateIntegrationState(d=>{const now=selectConnection(d,provider,selection).connection;if(now.uid!==c.uid||now.revision!==c.revision)throw new IntegrationError("connection_changed",409);now.external={...now.external,status:state,checkedAt:Date.now()};});
@@ -57,8 +59,8 @@ async function executeUnlocked(provider:string,selection:ConnectionSelector,tool
if(!/^[A-Z][A-Z0-9_]{2,180}$/.test(tool)||!tool.startsWith(definition.toolkit.toUpperCase()+"_"))throw new IntegrationError("toolkit_tool_mismatch");
// Revalidate identity/status immediately before acting; never select another account implicitly.
const verified=await verifyExternalIntegration(provider,selection);if(verified.ok!==true)throw new IntegrationError("active_connected_account_required",409);
- const result=await api(broker.values.apiKey,`/tools/execute/${encodeURIComponent(tool)}`,{connected_account_id:c.external.connectedAccountId,arguments:args});
- function redact(v:unknown,depth=0):unknown{if(depth>16)return"[depth limited]";if(typeof v==="string")return v.split(broker.values.apiKey).join("[redacted]");if(Array.isArray(v))return v.map(x=>redact(x,depth+1));if(v&&typeof v==="object")return Object.fromEntries(Object.entries(v).map(([k,x])=>[k,/token|password|secret|api.?key|authorization|credential/i.test(k)?"[redacted]":redact(x,depth+1)]));return v;}
+ const result=await api(broker.values,`/tools/execute/${encodeURIComponent(tool)}`,{connected_account_id:c.external.connectedAccountId,arguments:args});
+ function redact(v:unknown,depth=0):unknown{if(depth>16)return"[depth limited]";if(typeof v==="string")return [broker.values.apiKey,broker.values.orgApiKey].reduce((out,secret)=>secret?out.split(secret).join("[redacted]"):out,v);if(Array.isArray(v))return v.map(x=>redact(x,depth+1));if(v&&typeof v==="object")return Object.fromEntries(Object.entries(v).map(([k,x])=>[k,/token|password|secret|api.?key|authorization|credential/i.test(k)?"[redacted]":redact(x,depth+1)]));return v;}
return{user:selection.user,provider,connection:c.id,source:c.source,result:redact(result)};
}
diff --git a/lib/infra/portable/mapping.ts b/lib/infra/portable/mapping.ts
index 928ea981..dd09a8fa 100644
--- a/lib/infra/portable/mapping.ts
+++ b/lib/infra/portable/mapping.ts
@@ -13,11 +13,12 @@ export const FIELD_MAP:Record<string,Record<string,string>>={
vercel:{VERCEL_TOKEN:'apiKey',VERCEL_TEAM_ID:'teamId'},
stripe:{STRIPE_SECRET_KEY:'apiKey',STRIPE_PUBLISHABLE_KEY:'publishableKey',STRIPE_WEBHOOK_SECRET:'webhookSecret'},
resend:{RESEND_API_KEY:'apiKey',RESEND_FROM_DOMAIN:'fromDomain'},
+ linear:{LINEAR_API_KEY:'apiKey'},
clerk:{CLERK_SECRET_KEY:'apiKey',NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY:'publishableKey',NEXT_PUBLIC_CLERK_FRONTEND_API_URL:'frontendUrl'},
supabase:{SUPABASE_ACCESS_TOKEN:'managementToken',SUPABASE_ORG_ID:'organizationId'},
doku:{DOKU_CLIENT_ID:'paymentClientId',DOKU_SECRET_KEY:'paymentSecretKey',DOKU_ENV:'paymentEnvironment',DOKU_MCP_CLIENT_ID:'mcpClientId',DOKU_MCP_API_KEY:'mcpApiKey',DOKU_MCP_ENV:'environment'},
};
-const DIRECT:Record<string,string>={github:'classic-pat',dokploy:'admin-api-key',cloudflare:'api-token',hostinger:'api-token',convex:'self-hosted-admin',vercel:'account-token',stripe:'secret-key',resend:'api-key',clerk:'instance-keys',supabase:'personal-access-token',doku:'mcp-api-key'};
+const DIRECT:Record<string,string>={github:'classic-pat',dokploy:'admin-api-key',cloudflare:'api-token',hostinger:'api-token',convex:'self-hosted-admin',vercel:'account-token',stripe:'secret-key',resend:'api-key',linear:'personal-api-key',clerk:'instance-keys',supabase:'personal-access-token',doku:'mcp-api-key'};
export function wireMethod(provider:string,source:string,method:string){
if(source!=='direct')return source==='native-mcp'?'provider-oauth':method;
return provider==='composio'?(method==='organization'?'organization-token':'project-api-key'):provider==='convex-cloud'?(method==='deployment'?'deployment-key':'personal-access-token'):provider==='doku'?(method==='payment'?'payment-hmac':'mcp-api-key'):provider==='hostinger'?(method==='mail'?'mail-api-token':'api-token'):DIRECT[provider]??method;
diff --git a/lib/infra/provider-icons.ts b/lib/infra/provider-icons.ts
index dc5d15ad..fdf173c1 100644
--- a/lib/infra/provider-icons.ts
+++ b/lib/infra/provider-icons.ts
@@ -8,6 +8,7 @@ export const PROVIDER_ICON_PATHS: Record<string, string> = {
"convex-cloud": "M15.09 18.916c3.488-.387 6.776-2.246 8.586-5.348-.857 7.673-9.247 12.522-16.095 9.545a3.47 3.47 0 0 1-1.547-1.314c-1.539-2.417-2.044-5.492-1.318-8.282 2.077 3.584 6.3 5.78 10.374 5.399m-10.501-7.65c-1.414 3.266-1.475 7.092.258 10.24-6.1-4.59-6.033-14.41-.074-18.953a3.44 3.44 0 0 1 1.893-.707c2.825-.15 5.695.942 7.708 2.977-4.09.04-8.073 2.66-9.785 6.442m11.757-5.437C14.283 2.951 11.053.992 7.515.933c6.84-3.105 15.253 1.929 16.17 9.37a3.6 3.6 0 0 1-.334 2.02c-1.278 2.594-3.647 4.607-6.416 5.352 2.029-3.763 1.778-8.36-.589-11.847",
"convex": "M15.09 18.916c3.488-.387 6.776-2.246 8.586-5.348-.857 7.673-9.247 12.522-16.095 9.545a3.47 3.47 0 0 1-1.547-1.314c-1.539-2.417-2.044-5.492-1.318-8.282 2.077 3.584 6.3 5.78 10.374 5.399m-10.501-7.65c-1.414 3.266-1.475 7.092.258 10.24-6.1-4.59-6.033-14.41-.074-18.953a3.44 3.44 0 0 1 1.893-.707c2.825-.15 5.695.942 7.708 2.977-4.09.04-8.073 2.66-9.785 6.442m11.757-5.437C14.283 2.951 11.053.992 7.515.933c6.84-3.105 15.253 1.929 16.17 9.37a3.6 3.6 0 0 1-.334 2.02c-1.278 2.594-3.647 4.607-6.416 5.352 2.029-3.763 1.778-8.36-.589-11.847",
"resend": "M14.679 0c4.648 0 7.413 2.765 7.413 6.434s-2.765 6.434-7.413 6.434H12.33L24 24h-8.245l-8.88-8.44c-.636-.588-.93-1.273-.93-1.86 0-.831.587-1.565 1.713-1.883l4.574-1.224c1.737-.465 2.936-1.81 2.936-3.572 0-2.153-1.761-3.4-3.939-3.4H0V0z",
+ "linear": "M2.886 4.18A11.982 11.982 0 0 1 11.99 0C18.624 0 24 5.376 24 12.009c0 3.64-1.62 6.903-4.18 9.105L2.887 4.18ZM1.817 5.626l16.556 16.556c-.524.33-1.075.62-1.65.866L.951 7.277c.247-.575.537-1.126.866-1.65ZM.322 9.163l14.515 14.515c-.71.172-1.443.282-2.195.322L0 11.358a12 12 0 0 1 .322-2.195Zm-.17 4.862 9.823 9.824a12.02 12.02 0 0 1-9.824-9.824Z",
"stripe": "M13.976 9.15c-2.172-.806-3.356-1.426-3.356-2.409 0-.831.683-1.305 1.901-1.305 2.227 0 4.515.858 6.09 1.631l.89-5.494C18.252.975 15.697 0 12.165 0 9.667 0 7.589.654 6.104 1.872 4.56 3.147 3.757 4.992 3.757 7.218c0 4.039 2.467 5.76 6.476 7.219 2.585.92 3.445 1.574 3.445 2.583 0 .98-.84 1.545-2.354 1.545-1.875 0-4.965-.921-6.99-2.109l-.9 5.555C5.175 22.99 8.385 24 11.714 24c2.641 0 4.843-.624 6.328-1.813 1.664-1.305 2.525-3.236 2.525-5.732 0-4.128-2.524-5.851-6.594-7.305h.003z",
"clerk": "m21.47 20.829-2.881-2.881a.572.572 0 0 0-.7-.084 6.854 6.854 0 0 1-7.081 0 .576.576 0 0 0-.7.084l-2.881 2.881a.576.576 0 0 0-.103.69.57.57 0 0 0 .166.186 12 12 0 0 0 14.113 0 .58.58 0 0 0 .239-.423.576.576 0 0 0-.172-.453Zm.002-17.668-2.88 2.88a.569.569 0 0 1-.701.084A6.857 6.857 0 0 0 8.724 8.08a6.862 6.862 0 0 0-1.222 3.692 6.86 6.86 0 0 0 .978 3.764.573.573 0 0 1-.083.699l-2.881 2.88a.567.567 0 0 1-.864-.063A11.993 11.993 0 0 1 6.771 2.7a11.99 11.99 0 0 1 14.637-.405.566.566 0 0 1 .232.418.57.57 0 0 1-.168.448Zm-7.118 12.261a3.427 3.427 0 1 0 0-6.854 3.427 3.427 0 0 0 0 6.854Z",
"supabase": "M11.9 1.036c-.015-.986-1.26-1.41-1.874-.637L.764 12.05C-.33 13.427.65 15.455 2.409 15.455h9.579l.113 7.51c.014.985 1.259 1.408 1.873.636l9.262-11.653c1.093-1.375.113-3.403-1.645-3.403h-9.642z",
diff --git a/lib/infra/setup-capability.ts b/lib/infra/setup-capability.ts
index 148418aa..6e253dd4 100644
--- a/lib/infra/setup-capability.ts
+++ b/lib/infra/setup-capability.ts
@@ -17,7 +17,8 @@ export const SETUP_MAX_BODY = 16 * 1024;
const ROOT = path.join(path.dirname(INFRA_STORE_PATH), "integration-setup");
type Grant = { user: string; connection: string; uid: string; revision: number; provider: InfraProviderId; method: SetupMethod; principal: string; expiresAt: number; attempts: number; used: boolean };
export class SetupError extends Error {
- constructor(public readonly code: string, public readonly status: number) { super(code); }
+ /** `detail` is a provider-safe status string (never a credential or response body). */
+ constructor(public readonly code: string, public readonly status: number, public readonly detail?: string) { super(code); }
}
const invalid = () => new SetupError("setup_expired_or_invalid", 401);
const hash = (token: string) => createHash("sha256").update(token).digest("hex");
@@ -112,7 +113,7 @@ export async function consumeIntegrationSetup(token: string, raw: unknown) {
// escape this boundary, never provider response text or credential values.
const configurationOnly = grant.provider === GOOGLE_APP_PROVIDER;
const result = configurationOnly ? { ok: true } : await doctorInfraProvider(grant.provider, candidate);
- if (result.ok !== true) throw new SetupError(result.ok === null ? "live_validation_unavailable" : "credential_validation_failed", 422);
+ if (result.ok !== true) throw new SetupError(result.ok === null ? "live_validation_unavailable" : "credential_validation_failed", 422, result.ok === null ? undefined : "detail" in result ? result.detail : undefined);
if (grant.expiresAt <= Date.now()) throw invalid();
grant.used = true;
await fs.writeFile(file, JSON.stringify(grant), { mode: 0o600 });
diff --git a/lib/infra/setup-guidance.ts b/lib/infra/setup-guidance.ts
index af667adf..fea33a5b 100644
--- a/lib/infra/setup-guidance.ts
+++ b/lib/infra/setup-guidance.ts
@@ -26,7 +26,7 @@ export function setupFields(provider: InfraProviderId, method: SetupMethod) {
return getInfraProviderDefinition(provider).fields.filter(f => keys.includes(f.key)).map(f => ({ ...f, required: true }));
}
if (provider === "composio") {
- if (!["project", "organization"].includes(method)) throw new Error("Choose a Composio project or organization key");
+ if (!["project", "organization"].includes(method)) throw new Error("Choose a Composio project/user or organization key");
return getInfraProviderDefinition(provider).fields.filter(f => f.key === (method === "project" ? "apiKey" : "orgApiKey")).map(f => ({ ...f, required: true }));
}
if (method !== "direct") throw new Error("Unsupported authentication method");
@@ -57,7 +57,7 @@ export function setupGuidance(provider: InfraProviderId, method: SetupMethod) {
reference: "https://docs.composio.dev/reference/authenticating-to-composio",
steps: method === "organization"
? ["Open Composio Settings.", "Choose General Settings → Organization Access Tokens.", "Create a token only when cross-project administration is required.", "Copy the organization token into this form. It uses x-org-api-key, not x-api-key."]
- : ["Select the intended Composio project.", "Open Settings → Project Settings → API Keys.", "Create a project API key with the least privileges needed.", "Copy the project key into this form. Connected-account OAuth tokens remain in Composio."],
+ : ["Select the intended Composio project.", "Open Settings → Project Settings → API Keys.", "Create a project API key with the least privileges needed. A user key (uak_…) from `composio login` is also accepted and is sent as x-user-api-key automatically.", "Copy the project key into this form. Connected-account OAuth tokens remain in Composio."],
},
cloudflare: {
url: "https://dash.cloudflare.com/profile/api-tokens",
diff --git a/lib/infra/setup-ui.ts b/lib/infra/setup-ui.ts
index f34195a3..3d310712 100644
--- a/lib/infra/setup-ui.ts
+++ b/lib/infra/setup-ui.ts
@@ -53,7 +53,7 @@ function mountIntegrationForm(root,setup,access){
try{
const response=await fetch(endpoint,{method:"POST",credentials:"omit",cache:"no-store",referrerPolicy:"no-referrer",headers:{"Content-Type":"application/json",Authorization:"Bearer "+token},body:JSON.stringify({action:"save",values}),signal:AbortSignal.any([abort.signal,AbortSignal.timeout(45000)])});
const data=await response.json();
- if(!response.ok){const messages={credential_validation_failed:"The provider rejected this key or could not be reached. Check key type, permissions, and expiry; nothing was saved.",invalid_credential_format:"Check the credential format and remove pasted line breaks.",connection_changed_reopen_setup:"This connection changed after the form opened. Reopen it before updating credentials.",required_fields_missing:"Complete all required fields.",enter_at_least_one_value:"Enter a value to update.",setup_expired_or_invalid:"Setup expired or already used. Open a new form."};throw new Error(messages[data.error]||"Unable to save. Reopen setup or check the provider; nothing was displayed.")}
+ if(!response.ok){const messages={credential_validation_failed:"The provider rejected this key or could not be reached. Check key type, permissions, and expiry; nothing was saved.",invalid_credential_format:"Check the credential format and remove pasted line breaks.",connection_changed_reopen_setup:"This connection changed after the form opened. Reopen it before updating credentials.",required_fields_missing:"Complete all required fields.",enter_at_least_one_value:"Enter a value to update.",setup_expired_or_invalid:"Setup expired or already used. Open a new form."};const base=messages[data.error]||"Unable to save. Reopen setup or check the provider; nothing was displayed.";throw new Error(typeof data.detail==="string"&&data.detail?"Provider said: "+data.detail.slice(0,200):base)}
used=true;clearTimeout(timer);inputs.forEach(f=>{f.input.value="";f.input.disabled=true});save.textContent="Saved";status.textContent=data.configurationOnly?"OAuth app configuration saved. Create or select a Google service connection to complete consent and verify API access.":"Verified and saved in MSO. This setup session is now closed.";
}catch(error){status.textContent=error.message||"Connection failed. Check MSO connectivity."}finally{if(!used)save.disabled=false;for(const key of Object.keys(values))delete values[key]}
});
diff --git a/lib/infra/types.ts b/lib/infra/types.ts
index 1b466fe1..50b77d61 100644
--- a/lib/infra/types.ts
+++ b/lib/infra/types.ts
@@ -1,4 +1,4 @@
-export const INFRA_PROVIDER_IDS = ["dokploy", "cloudflare", "hostinger", "composio", "github", "vercel", "convex-cloud", "convex", "resend", "stripe", "clerk", "supabase", "telegram", "discord", "doku", "mcp", "openai-app", "google-oauth-app", "google-search-console", "google-analytics"] as const;
+export const INFRA_PROVIDER_IDS = ["dokploy", "cloudflare", "hostinger", "composio", "github", "vercel", "convex-cloud", "convex", "resend", "stripe", "clerk", "supabase", "telegram", "discord", "doku", "linear", "mcp", "openai-app", "google-oauth-app", "google-search-console", "google-analytics"] as const;
export type InfraProviderId = (typeof INFRA_PROVIDER_IDS)[number];
export type InfraProviderValues = Record<string, string>;