refactor(plugin): simplify promise adapter imports
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
export * as PluginPromise from "./promise"
|
export * as PluginPromise from "./promise"
|
||||||
|
|
||||||
import { Plugin } from "@opencode-ai/plugin/v2/effect"
|
import { define } from "@opencode-ai/plugin/v2/effect/plugin"
|
||||||
|
import type { Context, Plugin } from "@opencode-ai/plugin/v2/plugin"
|
||||||
import type { AnyTool } from "@opencode-ai/plugin/v2/tool"
|
import type { AnyTool } from "@opencode-ai/plugin/v2/tool"
|
||||||
import { Agent } from "@opencode-ai/schema/agent"
|
import { Agent } from "@opencode-ai/schema/agent"
|
||||||
import { Integration } from "@opencode-ai/schema/integration"
|
import { Integration } from "@opencode-ai/schema/integration"
|
||||||
@@ -16,11 +17,7 @@ import { Tool } from "../tool/tool"
|
|||||||
|
|
||||||
type HostRegistration = { readonly dispose: Effect.Effect<void> }
|
type HostRegistration = { readonly dispose: Effect.Effect<void> }
|
||||||
type Registration = { readonly dispose: () => Promise<void> }
|
type Registration = { readonly dispose: () => Promise<void> }
|
||||||
type PromisePlugin = import("@opencode-ai/plugin/v2/plugin").Plugin
|
type PromiseEvent = ReturnType<Context["event"]["subscribe"]> extends AsyncIterable<infer Event> ? Event : never
|
||||||
type PromisePluginContext = import("@opencode-ai/plugin/v2/plugin").Context
|
|
||||||
type PromiseEvent = ReturnType<PromisePluginContext["event"]["subscribe"]> extends AsyncIterable<infer Event>
|
|
||||||
? Event
|
|
||||||
: never
|
|
||||||
type JsonValue = null | boolean | number | string | Array<JsonValue> | { [key: string]: JsonValue }
|
type JsonValue = null | boolean | number | string | Array<JsonValue> | { [key: string]: JsonValue }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,8 +29,8 @@ type JsonValue = null | boolean | number | string | Array<JsonValue> | { [key: s
|
|||||||
* preserves boot-time batching, so Promise-plugin transforms still coalesce
|
* preserves boot-time batching, so Promise-plugin transforms still coalesce
|
||||||
* into one reload per domain.
|
* into one reload per domain.
|
||||||
*/
|
*/
|
||||||
export function fromPromise(plugin: PromisePlugin) {
|
export function fromPromise(plugin: Plugin) {
|
||||||
return Plugin.define({
|
return define({
|
||||||
id: plugin.id,
|
id: plugin.id,
|
||||||
effect: (host) =>
|
effect: (host) =>
|
||||||
Effect.gen(function* () {
|
Effect.gen(function* () {
|
||||||
@@ -59,7 +56,7 @@ export function fromPromise(plugin: PromisePlugin) {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
const context2: PromisePluginContext = {
|
const context2: Context = {
|
||||||
options: host.options,
|
options: host.options,
|
||||||
agent: {
|
agent: {
|
||||||
list: (input) => run(host.agent.list(input)),
|
list: (input) => run(host.agent.list(input)),
|
||||||
|
|||||||
Reference in New Issue
Block a user