fix(core): run Figma OAuth setup as plugin
This commit is contained in:
parent
456e6b5902
commit
02128f4254
4 changed files with 27 additions and 3 deletions
|
|
@ -15,7 +15,6 @@ import { Integration } from "../integration"
|
|||
import { IntegrationConnection } from "../integration/connection"
|
||||
import { KeyedMutex } from "../effect/keyed-mutex"
|
||||
import { Location } from "../location"
|
||||
import { FigmaPlugin } from "../plugin/figma"
|
||||
import { waitForAbort } from "@opencode-ai/util/process"
|
||||
import { State } from "../state"
|
||||
import { MCPClient } from "./client"
|
||||
|
|
@ -195,7 +194,6 @@ export const layer = (options?: Options) => Layer.effect(
|
|||
const urlElicitations = new Map<string, Form.ID>()
|
||||
for (const entry of documents) {
|
||||
for (const [name, server] of Object.entries(entry.info.mcp?.servers ?? {})) {
|
||||
FigmaPlugin.apply(server)
|
||||
runtime.set(ServerName.make(name), {
|
||||
config: { ...server, timeout: { ...timeout, ...server.timeout } },
|
||||
status: { status: "pending" },
|
||||
|
|
@ -624,7 +622,6 @@ export const layer = (options?: Options) => Layer.effect(
|
|||
if (previous.integrationID) owned.delete(previous.integrationID)
|
||||
if (previous.registration) yield* previous.registration.dispose
|
||||
}
|
||||
FigmaPlugin.apply(config)
|
||||
const entry: ServerEntry = {
|
||||
config: { ...config, timeout: { ...timeout, ...config.timeout } },
|
||||
status: { status: "pending" },
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
export * as FigmaPlugin from "./figma"
|
||||
|
||||
import { define } from "@opencode-ai/plugin/v2/effect/plugin"
|
||||
import { Effect } from "effect"
|
||||
import { Config } from "../config"
|
||||
import { ConfigMCP } from "../config/mcp"
|
||||
import { MCP } from "../mcp/index"
|
||||
|
||||
const CLIENT_ID = "3zVHNs9kINDDrk8loekLZV"
|
||||
|
||||
|
|
@ -15,3 +19,19 @@ export function apply(server: typeof ConfigMCP.Server.Type) {
|
|||
Object.assign(server, { oauth: { client_id: CLIENT_ID } })
|
||||
return server
|
||||
}
|
||||
|
||||
export const Plugin = define({
|
||||
id: "opencode.figma",
|
||||
effect: Effect.fn(function* () {
|
||||
const config = yield* Config.Service
|
||||
const mcp = yield* MCP.Service
|
||||
const documents = (yield* config.entries()).filter((entry): entry is Config.Document => entry.type === "document")
|
||||
for (const entry of documents) {
|
||||
for (const [name, server] of Object.entries(entry.info.mcp?.servers ?? {})) {
|
||||
if (server.type !== "remote" || !URL.canParse(server.url) || new URL(server.url).hostname !== "mcp.figma.com")
|
||||
continue
|
||||
yield* mcp.add(name, apply(server))
|
||||
}
|
||||
}
|
||||
}),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import { Integration } from "../integration"
|
|||
import { Location } from "../location"
|
||||
import { LocationMutation } from "../location-mutation"
|
||||
import { ModelsDev } from "../models-dev"
|
||||
import { MCP } from "../mcp/index"
|
||||
import { Npm } from "@opencode-ai/util/npm"
|
||||
import { PermissionV2 } from "../permission"
|
||||
import { Reference } from "../reference"
|
||||
|
|
@ -48,6 +49,7 @@ import { WellKnown } from "../wellknown"
|
|||
import { WriteTool } from "../tool/write"
|
||||
import { AgentPlugin } from "./agent"
|
||||
import { CommandPlugin } from "./command"
|
||||
import { FigmaPlugin } from "./figma"
|
||||
import { ModelsDevPlugin } from "./models-dev"
|
||||
import { ProviderPlugins } from "./provider"
|
||||
import { PluginRuntime } from "./runtime"
|
||||
|
|
@ -73,6 +75,7 @@ const services = Effect.fn("PluginInternal.services")(function* () {
|
|||
const location = yield* Location.Service
|
||||
const locationMutation = yield* LocationMutation.Service
|
||||
const models = yield* ModelsDev.Service
|
||||
const mcp = yield* MCP.Service
|
||||
const npm = yield* Npm.Service
|
||||
const permission = yield* PermissionV2.Service
|
||||
const runtime = yield* PluginRuntime.Service
|
||||
|
|
@ -102,6 +105,7 @@ const services = Effect.fn("PluginInternal.services")(function* () {
|
|||
Context.make(Location.Service, location),
|
||||
Context.make(LocationMutation.Service, locationMutation),
|
||||
Context.make(ModelsDev.Service, models),
|
||||
Context.make(MCP.Service, mcp),
|
||||
Context.make(Npm.Service, npm),
|
||||
Context.make(PermissionV2.Service, permission),
|
||||
Context.make(PluginRuntime.Service, runtime),
|
||||
|
|
@ -126,6 +130,7 @@ export type InternalPlugin = Plugin<Requirements | Scope.Scope>
|
|||
|
||||
const pre = [
|
||||
WellKnownPlugin.Plugin,
|
||||
FigmaPlugin.Plugin,
|
||||
AgentPlugin.Plugin,
|
||||
CommandPlugin.Plugin,
|
||||
SkillPlugin.Plugin,
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import { Integration } from "../integration"
|
|||
import { Location } from "../location"
|
||||
import { LocationMutation } from "../location-mutation"
|
||||
import { ModelsDev } from "../models-dev"
|
||||
import { MCP } from "../mcp/index"
|
||||
import { Npm } from "@opencode-ai/util/npm"
|
||||
import { PermissionV2 } from "../permission"
|
||||
import { PluginV2 } from "../plugin"
|
||||
|
|
@ -292,6 +293,7 @@ export const node = makeLocationNode({
|
|||
Location.node,
|
||||
LocationMutation.node,
|
||||
ModelsDev.node,
|
||||
MCP.node,
|
||||
Npm.node,
|
||||
PermissionV2.node,
|
||||
PluginRuntime.node,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue