Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Remove agent gates

Richie McIlroyfb3f24380cf1
diff --git a/apps/web/__tests__/unit/agent-auth.test.ts b/apps/web/__tests__/unit/agent-auth.test.ts
index 402a2364b..42b5f984d 100644
--- a/apps/web/__tests__/unit/agent-auth.test.ts
+++ b/apps/web/__tests__/unit/agent-auth.test.ts
@@ -10,7 +10,6 @@ import {
hashAgentSecret,
isAgentCodeVerifier,
isAgentLoopbackRedirectUri,
- isAgentReadAccessEnabled,
parseAgentAuthorizationRequest,
parseAgentScopes,
verifyAgentCodeChallenge,
@@ -109,47 +108,6 @@ describe("agent browser authorization", () => {
expect(hashAgentSecret(token)).not.toContain(token);
});
});
-
-describe("agent API dark launch", () => {
- it("requires both the production switch and exact allowlist membership", () => {
- expect(
- isAgentReadAccessEnabled({
- nodeEnv: "production",
- enabled: "true",
- allowlist: "[email protected]",
- email: "[email protected]",
- }),
- ).toBe(true);
- expect(
- isAgentReadAccessEnabled({
- nodeEnv: "production",
- enabled: "false",
- allowlist: "[email protected]",
- email: "[email protected]",
- }),
- ).toBe(false);
- expect(
- isAgentReadAccessEnabled({
- nodeEnv: "production",
- enabled: "true",
- allowlist: "[email protected]",
- email: "[email protected]",
- }),
- ).toBe(false);
- });
-
- it("stays available in local and test environments", () => {
- expect(
- isAgentReadAccessEnabled({
- nodeEnv: "test",
- enabled: undefined,
- allowlist: undefined,
- email: "[email protected]",
- }),
- ).toBe(true);
- });
-});
-
describe("legacy agent credentials", () => {
it("accepts desktop-era keys without extending mobile or extension keys", () => {
expect(isLegacyAgentKeySource("desktop")).toBe(true);
diff --git a/apps/web/lib/agent-auth.ts b/apps/web/lib/agent-auth.ts
index e494f77f4..54c844fe7 100644
--- a/apps/web/lib/agent-auth.ts
+++ b/apps/web/lib/agent-auth.ts
@@ -147,20 +147,3 @@ export const buildAgentCallbackUrl = (
if (params.error) url.searchParams.set("error", params.error);
return url.toString();
};
-
-export const isAgentReadAccessEnabled = (input: {
- nodeEnv: string | undefined;
- enabled: string | undefined;
- allowlist: string | undefined;
- email: string;
-}) => {
- if (input.nodeEnv !== "production") return true;
- if (input.enabled !== "true") return false;
- const allowedEmails = new Set(
- (input.allowlist ?? "")
- .split(",")
- .map((email) => email.trim().toLowerCase())
- .filter(Boolean),
- );
- return allowedEmails.has(input.email.trim().toLowerCase());
-};
diff --git a/packages/web-backend/src/AgentAuth.ts b/packages/web-backend/src/AgentAuth.ts
index 4a3c79a29..e5d490c12 100644
--- a/packages/web-backend/src/AgentAuth.ts
+++ b/packages/web-backend/src/AgentAuth.ts
@@ -94,18 +94,6 @@ const parseScopes = (value: unknown) => {
export const isLegacyAgentKeySource = (source: string) =>
source === "desktop" || source === "unknown";
-export const isAgentReadAccessEnabled = (email: string) => {
- if (process.env.NODE_ENV !== "production") return true;
- if (process.env.CAP_AGENT_API_READ_ENABLED !== "true") return false;
- const allowlist = new Set(
- (process.env.CAP_AGENT_API_ALLOWLIST ?? "")
- .split(",")
- .map((entry) => entry.trim().toLowerCase())
- .filter(Boolean),
- );
- return allowlist.has(email.trim().toLowerCase());
-};
-
export const AgentHttpAuthMiddlewareLive = Layer.effect(
Agent.AgentHttpAuthMiddleware,
Effect.gen(function* () {
@@ -143,9 +131,6 @@ export const AgentHttpAuthMiddlewareLive = Layer.effect(
}
const scopes = parseScopes(row.scopes);
if (!scopes) return yield* authRequired();
- if (!isAgentReadAccessEnabled(row.email)) {
- return yield* temporarilyUnavailable();
- }
const now = new Date();
if (shouldRefreshAgentLastUsedAt(row.lastUsedAt, now)) {
yield* database
@@ -196,9 +181,6 @@ export const AgentHttpAuthMiddlewareLive = Layer.effect(
);
if (!row) return yield* authRequired();
if (!isLegacyAgentKeySource(row.source)) return yield* authRequired();
- if (!isAgentReadAccessEnabled(row.email)) {
- return yield* temporarilyUnavailable();
- }
return Agent.AgentPrincipal.of({
id: row.id,