import type { z } from 'zod' import type { PluginHostMethodSpec } from '../../../shared/plugins/workers/plugin-host-api' import type { PluginHostCallScope } from './plugin-host-call-scope' import type { PluginHostServices } from './plugin-host-method-bindings' export type PluginHostMethodContext = { pluginId: string services: PluginHostServices scope: PluginHostCallScope } export type PreparedPluginHostCall = | { ok: false; issue: string } | { ok: true params: unknown /** Runs the handler; `value` is null when the result failed its schema. */ execute: (ctx: PluginHostMethodContext) => Promise<{ value: unknown } | null> } export type BoundPluginHostMethod = { spec: PluginHostMethodSpec prepare: (params: unknown) => PreparedPluginHostCall } export function bind
( spec: PluginHostMethodSpec
, handler: (params: z.output
, ctx: PluginHostMethodContext) => Promise