Compare commits

...
Sign in to create a new pull request.

2 commits

Author SHA1 Message Date
Kit Langton
6af06c06c5 refactor: switch mcp siblings to self-reexport imports 2026-04-16 11:24:31 -04:00
Kit Langton
43e2617e72 feat: unwrap McpAuth, McpOAuthCallback namespaces to flat exports + barrel 2026-04-16 08:28:13 -04:00
8 changed files with 281 additions and 283 deletions

View file

@ -5,7 +5,7 @@ import { UnauthorizedError } from "@modelcontextprotocol/sdk/client/auth.js"
import * as prompts from "@clack/prompts" import * as prompts from "@clack/prompts"
import { UI } from "../ui" import { UI } from "../ui"
import { MCP } from "../../mcp" import { MCP } from "../../mcp"
import { McpAuth } from "../../mcp/auth" import { McpAuth } from "@/mcp/auth"
import { McpOAuthProvider } from "../../mcp/oauth-provider" import { McpOAuthProvider } from "../../mcp/oauth-provider"
import { Config } from "../../config" import { Config } from "../../config"
import { Instance } from "../../project/instance" import { Instance } from "../../project/instance"

View file

@ -4,7 +4,6 @@ import { Global } from "../global"
import { Effect, Layer, Context } from "effect" import { Effect, Layer, Context } from "effect"
import { AppFileSystem } from "@opencode-ai/shared/filesystem" import { AppFileSystem } from "@opencode-ai/shared/filesystem"
export namespace McpAuth {
export const Tokens = z.object({ export const Tokens = z.object({
accessToken: z.string(), accessToken: z.string(),
refreshToken: z.string().optional(), refreshToken: z.string().optional(),
@ -141,4 +140,4 @@ export namespace McpAuth {
) )
export const defaultLayer = layer.pipe(Layer.provide(AppFileSystem.defaultLayer)) export const defaultLayer = layer.pipe(Layer.provide(AppFileSystem.defaultLayer))
} export * as McpAuth from "./auth"

View file

@ -19,8 +19,8 @@ import { InstallationVersion } from "../installation/version"
import { withTimeout } from "@/util/timeout" import { withTimeout } from "@/util/timeout"
import { AppFileSystem } from "@opencode-ai/shared/filesystem" import { AppFileSystem } from "@opencode-ai/shared/filesystem"
import { McpOAuthProvider } from "./oauth-provider" import { McpOAuthProvider } from "./oauth-provider"
import { McpOAuthCallback } from "./oauth-callback" import * as McpOAuthCallback from "./oauth-callback"
import { McpAuth } from "./auth" import * as McpAuth from "./auth"
import { BusEvent } from "../bus/bus-event" import { BusEvent } from "../bus/bus-event"
import { Bus } from "@/bus" import { Bus } from "@/bus"
import { TuiEvent } from "@/cli/cmd/tui/event" import { TuiEvent } from "@/cli/cmd/tui/event"

View file

@ -56,7 +56,6 @@ interface PendingAuth {
timeout: ReturnType<typeof setTimeout> timeout: ReturnType<typeof setTimeout>
} }
export namespace McpOAuthCallback {
let server: ReturnType<typeof createServer> | undefined let server: ReturnType<typeof createServer> | undefined
const pendingAuths = new Map<string, PendingAuth>() const pendingAuths = new Map<string, PendingAuth>()
// Reverse index: mcpName → oauthState, so cancelPending(mcpName) can // Reverse index: mcpName → oauthState, so cancelPending(mcpName) can
@ -229,4 +228,4 @@ export namespace McpOAuthCallback {
export function isRunning(): boolean { export function isRunning(): boolean {
return server !== undefined return server !== undefined
} }
} export * as McpOAuthCallback from "./oauth-callback"

View file

@ -6,7 +6,7 @@ import type {
OAuthClientInformationFull, OAuthClientInformationFull,
} from "@modelcontextprotocol/sdk/shared/auth.js" } from "@modelcontextprotocol/sdk/shared/auth.js"
import { Effect } from "effect" import { Effect } from "effect"
import { McpAuth } from "./auth" import * as McpAuth from "./auth"
import { Log } from "../util" import { Log } from "../util"
const log = Log.create({ service: "mcp.oauth" }) const log = Log.create({ service: "mcp.oauth" })

View file

@ -641,7 +641,7 @@ test(
// ======================================================================== // ========================================================================
test("McpOAuthCallback.cancelPending is keyed by mcpName but pendingAuths uses oauthState", async () => { test("McpOAuthCallback.cancelPending is keyed by mcpName but pendingAuths uses oauthState", async () => {
const { McpOAuthCallback } = await import("../../src/mcp/oauth-callback") const McpOAuthCallback = await import("../../src/mcp/oauth-callback")
// Register a pending auth with an oauthState key, associated to an mcpName // Register a pending auth with an oauthState key, associated to an mcpName
const oauthState = "abc123hexstate" const oauthState = "abc123hexstate"

View file

@ -158,7 +158,7 @@ test("first connect to OAuth server shows needs_auth instead of failed", async (
test("state() generates a new state when none is saved", async () => { test("state() generates a new state when none is saved", async () => {
const { McpOAuthProvider } = await import("../../src/mcp/oauth-provider") const { McpOAuthProvider } = await import("../../src/mcp/oauth-provider")
const { McpAuth } = await import("../../src/mcp/auth") const McpAuth = await import("../../src/mcp/auth")
await using tmp = await tmpdir() await using tmp = await tmpdir()
@ -199,7 +199,7 @@ test("state() generates a new state when none is saved", async () => {
test("state() returns existing state when one is saved", async () => { test("state() returns existing state when one is saved", async () => {
const { McpOAuthProvider } = await import("../../src/mcp/oauth-provider") const { McpOAuthProvider } = await import("../../src/mcp/oauth-provider")
const { McpAuth } = await import("../../src/mcp/auth") const McpAuth = await import("../../src/mcp/auth")
await using tmp = await tmpdir() await using tmp = await tmpdir()

View file

@ -104,7 +104,7 @@ beforeEach(() => {
const { MCP } = await import("../../src/mcp/index") const { MCP } = await import("../../src/mcp/index")
const { AppRuntime } = await import("../../src/effect/app-runtime") const { AppRuntime } = await import("../../src/effect/app-runtime")
const { Bus } = await import("../../src/bus") const { Bus } = await import("../../src/bus")
const { McpOAuthCallback } = await import("../../src/mcp/oauth-callback") const McpOAuthCallback = await import("../../src/mcp/oauth-callback")
const { Instance } = await import("../../src/project/instance") const { Instance } = await import("../../src/project/instance")
const { tmpdir } = await import("../fixture/fixture") const { tmpdir } = await import("../fixture/fixture")
const service = MCP.Service as unknown as Effect.Effect<MCPNS.Interface, never, never> const service = MCP.Service as unknown as Effect.Effect<MCPNS.Interface, never, never>