refactor(cli/mcp+agent): Stage 4 — drop AppRuntime.runPromise bridges (#25530)
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import { cmd } from "./cmd"
|
import { cmd } from "./cmd"
|
||||||
import * as prompts from "@clack/prompts"
|
import * as prompts from "@clack/prompts"
|
||||||
import { AppRuntime } from "@/effect/app-runtime"
|
|
||||||
import { UI } from "../ui"
|
import { UI } from "../ui"
|
||||||
import { Global } from "@opencode-ai/core/global"
|
import { Global } from "@opencode-ai/core/global"
|
||||||
import { Agent } from "../../agent/agent"
|
import { Agent } from "../../agent/agent"
|
||||||
@@ -66,6 +65,7 @@ const AgentCreateCommand = effectCmd({
|
|||||||
const maybeCtx = yield* InstanceRef
|
const maybeCtx = yield* InstanceRef
|
||||||
if (!maybeCtx) return yield* Effect.die("InstanceRef not provided")
|
if (!maybeCtx) return yield* Effect.die("InstanceRef not provided")
|
||||||
const ctx = maybeCtx
|
const ctx = maybeCtx
|
||||||
|
const agentSvc = yield* Agent.Service
|
||||||
yield* Effect.promise(async () => {
|
yield* Effect.promise(async () => {
|
||||||
const cliPath = args.path
|
const cliPath = args.path
|
||||||
const cliDescription = args.description
|
const cliDescription = args.description
|
||||||
@@ -127,9 +127,7 @@ const AgentCreateCommand = effectCmd({
|
|||||||
const spinner = prompts.spinner()
|
const spinner = prompts.spinner()
|
||||||
spinner.start("Generating agent configuration...")
|
spinner.start("Generating agent configuration...")
|
||||||
const model = args.model ? Provider.parseModel(args.model) : undefined
|
const model = args.model ? Provider.parseModel(args.model) : undefined
|
||||||
const generated = await AppRuntime.runPromise(
|
const generated = await Effect.runPromise(agentSvc.generate({ description, model })).catch((error) => {
|
||||||
Agent.Service.use((svc) => svc.generate({ description, model })),
|
|
||||||
).catch((error) => {
|
|
||||||
spinner.stop(`LLM failed to generate agent: ${error.message}`, 1)
|
spinner.stop(`LLM failed to generate agent: ${error.message}`, 1)
|
||||||
if (isFullyNonInteractive) process.exit(1)
|
if (isFullyNonInteractive) process.exit(1)
|
||||||
throw new UI.CancelledError()
|
throw new UI.CancelledError()
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import { Global } from "@opencode-ai/core/global"
|
|||||||
import { modify, applyEdits } from "jsonc-parser"
|
import { modify, applyEdits } from "jsonc-parser"
|
||||||
import { Filesystem } from "@/util/filesystem"
|
import { Filesystem } from "@/util/filesystem"
|
||||||
import { Bus } from "../../bus"
|
import { Bus } from "../../bus"
|
||||||
import { AppRuntime } from "../../effect/app-runtime"
|
|
||||||
import { Effect } from "effect"
|
import { Effect } from "effect"
|
||||||
|
|
||||||
function getAuthStatusIcon(status: MCP.AuthStatus): string {
|
function getAuthStatusIcon(status: MCP.AuthStatus): string {
|
||||||
@@ -606,11 +605,13 @@ export const McpDebugCommand = effectCmd({
|
|||||||
demandOption: true,
|
demandOption: true,
|
||||||
}),
|
}),
|
||||||
handler: Effect.fn("Cli.mcp.debug")(function* (args) {
|
handler: Effect.fn("Cli.mcp.debug")(function* (args) {
|
||||||
|
const config = yield* Config.Service.use((cfg) => cfg.get())
|
||||||
|
const mcp = yield* MCP.Service
|
||||||
|
const auth = yield* McpAuth.Service
|
||||||
yield* Effect.promise(async () => {
|
yield* Effect.promise(async () => {
|
||||||
UI.empty()
|
UI.empty()
|
||||||
prompts.intro("MCP OAuth Debug")
|
prompts.intro("MCP OAuth Debug")
|
||||||
|
|
||||||
const config = await AppRuntime.runPromise(Config.Service.use((cfg) => cfg.get()))
|
|
||||||
const mcpServers = config.mcp ?? {}
|
const mcpServers = config.mcp ?? {}
|
||||||
const serverName = args.name
|
const serverName = args.name
|
||||||
|
|
||||||
@@ -636,15 +637,11 @@ export const McpDebugCommand = effectCmd({
|
|||||||
prompts.log.info(`Server: ${serverName}`)
|
prompts.log.info(`Server: ${serverName}`)
|
||||||
prompts.log.info(`URL: ${serverConfig.url}`)
|
prompts.log.info(`URL: ${serverConfig.url}`)
|
||||||
|
|
||||||
// Check stored auth status
|
// Check stored auth status — services already in hand, run inline.
|
||||||
const { authStatus, entry } = await AppRuntime.runPromise(
|
const { authStatus, entry } = await Effect.runPromise(
|
||||||
Effect.gen(function* () {
|
Effect.all({
|
||||||
const mcp = yield* MCP.Service
|
authStatus: mcp.getAuthStatus(serverName),
|
||||||
const auth = yield* McpAuth.Service
|
entry: auth.get(serverName),
|
||||||
return {
|
|
||||||
authStatus: yield* mcp.getAuthStatus(serverName),
|
|
||||||
entry: yield* auth.get(serverName),
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
prompts.log.info(`Auth status: ${getAuthStatusIcon(authStatus)} ${getAuthStatusText(authStatus)}`)
|
prompts.log.info(`Auth status: ${getAuthStatusIcon(authStatus)} ${getAuthStatusText(authStatus)}`)
|
||||||
@@ -704,11 +701,6 @@ export const McpDebugCommand = effectCmd({
|
|||||||
|
|
||||||
// Try to discover OAuth metadata
|
// Try to discover OAuth metadata
|
||||||
const oauthConfig = typeof serverConfig.oauth === "object" ? serverConfig.oauth : undefined
|
const oauthConfig = typeof serverConfig.oauth === "object" ? serverConfig.oauth : undefined
|
||||||
const auth = await AppRuntime.runPromise(
|
|
||||||
Effect.gen(function* () {
|
|
||||||
return yield* McpAuth.Service
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
const authProvider = new McpOAuthProvider(
|
const authProvider = new McpOAuthProvider(
|
||||||
serverName,
|
serverName,
|
||||||
serverConfig.url,
|
serverConfig.url,
|
||||||
|
|||||||
Reference in New Issue
Block a user