Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions apps/api/infra/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof createApi>

export type ApiWorkerResource = ReturnType<typeof createApi>
73 changes: 0 additions & 73 deletions apps/web/src/components/admin-ai-provider-panel-ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 = <LockedLabel label={label} helpText={helpText} envVarName={envVarName} />
const hasExternalLabel = Boolean(helpText || envVarName)

const select = (
<KumoSelect
label={hasExternalLabel ? undefined : labelNode}
aria-label={hasExternalLabel ? label : undefined}
value={selectedValue}
onValueChange={(nextValue) =>
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"
>
<KumoSelect.Option value={EMPTY_SELECT_VALUE}>{placeholder}</KumoSelect.Option>
{options.map((option) => (
<KumoSelect.Option key={option.value} value={option.value}>
{option.label}
</KumoSelect.Option>
))}
</KumoSelect>
)

if (!hasExternalLabel) {
return select
}

return (
<div className="grid w-full gap-2">
{labelNode}
{select}
{error ? <p className="text-sm leading-snug text-kumo-danger">{error}</p> : null}
</div>
)
}

export function ModelThinkingField({
label,
modelLabel,
Expand Down
37 changes: 0 additions & 37 deletions apps/web/src/components/admin-page/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Tabs
value={view}
onValueChange={(value) => {
if (isAdminView(value)) {
onChange(value)
}
}}
tabs={ADMIN_VIEW_TABS}
variant="segmented"
/>
)
}

export const INTEGRATION_TABS: Array<{
value: AdminIntegrationTab
label: string
Expand Down Expand Up @@ -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":
Expand Down
22 changes: 0 additions & 22 deletions packages/api/src/server/background/db/s0-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -263,24 +262,3 @@ export class S0ConfigStore {
return Option.flatMap(parsed, readEncryptedSecretRecord)
})
}

export interface S0ConfigStorePromise {
getJson<T = unknown>(key: string): Promise<Option.Option<T>>
putJson(key: string, value: unknown): Promise<void>
encryptedSecretConfigured(key: string): Promise<boolean>
getEncryptedSecret(key: string): Promise<Option.Option<string>>
setEncryptedSecret(key: string, plaintext: string): Promise<void>
}

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)),
}
}
32 changes: 1 addition & 31 deletions packages/api/src/server/background/isolate/model.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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,
Expand Down
19 changes: 0 additions & 19 deletions packages/api/src/server/background/workflows/lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<WorkflowRunRecord> {
return runEffectPromise(new WorkflowLifecycle(env).startWorkflowRun(input))
}
8 changes: 0 additions & 8 deletions packages/api/src/server/background/workflows/runtime-abi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -60,7 +60,6 @@ import {
type GitHubProviderService,
type IdentityProviderService,
} from "../../services/providers"
import { requireSessionAccess } from "./control-plane/sessions"

export { requestFromSource }

Expand Down Expand Up @@ -712,44 +711,3 @@ export function runControlPlane<A, E, R>(handler: ControlPlaneHandler<A, E, R>)
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<Response | null> {
// 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<Response | null>(failureResponse(failure.payload, failure.status)),
),
Effect.catchIf(UnauthorizedError.is, (cause) =>
Effect.succeed<Response | null>(error(cause.message, 401)),
),
Effect.catchIf(
(cause): cause is InternalServerError => cause instanceof InternalServerError,
(cause) => Effect.succeed<Response | null>(error(cause.message, 500)),
),
Effect.catch((cause) => Effect.succeed<Response | null>(error(describeError(cause), 500))),
),
)
}
20 changes: 0 additions & 20 deletions packages/api/src/server/effect/services/observability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -194,18 +186,6 @@ export function setRequestUserIdentity(
)
}

export function redactHeaders(headers: Headers): Record<string, string> {
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<T>(key: string, value: T | null | undefined): Record<string, T> {
return Option.match(Option.filter(Option.fromNullishOr(value), Boolean), {
onNone: (): Record<string, T> => ({}),
Expand Down
7 changes: 0 additions & 7 deletions packages/api/src/server/mcp/workflow-builder/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Loading