From fff4157285ea3e140757b33f068019ecb7641218 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 22 Nov 2026 09:17:05 +0000 Subject: [PATCH] Remove unused exports with no callers These symbols were only referenced at their definitions. Call sites use the live helpers beside them, including the Effect workflow start path, S0ConfigStore, and the admin sidebar. Co-authored-by: Jonathan Beckman --- apps/api/infra/index.ts | 2 - .../components/admin-ai-provider-panel-ui.tsx | 73 ------------------- apps/web/src/components/admin-page/page.tsx | 37 ---------- .../api/src/server/background/db/s0-config.ts | 22 ------ .../src/server/background/isolate/model.ts | 32 +------- .../server/background/workflows/lifecycle.ts | 19 ----- .../background/workflows/runtime-abi.ts | 8 -- .../effect/handlers/shared/control-plane.ts | 44 +---------- .../server/effect/services/observability.ts | 20 ----- .../server/mcp/workflow-builder/runtime.ts | 7 -- 10 files changed, 2 insertions(+), 262 deletions(-) diff --git a/apps/api/infra/index.ts b/apps/api/infra/index.ts index e9bdba96..a00f9c27 100644 --- a/apps/api/infra/index.ts +++ b/apps/api/infra/index.ts @@ -696,5 +696,3 @@ function createAgentContainerNamespace( // SAFETY: ApiWorker is a type-only placeholder and is never read at runtime; it exists so binding declarations can name the createApi resource type. // oxlint-disable-next-line effect/avoid-any, anti-slop/no-chained-type-assertions -- ReturnType of createApi is an Alchemy Effect resource type that null does not overlap, and this placeholder is never read at runtime. export const ApiWorker = null as unknown as ReturnType - -export type ApiWorkerResource = ReturnType diff --git a/apps/web/src/components/admin-ai-provider-panel-ui.tsx b/apps/web/src/components/admin-ai-provider-panel-ui.tsx index cb744440..c0555469 100644 --- a/apps/web/src/components/admin-ai-provider-panel-ui.tsx +++ b/apps/web/src/components/admin-ai-provider-panel-ui.tsx @@ -18,8 +18,6 @@ import { import { useState, type ReactNode } from "react" import { squareIconButton } from "@/components/ui/kumo-icon-button" -const EMPTY_SELECT_VALUE = "__s0_admin_empty__" - const ADAPTER_OPTIONS = [ "@ai-sdk/openai", "@ai-sdk/anthropic", @@ -466,77 +464,6 @@ export function Field({ ) } -export function SelectField({ - label, - helpText, - value, - options, - onChange, - placeholder, - disabled, - disabledEnvVarName, - error, - portalContainer, -}: { - label: string - helpText?: string - value: string - options: Array<{ value: string; label: string }> - onChange: (value: string) => void - placeholder: string - disabled?: boolean - disabledEnvVarName?: string | null - error?: string - portalContainer?: HTMLElement | null -}) { - const selectedValue = value || EMPTY_SELECT_VALUE - const envVarName = disabled ? disabledEnvVarName : null - const labelNode = - const hasExternalLabel = Boolean(helpText || envVarName) - - const select = ( - - onChange(nextValue === EMPTY_SELECT_VALUE ? "" : String(nextValue ?? "")) - } - renderValue={(nextValue) => { - if (nextValue === EMPTY_SELECT_VALUE) { - return placeholder - } - - return options.find((option) => option.value === nextValue)?.label ?? String(nextValue) - }} - disabled={disabled} - placeholder={placeholder} - error={error ? { message: error, match: true } : undefined} - container={portalContainer ?? undefined} - className="w-full" - > - {placeholder} - {options.map((option) => ( - - {option.label} - - ))} - - ) - - if (!hasExternalLabel) { - return select - } - - return ( -
- {labelNode} - {select} - {error ?

{error}

: null} -
- ) -} - export function ModelThinkingField({ label, modelLabel, diff --git a/apps/web/src/components/admin-page/page.tsx b/apps/web/src/components/admin-page/page.tsx index 8d2f5bf3..b0e49ac5 100644 --- a/apps/web/src/components/admin-page/page.tsx +++ b/apps/web/src/components/admin-page/page.tsx @@ -336,34 +336,6 @@ export function AdminDenied({ email }: { email: string }) { ) } -export const ADMIN_VIEW_TABS: Array<{ value: AdminView; label: string }> = [ - { value: "sessions", label: "Agents" }, - { value: "workflows", label: "Workflows" }, - { value: "ai-search", label: "AI Search" }, - { value: "integrations", label: "Integrations" }, -] - -export function AdminViewTabs({ - view, - onChange, -}: { - view: AdminView - onChange: (view: AdminView) => void -}) { - return ( - { - if (isAdminView(value)) { - onChange(value) - } - }} - tabs={ADMIN_VIEW_TABS} - variant="segmented" - /> - ) -} - export const INTEGRATION_TABS: Array<{ value: AdminIntegrationTab label: string @@ -394,15 +366,6 @@ export function IntegrationTabs({ ) } -export function isAdminView(value: string): value is AdminView { - return ( - value === "sessions" || - value === "workflows" || - value === "ai-search" || - value === "integrations" - ) -} - export function getAdminViewTitle(view: AdminView): string { switch (view) { case "sessions": diff --git a/packages/api/src/server/background/db/s0-config.ts b/packages/api/src/server/background/db/s0-config.ts index 82e4d4d4..4fa38668 100644 --- a/packages/api/src/server/background/db/s0-config.ts +++ b/packages/api/src/server/background/db/s0-config.ts @@ -8,7 +8,6 @@ import type { SecretReference } from "@solzero/shared" import { decryptSecret, encryptSecret } from "../auth/crypto" import { toError } from "../../lib/effect-errors" import { parseJson, stringifyJson } from "../../lib/json" -import { runEffectPromise } from "../../lib/effect-promise" import type { Env } from "../types" export const S0_CONFIG_KEYS = { @@ -263,24 +262,3 @@ export class S0ConfigStore { return Option.flatMap(parsed, readEncryptedSecretRecord) }) } - -export interface S0ConfigStorePromise { - getJson(key: string): Promise> - putJson(key: string, value: unknown): Promise - encryptedSecretConfigured(key: string): Promise - getEncryptedSecret(key: string): Promise> - setEncryptedSecret(key: string, plaintext: string): Promise -} - -export function createS0ConfigStore(kv: KVNamespace, encryptionKey?: string): S0ConfigStorePromise { - const store = new S0ConfigStore(kv, encryptionKey) - - return { - getJson: (key) => runEffectPromise(store.getJson(key)), - putJson: (key, value) => runEffectPromise(store.putJson(key, value)), - encryptedSecretConfigured: (key) => runEffectPromise(store.encryptedSecretConfigured(key)), - getEncryptedSecret: (key) => runEffectPromise(store.getEncryptedSecret(key)), - setEncryptedSecret: (key, plaintext) => - runEffectPromise(store.setEncryptedSecret(key, plaintext)), - } -} diff --git a/packages/api/src/server/background/isolate/model.ts b/packages/api/src/server/background/isolate/model.ts index 325bc98d..7e1ccaf7 100644 --- a/packages/api/src/server/background/isolate/model.ts +++ b/packages/api/src/server/background/isolate/model.ts @@ -1,7 +1,7 @@ import { createAnthropic } from "@ai-sdk/anthropic" import { createOpenAI } from "@ai-sdk/openai" import { createOpenAICompatible } from "@ai-sdk/openai-compatible" -import { type LanguageModel, type ModelMessage } from "ai" +import { type LanguageModel } from "ai" import type { CompiledOpenCodeConfig } from "@solzero/shared" import * as Effect from "effect/Effect" import * as Match from "effect/Match" @@ -407,36 +407,6 @@ export const compileIsolateModelContext = Effect.fn("isolate.model.compileContex }, ) -function buildUserPrompt(input: { prompt: string; repoWarning?: string | null }): string { - return Option.match( - Option.fromNullishOr(input.repoWarning).pipe(Option.filter((warning) => warning.length > 0)), - { - onNone: () => input.prompt.trim(), - onSome: (warning) => - [ - "User request:", - input.prompt.trim(), - ["Repository warning:", warning.trim()].join("\n"), - ].join("\n\n"), - }, - ) -} - -export function buildIsolateModelMessages(input: { - prompt: string - repoWarning?: string | null -}): ModelMessage[] { - return [ - { - role: "user", - content: buildUserPrompt({ - prompt: input.prompt, - repoWarning: input.repoWarning, - }), - }, - ] -} - /** Avoid the native GPT-OSS 256-token default while preserving explicit turn budgets. */ export function resolveIsolateOutputTokenLimit( modelId: string, diff --git a/packages/api/src/server/background/workflows/lifecycle.ts b/packages/api/src/server/background/workflows/lifecycle.ts index e48b7a60..9f9a336e 100644 --- a/packages/api/src/server/background/workflows/lifecycle.ts +++ b/packages/api/src/server/background/workflows/lifecycle.ts @@ -24,7 +24,6 @@ import { normalizeWorkflowManifest } from "./manifest" import { startWorkflowRun, type WorkflowTriggerPayload } from "./runner" import { disableWorkflowSlackTriggers, registerWorkflowSlackTriggers } from "./slack-apps" import * as Effect from "effect/Effect" -import { runEffectPromise } from "../../lib/effect-promise" import * as Match from "effect/Match" import * as Option from "effect/Option" import * as Schema from "effect/Schema" @@ -574,21 +573,3 @@ export class WorkflowLifecycle { }) } } - -/** - * Promise-facing webhook entry that runs a workflow via {@link WorkflowLifecycle} for the - * non-Effect public router (Worker request entry), which stays Effect-free to keep its imperative - * request-handling path lint-clean. Runs the underlying Effect at this boundary. - */ -export function startWorkflowRunFromWebhook( - env: Env, - input: { - workflow: WorkflowRecord - trigger: WorkflowTriggerPayload - userId?: string - oktaUserId?: string | null - log?: RequestLogger - }, -): Promise { - return runEffectPromise(new WorkflowLifecycle(env).startWorkflowRun(input)) -} diff --git a/packages/api/src/server/background/workflows/runtime-abi.ts b/packages/api/src/server/background/workflows/runtime-abi.ts index 76d2a18b..15299323 100644 --- a/packages/api/src/server/background/workflows/runtime-abi.ts +++ b/packages/api/src/server/background/workflows/runtime-abi.ts @@ -42,20 +42,12 @@ function updateFingerprint(fingerprint: number, value: string): number { return next >>> 0 } -export function isWorkflowRuntimeAbiVersion(value: unknown): value is WorkflowRuntimeAbiVersion { - return WORKFLOW_RUNTIME_ABI_VERSIONS.some((version) => version === value) -} - export function getWorkflowRuntimeKernel( version: WorkflowRuntimeAbiVersion, ): WorkflowRuntimeKernelModule { return WORKFLOW_RUNTIME_KERNELS[version] } -export function getCurrentWorkflowRuntimeKernel(): WorkflowRuntimeKernelModule { - return getWorkflowRuntimeKernel(CURRENT_WORKFLOW_RUNTIME_ABI_VERSION) -} - export function getWorkflowRuntimeKernelModuleName( version: WorkflowRuntimeAbiVersion = CURRENT_WORKFLOW_RUNTIME_ABI_VERSION, ): string { diff --git a/packages/api/src/server/effect/handlers/shared/control-plane.ts b/packages/api/src/server/effect/handlers/shared/control-plane.ts index aa3e6071..2850261a 100644 --- a/packages/api/src/server/effect/handlers/shared/control-plane.ts +++ b/packages/api/src/server/effect/handlers/shared/control-plane.ts @@ -46,7 +46,7 @@ import { type ControlPlaneDb, } from "../../db/control-plane-db" import { getCloudflareBindings } from "../../services/middleware" -import { authenticateControlPlaneRequest, requestFromSource } from "../../services/auth" +import { requestFromSource } from "../../services/auth" import { annotateCurrentUserIdentity, EffectRequestLogger, @@ -60,7 +60,6 @@ import { type GitHubProviderService, type IdentityProviderService, } from "../../services/providers" -import { requireSessionAccess } from "./control-plane/sessions" export { requestFromSource } @@ -712,44 +711,3 @@ export function runControlPlane(handler: ControlPlaneHandler) Effect.map(toEffectResponse), ) } - -const authorizeSessionProxy = Effect.fn("controlPlane.authorizeSessionProxy")(function* ( - request: Request, - env: ApiEnv, - sessionId: string, -) { - const principal = yield* authenticateControlPlaneRequest(request, env) - yield* requireSessionAccess(request, env, principal, sessionId) - - return null -}) - -/** - * Promise bridge for the raw Worker preview-proxy router (a non-Effect boundary): authenticates - * and authorizes a session request, resolving to a short-circuit Response on failure or `null` - * when access is granted. - */ -export function authorizeSessionProxyRequest( - request: Request, - env: ApiEnv, - sessionId: string, -): Promise { - // oxlint-disable-next-line effect/effect-run-in-body -- Promise boundary for the non-Effect Worker preview-proxy router, which cannot import Effect without re-gating its imperative request plumbing. - return Effect.runPromise( - authorizeSessionProxy(request, env, sessionId).pipe( - Effect.catchIf( - (cause): cause is ControlPlaneFailure => cause instanceof ControlPlaneFailure, - (failure) => - Effect.succeed(failureResponse(failure.payload, failure.status)), - ), - Effect.catchIf(UnauthorizedError.is, (cause) => - Effect.succeed(error(cause.message, 401)), - ), - Effect.catchIf( - (cause): cause is InternalServerError => cause instanceof InternalServerError, - (cause) => Effect.succeed(error(cause.message, 500)), - ), - Effect.catch((cause) => Effect.succeed(error(describeError(cause), 500))), - ), - ) -} diff --git a/packages/api/src/server/effect/services/observability.ts b/packages/api/src/server/effect/services/observability.ts index 44fa3eeb..42446ba1 100644 --- a/packages/api/src/server/effect/services/observability.ts +++ b/packages/api/src/server/effect/services/observability.ts @@ -30,14 +30,6 @@ import { type CloudflareTracing, } from "../../background/observability/span" -const SENSITIVE_HEADER_NAMES = new Set([ - "authorization", - "cookie", - "set-cookie", - "x-api-key", - "cf-access-jwt-assertion", -]) - export type TracedExecutionContext = ExecutionContext & { readonly tracing: CloudflareTracing } @@ -194,18 +186,6 @@ export function setRequestUserIdentity( ) } -export function redactHeaders(headers: Headers): Record { - return Object.fromEntries( - Array.from(headers.entries(), ([key, value]) => [ - key, - Match.value(SENSITIVE_HEADER_NAMES.has(key.toLowerCase())).pipe( - Match.when(true, () => "[REDACTED]"), - Match.orElse(() => value), - ), - ]), - ) -} - function optionalAnnotation(key: string, value: T | null | undefined): Record { return Option.match(Option.filter(Option.fromNullishOr(value), Boolean), { onNone: (): Record => ({}), diff --git a/packages/api/src/server/mcp/workflow-builder/runtime.ts b/packages/api/src/server/mcp/workflow-builder/runtime.ts index bd6937ed..469cbbfd 100644 --- a/packages/api/src/server/mcp/workflow-builder/runtime.ts +++ b/packages/api/src/server/mcp/workflow-builder/runtime.ts @@ -289,10 +289,3 @@ export const readLatestWorkflowBuilderDraft = Effect.fn("mcp.workflowBuilder.rea }) }, ) - -/** Synchronous validation for callers that cannot thread Effect (e.g. schema decode boundaries). */ -export function validateWorkflowBuilderManifestSync(input: { - manifest: unknown -}): WorkflowDraftValidationResult { - return validateWorkflowDraft(unwrapWorkflowManifestInput(input.manifest)) -}