From 80e013ec81ce13443e0a78cce9823dbe0c77cc0d Mon Sep 17 00:00:00 2001 From: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com> Date: Fri, 13 Nov 2026 19:47:13 +0000 Subject: [PATCH] Scope goal reads to the session directory and stabilize the background activity tests --- .env.example | 3 + backend/src/auth/index.ts | 3 + backend/src/routes/opencode-auth-proxy.ts | 32 ++++++++- .../test/routes/opencode-auth-proxy.test.ts | 56 ++++++++++++++++ e2e/background-activity.spec.ts | 16 ++++- e2e/env.ts | 1 + .../src/components/message/PromptInput.tsx | 4 +- frontend/src/contexts/EventContext.test.tsx | 6 +- frontend/src/hooks/useSessionGoals.test.tsx | 65 +++++++++++++++++-- frontend/src/hooks/useSessionGoals.ts | 34 +++++++--- frontend/src/pages/SessionDetail.tsx | 3 +- .../__tests__/SessionDetail.goal.test.tsx | 54 +++++++++++++++ frontend/src/test/promptInput.tsx | 1 + shared/src/config/env.ts | 1 + 14 files changed, 257 insertions(+), 22 deletions(-) create mode 100644 frontend/src/pages/__tests__/SessionDetail.goal.test.tsx diff --git a/.env.example b/.env.example index f2a5598a..b888e77a 100644 --- a/.env.example +++ b/.env.example @@ -114,6 +114,9 @@ DEBUG=false # so set true explicitly for HTTPS. # AUTH_SECURE_COOKIES=true +# Auth rate limit: maximum auth requests per client per 60 seconds (production only) +# AUTH_RATE_LIMIT_MAX=100 + # OAuth Providers (optional - enable by providing client ID and secret) # GITHUB_CLIENT_ID= # GITHUB_CLIENT_SECRET= diff --git a/backend/src/auth/index.ts b/backend/src/auth/index.ts index 6e3346b1..ed0caa0d 100644 --- a/backend/src/auth/index.ts +++ b/backend/src/auth/index.ts @@ -59,6 +59,9 @@ export function createAuth( database: db, secret: env.SECRET, trustedOrigins, + rateLimit: { + max: env.RATE_LIMIT_MAX, + }, emailAndPassword: { enabled: true, minPasswordLength: 8, diff --git a/backend/src/routes/opencode-auth-proxy.ts b/backend/src/routes/opencode-auth-proxy.ts index adabce70..2212b1fc 100644 --- a/backend/src/routes/opencode-auth-proxy.ts +++ b/backend/src/routes/opencode-auth-proxy.ts @@ -1,5 +1,8 @@ import { Hono } from 'hono' import type { MiddlewareHandler } from 'hono' +import { cloneRawRequest } from 'hono/request' +import { parseJsonText } from '@opencode-manager/shared/utils' +import { z } from 'zod' import { opencodeServerManager } from '../services/opencode-single-server' import type { OpenCodeClient } from '../services/opencode/client' @@ -7,6 +10,25 @@ export type OpenCodeProxyClient = Pick export type OpenCodeLifecycleGate = Pick +const RPC_PATH_SEGMENT = '/rpc/' +const RPC_UNAVAILABLE_TYPE = 'rpc.unavailable' +const RPC_WARMUP_RETRY_DELAY_MS = 300 + +const rpcErrorSchema = z.object({ type: z.string() }) + +function delay(ms: number): Promise { + return new Promise((resolve) => { + setTimeout(resolve, ms) + }) +} + +async function isWarmingRpcUnavailable(response: Response): Promise { + if (response.status !== 400) return false + const body = await response.clone().text() + const parsed = rpcErrorSchema.safeParse(parseJsonText(body)) + return parsed.success && parsed.data.type === RPC_UNAVAILABLE_TYPE +} + export function createAuthenticatedOpenCodeProxyRoutes( openCodeClient: OpenCodeProxyClient, requireAuth: MiddlewareHandler, @@ -19,7 +41,15 @@ export function createAuthenticatedOpenCodeProxyRoutes( return c.json({ error: 'OpenCode lifecycle initialization is incomplete; refusing to proxy to an unmanaged server' }, 503) } - return openCodeClient.forwardRaw(c.req.raw) + if (!c.req.path.includes(RPC_PATH_SEGMENT)) { + return openCodeClient.forwardRaw(c.req.raw) + } + + const retryRequest = await cloneRawRequest(c.req) + const response = await openCodeClient.forwardRaw(c.req.raw) + if (!(await isWarmingRpcUnavailable(response))) return response + await delay(RPC_WARMUP_RETRY_DELAY_MS) + return openCodeClient.forwardRaw(retryRequest) }) return app diff --git a/backend/test/routes/opencode-auth-proxy.test.ts b/backend/test/routes/opencode-auth-proxy.test.ts index 63effe61..c7e6e9f0 100644 --- a/backend/test/routes/opencode-auth-proxy.test.ts +++ b/backend/test/routes/opencode-auth-proxy.test.ts @@ -211,6 +211,62 @@ describe('authenticated opencode proxy routes', () => { expect(forwardRaw).toHaveBeenCalledTimes(1) expect(await forwardedJson(forwardRaw)).toEqual(body) }) + + function rpcUnavailable(): Response { + return new Response( + JSON.stringify({ _tag: 'RpcError', type: 'rpc.unavailable', message: 'RPC is unavailable: opencode.goal' }), + { status: 400, headers: { 'Content-Type': 'application/json' } }, + ) + } + + async function rpcCall(path: string): Promise { + return buildApp(forwardRaw).request(path, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ input: { sessionID: 'ses_1' } }), + }) + } + + it('retries an RPC call once while the directory instance loads its RPCs', async () => { + forwardRaw + .mockResolvedValueOnce(rpcUnavailable()) + .mockResolvedValueOnce(new Response(JSON.stringify({ output: null }), { status: 200 })) + + vi.useFakeTimers() + try { + const pending = rpcCall('/api/opencode/rpc/opencode.goal/get') + await vi.advanceTimersByTimeAsync(0) + await vi.advanceTimersByTimeAsync(1_000) + const res = await pending + expect(res.status).toBe(200) + } finally { + vi.useRealTimers() + } + + expect(forwardRaw).toHaveBeenCalledTimes(2) + expect(forwardRaw.mock.calls[1]?.[0].url).toContain('/rpc/opencode.goal/get') + }) + + it('does not retry an unavailable RPC outside an RPC path', async () => { + forwardRaw.mockResolvedValueOnce(rpcUnavailable()) + + const res = await buildApp(forwardRaw).request('/api/opencode/session/ses_1/message', { method: 'POST' }) + + expect(res.status).toBe(400) + expect(forwardRaw).toHaveBeenCalledTimes(1) + }) + + it('does not retry a different RPC failure', async () => { + forwardRaw.mockResolvedValueOnce(new Response( + JSON.stringify({ _tag: 'RpcError', type: 'rpc.failed', message: 'RPC failed' }), + { status: 400, headers: { 'Content-Type': 'application/json' } }, + )) + + const res = await rpcCall('/api/opencode/rpc/opencode.goal/get') + + expect(res.status).toBe(400) + expect(forwardRaw).toHaveBeenCalledTimes(1) + }) }) describe('authenticated opencode proxy streaming', () => { diff --git a/e2e/background-activity.spec.ts b/e2e/background-activity.spec.ts index 15549f95..790f4ef6 100644 --- a/e2e/background-activity.spec.ts +++ b/e2e/background-activity.spec.ts @@ -100,7 +100,15 @@ async function navigateWithinApp(page: Page, url: string): Promise { }, url) } -test.afterEach(async ({ request }) => { +async function settleRequestDispatch(page: Page): Promise { + await page.evaluate(async () => { + await fetch('/api/health') + }) +} + +test.afterEach(async ({ page, request }) => { + await page.close() + const shells = createdShells.splice(0) const results = await Promise.allSettled(shells.map(({ directory, id }) => removeShell(request, directory, id))) const failures = results.flatMap((result) => (result.status === 'rejected' ? [String(result.reason)] : [])) @@ -232,12 +240,16 @@ test.describe('session background activity', () => { }) await navigateWithinApp(page, '/') + await expect(page.getByPlaceholder('Send a message...')).toBeHidden() + await settleRequestDispatch(page) + expect(unsubscribes).toEqual([]) + await removeShell(request, directory, shellId) await navigateWithinApp(page, `/repos/${repo.id}/sessions/${sessionId}`) await expect(page.getByPlaceholder('Send a message...')).toBeVisible() await expect(backgroundIndicator(page)).toBeHidden({ timeout: 20_000 }) - expect(unsubscribes).toEqual([]) + expect(unsubscribes.length).toBeLessThanOrEqual(1) }) test('follows a session moved to another directory without a reload', async ({ page, request, repo }) => { diff --git a/e2e/env.ts b/e2e/env.ts index e8a0c39d..b6e4899b 100644 --- a/e2e/env.ts +++ b/e2e/env.ts @@ -43,6 +43,7 @@ export function createServerEnv() { WORKSPACE_PATH: path.join(E2E_TMP, 'workspace'), REPO_BROWSE_ROOT: path.join(E2E_TMP, 'workspace'), AUTH_SECRET, + AUTH_RATE_LIMIT_MAX: '500', AUTH_TRUSTED_ORIGINS: `${BASE_URL},http://localhost:${SERVER_PORT}`, AUTH_SECURE_COOKIES: 'false', PASSKEY_ORIGIN: BASE_URL, diff --git a/frontend/src/components/message/PromptInput.tsx b/frontend/src/components/message/PromptInput.tsx index 56fc9d33..fa5f2178 100644 --- a/frontend/src/components/message/PromptInput.tsx +++ b/frontend/src/components/message/PromptInput.tsx @@ -127,6 +127,7 @@ export interface PromptInputHandle { interface PromptInputProps { directory?: string + goalDirectory: string | undefined sessionID: string onVoiceConversationActiveChange?: (active: boolean) => void onSuggestionsOpenChange?: (open: boolean) => void @@ -140,6 +141,7 @@ interface PromptInputProps { export const PromptInput = memo(forwardRef(function PromptInput({ directory, + goalDirectory, sessionID, onVoiceConversationActiveChange, onSuggestionsOpenChange, @@ -259,7 +261,7 @@ export const PromptInput = memo(forwardRef( const goalCommand = useSessionGoalCommand(directory) const isPromptSubmitPending = sendPrompt.isPending || sendShell.isPending || goalCommand.isPending const interruptSession = useInterruptSession() - const { data: goalRead } = useSessionGoal(sessionID, directory) + const { data: goalRead } = useSessionGoal(sessionID, goalDirectory) const { searchCommands, findCommand, recentNames } = useCommands({ directory }) const recordCommand = useRecentCommandsStore((state) => state.recordCommand) const isExactCommandPrompt = (value: string) => { diff --git a/frontend/src/contexts/EventContext.test.tsx b/frontend/src/contexts/EventContext.test.tsx index 12ffefa6..fdefb75c 100644 --- a/frontend/src/contexts/EventContext.test.tsx +++ b/frontend/src/contexts/EventContext.test.tsx @@ -1190,16 +1190,16 @@ describe('EventProvider permissions and forms', () => { } const updatedGoal: GoalState = { ...initialGoal, rounds: 1, updatedAt: 2000 } const queryClient = createTestQueryClient() - queryClient.setQueryData(['session-goal', 'session-1'], { supported: true, goal: initialGoal }) + queryClient.setQueryData(['session-goal', 'session-1', '/repo'], { supported: true, goal: initialGoal }) const harness = await renderProvider({ queryClient }) harness.push(goalChanged('session-1', updatedGoal, { directory: '/repo' })) - expect(queryClient.getQueryData(['session-goal', 'session-1'])).toEqual({ supported: true, goal: updatedGoal }) + expect(queryClient.getQueryData(['session-goal', 'session-1', '/repo'])).toEqual({ supported: true, goal: updatedGoal }) harness.push(sessionIdle('other', { directory: '/repo' })) - expect(queryClient.getQueryData(['session-goal', 'session-1'])).toEqual({ supported: true, goal: updatedGoal }) + expect(queryClient.getQueryData(['session-goal', 'session-1', '/repo'])).toEqual({ supported: true, goal: updatedGoal }) }) it('invalidates the sibling caches when a branch changes outside a repo row', async () => { diff --git a/frontend/src/hooks/useSessionGoals.test.tsx b/frontend/src/hooks/useSessionGoals.test.tsx index ddd3bb62..79e457eb 100644 --- a/frontend/src/hooks/useSessionGoals.test.tsx +++ b/frontend/src/hooks/useSessionGoals.test.tsx @@ -52,7 +52,7 @@ function deferred() { describe('useSessionGoal', () => { it('reads the goal from the local server', async () => { - const { result, fetchFake } = renderHookWithProviders(() => useSessionGoal('ses_1', '/repo'), { + const { result, fetchFake, queryClient } = renderHookWithProviders(() => useSessionGoal('ses_1', '/repo'), { ...hookProviders, fetchRoutes: [goalRoute()], }) @@ -62,6 +62,8 @@ describe('useSessionGoal', () => { const request = fetchFake.lastRequest('POST', goalReadPath) expect(request?.body).toEqual({ input: { sessionID: 'ses_1' } }) expect(request?.searchParams.get('location[directory]')).toBe('/repo') + expect(queryClient.getQueryData(['session-goal', 'ses_1', '/repo'])).toEqual(supportedGoal) + expect(queryClient.getQueryCache().find({ queryKey: ['session-goal', 'ses_1', '/other'] })).toBeUndefined() }) it('reads the goal from the current remote server and scopes its cache key', async () => { @@ -80,7 +82,7 @@ describe('useSessionGoal', () => { await waitFor(() => expect(result.current.data).toEqual(supportedGoal)) - expect(queryClient.getQueryCache().find({ queryKey: ['session-goal', 'ses_1', 'srv_remote'] })).toBeDefined() + expect(queryClient.getQueryCache().find({ queryKey: ['session-goal', 'ses_1', '/repo', 'srv_remote'] })).toBeDefined() }) it('does not poll for goal updates', async () => { @@ -147,12 +149,43 @@ describe('applySessionGoalEvent', () => { expect(result.current.data).toEqual(supportedGoal) }) + it('updates every cached goal for the session directory on the event server only', async () => { + const { result, queryClient } = renderHookWithProviders(() => useSessionGoal('ses_1', '/repo'), { + ...hookProviders, + fetchRoutes: [goalRoute()], + }) + + await waitFor(() => expect(result.current.data).toEqual(supportedGoal)) + + queryClient.setQueryData(['session-goal', 'ses_1', '/elsewhere'], supportedGoal) + queryClient.setQueryData(['session-goal', 'ses_2', '/repo'], supportedGoal) + queryClient.setQueryData(['session-goal', 'ses_1', '/repo', 'srv_remote'], supportedGoal) + + await act(async () => { + applySessionGoalEvent( + queryClient, + { type: 'rpc.opencode.goal.changed', data: { sessionID: 'ses_1', goal: updatedGoal } }, + 'local', + ) + }) + + const nextGoal = { supported: true, goal: updatedGoal } + expect(queryClient.getQueryData(['session-goal', 'ses_1', '/repo'])).toEqual(nextGoal) + expect(queryClient.getQueryData(['session-goal', 'ses_1', '/elsewhere'])).toEqual(nextGoal) + expect(queryClient.getQueryData(['session-goal', 'ses_2', '/repo'])).toEqual(supportedGoal) + expect(queryClient.getQueryData(['session-goal', 'ses_1', '/repo', 'srv_remote'])).toEqual(supportedGoal) + }) + it('writes the change under the event server scoped key', async () => { const { queryClient } = renderHookWithProviders(() => useSessionGoal('ses_1', '/repo'), { ...hookProviders, fetchRoutes: [goalRoute()], }) + queryClient.setQueryData(['session-goal', 'ses_1', '/repo', 'srv_remote'], supportedGoal) + queryClient.setQueryData(['session-goal', 'ses_2', '/repo', 'srv_remote'], supportedGoal) + queryClient.setQueryData(['session-goal', 'ses_1', 'other', 'srv_other'], supportedGoal) + await act(async () => { applySessionGoalEvent( queryClient, @@ -161,11 +194,13 @@ describe('applySessionGoalEvent', () => { ) }) - expect(queryClient.getQueryData(['session-goal', 'ses_1', 'srv_remote'])).toEqual({ + expect(queryClient.getQueryData(['session-goal', 'ses_1', '/repo', 'srv_remote'])).toEqual({ supported: true, goal: updatedGoal, }) - expect(queryClient.getQueryData(['session-goal', 'ses_1'])).toEqual(supportedGoal) + expect(queryClient.getQueryData(['session-goal', 'ses_2', '/repo', 'srv_remote'])).toEqual(supportedGoal) + expect(queryClient.getQueryData(['session-goal', 'ses_1', 'other', 'srv_other'])).toEqual(supportedGoal) + expect(queryClient.getQueryData(['session-goal', 'ses_1', '/repo'])).toEqual(supportedGoal) }) it('keeps the event goal when an in-flight read resolves afterwards', async () => { @@ -175,7 +210,9 @@ describe('applySessionGoalEvent', () => { fetchRoutes: [goalRoute(() => pending.promise)], }) - await waitFor(() => expect(queryClient.getQueryState(['session-goal', 'ses_1'])?.fetchStatus).toBe('fetching')) + await waitFor(() => + expect(queryClient.getQueryState(['session-goal', 'ses_1', '/repo'])?.fetchStatus).toBe('fetching'), + ) act(() => { applySessionGoalEvent( @@ -240,6 +277,24 @@ describe('useSessionGoalCommand', () => { ) }) + it('refetches the goal queries for the session after the command succeeds', async () => { + const { result, fetchFake } = renderHookWithProviders( + () => ({ goal: useSessionGoal('ses_1', '/repo'), command: useSessionGoalCommand('/repo') }), + { + ...hookProviders, + fetchRoutes: [goalRoute(), commandRoute, ...switchRoutes], + }, + ) + + await waitFor(() => expect(fetchFake.findRequests('POST', goalReadPath)).toHaveLength(1)) + + await act(async () => { + await result.current.command.mutateAsync({ sessionID: 'ses_1', text: 'pause' }) + }) + + await waitFor(() => expect(fetchFake.findRequests('POST', goalReadPath)).toHaveLength(2)) + }) + it('reports the command failure message', async () => { const failingCommand: FetchRoute = { method: 'POST', diff --git a/frontend/src/hooks/useSessionGoals.ts b/frontend/src/hooks/useSessionGoals.ts index 2a39b880..f9c92d0e 100644 --- a/frontend/src/hooks/useSessionGoals.ts +++ b/frontend/src/hooks/useSessionGoals.ts @@ -1,6 +1,6 @@ -import { useMutation, useQuery, useQueryClient, type QueryClient } from '@tanstack/react-query' +import { useMutation, useQuery, useQueryClient, type Query, type QueryClient } from '@tanstack/react-query' import { getSessionGoal, runCommand, type RunCommandInput } from '@/api/opencode' -import { useOpenCodeServerId } from '@/contexts/opencode-server-context' +import { isLocalOpenCodeServer, useOpenCodeServerId } from '@/contexts/opencode-server-context' import { useSyncSessionSelection } from '@/hooks/useOpenCode' import { serverScopedKey } from '@/lib/serverScope' import { showToast } from '@/lib/toast' @@ -13,14 +13,30 @@ import { export const SESSION_GOAL_QUERY_ROOT = 'session-goal' -function sessionGoalQueryKey(sessionID: string, serverId: string) { - return serverScopedKey([SESSION_GOAL_QUERY_ROOT, sessionID], serverId) +const SESSION_GOAL_KEY_BASE_LENGTH = 3 + +function sessionGoalQueryKey(sessionID: string, directory: string | undefined, serverId: string) { + return serverScopedKey([SESSION_GOAL_QUERY_ROOT, sessionID, directory], serverId) +} + +function isSessionGoalQueryFor(query: Query, sessionID: string, serverId: string): boolean { + const { queryKey } = query + if (queryKey[0] !== SESSION_GOAL_QUERY_ROOT || queryKey[1] !== sessionID) return false + if (isLocalOpenCodeServer(serverId)) return queryKey.length === SESSION_GOAL_KEY_BASE_LENGTH + return ( + queryKey.length === SESSION_GOAL_KEY_BASE_LENGTH + 1 + && queryKey[SESSION_GOAL_KEY_BASE_LENGTH] === serverId + ) +} + +function sessionGoalQueryPredicate(sessionID: string, serverId: string) { + return (query: Query) => isSessionGoalQueryFor(query, sessionID, serverId) } export function useSessionGoal(sessionID: string, directory: string | undefined) { const serverId = useOpenCodeServerId() return useQuery({ - queryKey: sessionGoalQueryKey(sessionID, serverId), + queryKey: sessionGoalQueryKey(sessionID, directory, serverId), queryFn: () => getSessionGoal(sessionID, directory, serverId), enabled: Boolean(directory), }) @@ -34,9 +50,9 @@ export function applySessionGoalEvent( const change = goalChangeFromEvent(event) if (!change) return false const nextGoal: SessionGoalRead = { supported: true, goal: change.goal } - const queryKey = sessionGoalQueryKey(change.sessionID, serverId) - void queryClient.cancelQueries({ queryKey }) - queryClient.setQueryData(queryKey, nextGoal) + const predicate = sessionGoalQueryPredicate(change.sessionID, serverId) + void queryClient.cancelQueries({ predicate }) + queryClient.setQueriesData({ predicate }, nextGoal) return true } @@ -55,7 +71,7 @@ export function useSessionGoalCommand(directory: string | undefined) { await runCommand({ ...command, name: GOAL_COMMAND_NAME }, serverId) }, onSuccess: (_result, input) => { - void queryClient.invalidateQueries({ queryKey: sessionGoalQueryKey(input.sessionID, serverId) }) + void queryClient.invalidateQueries({ predicate: sessionGoalQueryPredicate(input.sessionID, serverId) }) }, onError: (error: Error) => { showToast.error(error.message ?? 'Goal command failed') diff --git a/frontend/src/pages/SessionDetail.tsx b/frontend/src/pages/SessionDetail.tsx index 900f8105..11618c43 100644 --- a/frontend/src/pages/SessionDetail.tsx +++ b/frontend/src/pages/SessionDetail.tsx @@ -980,7 +980,7 @@ export function SessionDetail() {
- + void = () => undefined + const promise = new Promise((resolveResult) => { + resolve = resolveResult + }) + return { promise, resolve } +} + +function goalDirectories(fetchFake: FetchFake): Array { + return fetchFake + .findRequests('POST', GOAL_PATH) + .map((request) => request.searchParams.get('location[directory]')) +} + +describe('SessionDetail goal reads', () => { + beforeEach(() => { + installMatchMedia(false) + installWindowSize(900) + }) + + it('reads the goal with the session directory once it resolves instead of the repo directory', async () => { + const sessionResponse = deferred() + const session = makeSession({ + id: SESSION_ID, + title: 'Elsewhere', + location: { directory: SESSION_DIRECTORY }, + }) + const { fetchFake } = renderSessionPage({ + repo: makeRepo({ id: 1, fullPath: REPO_DIRECTORY }), + session, + sessionRespond: () => sessionResponse.promise, + }) + + await waitFor(() => expect(document.querySelector('[data-prompt-input]')).not.toBeNull()) + expect(goalDirectories(fetchFake)).toEqual([]) + + sessionResponse.resolve({ json: { data: session } }) + + await waitFor(() => expect(goalDirectories(fetchFake).length).toBeGreaterThan(0)) + expect(new Set(goalDirectories(fetchFake))).toEqual(new Set([SESSION_DIRECTORY])) + }) +}) diff --git a/frontend/src/test/promptInput.tsx b/frontend/src/test/promptInput.tsx index a6d21bf5..96b49df5 100644 --- a/frontend/src/test/promptInput.tsx +++ b/frontend/src/test/promptInput.tsx @@ -141,6 +141,7 @@ export async function renderPromptInput(fixture: PromptInputFixture = {}) { key={active.sessionID ?? 'test-session'} sessionID={active.sessionID ?? 'test-session'} directory={active.directory ?? '/test'} + goalDirectory={active.directory ?? '/test'} isSessionActive={active.isSessionActive ?? false} isStreamingResponse={active.isStreamingResponse ?? false} onScrollToBottom={() => {}} diff --git a/shared/src/config/env.ts b/shared/src/config/env.ts index d5c74877..31389baf 100644 --- a/shared/src/config/env.ts +++ b/shared/src/config/env.ts @@ -140,6 +140,7 @@ export const ENV = { PASSKEY_RP_ID: getEnvString('PASSKEY_RP_ID', 'localhost'), PASSKEY_RP_NAME: getEnvString('PASSKEY_RP_NAME', 'OpenCode Manager'), PASSKEY_ORIGIN: getEnvString('PASSKEY_ORIGIN', 'http://localhost:5003'), + RATE_LIMIT_MAX: getEnvNumber('AUTH_RATE_LIMIT_MAX', 100), }, } as const