History

fix build

Rhys Sullivan committed 8 months ago

Commit 380105a1 parent f3e9beb6 files · +63 −22Browse files

Unified · Split

6 files
  1. executor/apps/web/src/components/tools/install-configs.ts +3 −7
  2. executor/apps/web/src/components/tools/setup-card.tsx +4 −5
  3. executor/packages/database/src/auth/identity.test.ts +3 −4
  4. executor/packages/database/src/auth/mcp_api_key.test.ts +3 −4
  5. executor/packages/database/src/auth/naming.test.ts +25 −0
  6. executor/packages/database/src/auth/naming.ts +25 −2
executor/apps/web/src/components/tools/install-configs.ts+3−7
@@ -8,22 +8,18 @@ export function getAddMcpInstallConfig( · 7 unmodified lines
88 mcpUrl: string,
99 serverName: string,
1010 auth?: {
11− apiKeyEnvName?: string;
11+ apiKey?: string;
1212 },
1313 ): McpInstallConfig {
14− const apiKeyEnvName = auth?.apiKeyEnvName?.trim() || "API_KEY";
1514 const headerArg = auth
16− ? ` --header "x-api-key: $${apiKeyEnvName}"`
17− : "";
18− const exportLine = auth
19− ? `${apiKeyEnvName}="<paste-api-key-from-above>"`
15+ ? ` --header "x-api-key: ${auth.apiKey}"`
2016 : "";
2117
2218 return {
2319 type: "command",
2420 description: "Run once to install for all supported clients (via add-mcp):",
2521 content: auth
26− ? `${exportLine}\nnpx add-mcp "${mcpUrl}" --transport http --name "${serverName}" --all${headerArg}`
22+ ? `npx add-mcp "${mcpUrl}" --transport http --name "${serverName}" --all${headerArg}`
2723 : `npx add-mcp "${mcpUrl}" --transport http --name "${serverName}" --all${headerArg}`,
2824 };
2925 }
executor/apps/web/src/components/tools/setup-card.tsx+4−5
@@ -3,6 +3,7 @@ · 2 unmodified lines
33 import { useMemo, useState } from "react";
44 import { useQuery } from "convex/react";
55 import { Check, Copy } from "lucide-react";
6+import type { Id } from "@executor/database/convex/_generated/dataModel";
67 import { Button } from "@/components/ui/button";
78 import { Input } from "@/components/ui/input";
89 import { Label } from "@/components/ui/label";
@@ -50,7 +51,7 @@ export function McpSetupCard({ · 41 unmodified lines
5051 workspaceId,
5152 sessionId,
5253 }: {
53− workspaceId?: string;
54+ workspaceId?: Id<"workspaces">;
5455 sessionId?: string;
5556 }) {
5657 const [copiedKey, setCopiedKey] = useState<string | null>(null);
@@ -81,12 +82,12 @@ export function McpSetupCard({ · 24 unmodified lines
8182 isAnonymousSession && workspaceId
8283 ? {
8384 workspaceId,
84− sessionId,
85+ sessionId
8586 }
8687 : "skip",
8788 );
8889
89− const apiKeyEnvName = anonymousMcpApiKey?.envVar ?? "API_KEY";
90+
9091 const apiKeyValue = anonymousMcpApiKey?.enabled
9192 ? anonymousMcpApiKey.apiKey
9293 : null;
@@ -104,7 +105,6 @@ export function McpSetupCard({ · 11 unmodified lines
104105 serverName,
105106 isAnonymousSession
106107 ? {
107− apiKeyEnvName,
108108 apiKey: apiKeyValue ?? "your-api-key-here",
109109 }
110110 : undefined,
@@ -139,7 +139,6 @@ export function McpSetupCard({ · 28 unmodified lines
139139
140140 {isAnonymousSession && (
141141 <div className="mt-2 space-y-1.5">
142− <Label className="text-xs text-muted-foreground">API Key ({apiKeyEnvName})</Label>
143142 <div className="flex items-center gap-2">
144143 <Input
145144 value={apiKeyValue ?? "Loading API key..."}
executor/packages/database/src/auth/identity.test.ts+3−4
@@ -130,8 +130,7 @@ test("getAuthKitUserProfile retries with normalized user id", async () => { · 129 unmodified lines
130130 "workos|user_01KH1TVHS4WJCPQG2XQJGMMJMJ",
131131 "user_01KH1TVHS4WJCPQG2XQJGMMJMJ",
132132 ]);
133− expect(result).toEqual({
134− id: "user_01KH1TVHS4WJCPQG2XQJGMMJMJ",
135− email: "alex@example.com",
136− });
133+ expect(result).not.toBeNull();
134+ expect(result?.id).toBe("user_01KH1TVHS4WJCPQG2XQJGMMJMJ");
135+ expect(result?.email).toBe("alex@example.com");
137136 });
executor/packages/database/src/auth/mcp_api_key.test.ts+3−4
@@ -20,10 +20,9 @@ test("issueMcpApiKey + verifyMcpApiKey round trip", async () => { · 19 unmodified lines
2020
2121 expect(apiKey).toBeTruthy();
2222 const verified = await verifyMcpApiKey(apiKey);
23− expect(verified).toEqual({
24− workspaceId: "workspace_123",
25− accountId: "account_456",
26− });
23+ expect(verified).not.toBeNull();
24+ expect(verified?.workspaceId).toBe("workspace_123" as Id<"workspaces">);
25+ expect(verified?.accountId).toBe("account_456" as Id<"accounts">);
2726 });
2827
2928 test("verifyMcpApiKey rejects tampered token", async () => {
executor/packages/database/src/auth/naming.test.ts+25−0
@@ -0,0 +1,25 @@
1+import { expect, test } from "bun:test";
2+import { derivePersonalNames } from "./naming";
3+
4+test("derivePersonalNames ignores generated fallback full name", () => {
5+ const names = derivePersonalNames({
6+ fullName: "User GMMJMJ",
7+ email: "alex@example.com",
8+ workosUserId: "user_01KH1TVHS4WJCPQG2XQJGMMJMJ",
9+ });
10+
11+ expect(names.organizationName).toBe("Alex's Organization");
12+ expect(names.workspaceName).toBe("Alex's Workspace");
13+});
14+
15+test("derivePersonalNames prefers first name when available", () => {
16+ const names = derivePersonalNames({
17+ firstName: "Alex",
18+ fullName: "User GMMJMJ",
19+ email: "alex@example.com",
20+ workosUserId: "user_01KH1TVHS4WJCPQG2XQJGMMJMJ",
21+ });
22+
23+ expect(names.organizationName).toBe("Alex's Organization");
24+ expect(names.workspaceName).toBe("Alex's Workspace");
25+});
executor/packages/database/src/auth/naming.ts+25−2
@@ -14,6 +14,29 @@ function escapeRegex(value: string): string { · 13 unmodified lines
1414 return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1515 }
1616
17+function isGeneratedIdentityLabel(value: string, workosUserId: string): boolean {
18+ const normalizedValue = value.trim();
19+ const normalizedWorkosUserId = workosUserId.trim();
20+ if (!normalizedValue) {
21+ return false;
22+ }
23+
24+ const fallbackSuffix = normalizedWorkosUserId.slice(-6);
25+ if (fallbackSuffix && new RegExp(`^user\\s+${escapeRegex(fallbackSuffix)}$`, "i").test(normalizedValue)) {
26+ return true;
27+ }
28+
29+ if (/^user\s+[a-z0-9]{6,}$/i.test(normalizedValue)) {
30+ return true;
31+ }
32+
33+ if (/^(?:workos\|)?user_[a-z0-9]+$/i.test(normalizedValue)) {
34+ return true;
35+ }
36+
37+ return normalizedValue.toLowerCase() === normalizedWorkosUserId.toLowerCase();
38+}
39+
1740 export function isGeneratedPersonalOrganizationName(name: string, workosUserId: string): boolean {
1841 if (/workspace$/i.test(name)) {
1942 return true;
@@ -40,12 +63,12 @@ export function isGeneratedPersonalWorkspaceName(name: string, workosUserId: str · 20 unmodified lines
4063
4164 function deriveOwnerLabel(args: { firstName?: string; fullName?: string; email?: string; workosUserId: string }): string {
4265 const firstName = args.firstName?.trim();
43− if (firstName && !/^my$/i.test(firstName)) {
66+ if (firstName && !/^my$/i.test(firstName) && !/^user$/i.test(firstName)) {
4467 return firstName;
4568 }
4669
4770 const fullName = args.fullName?.trim();
48− if (fullName && !fullName.includes("@")) {
71+ if (fullName && !fullName.includes("@") && !isGeneratedIdentityLabel(fullName, args.workosUserId)) {
4972 return fullName;
5073 }
5174