ToolRegistration is now pure data (pluginKey, metadata, schemas) with no invoke closures. Plugins register a ToolInvoker that the registry delegates to at call time. SDK: - ToolRegistration: remove invoke closure, add pluginKey field - ToolInvoker: new interface (invoke by toolId) - ToolRegistry: add registerInvoker(pluginKey, invoker) - In-memory registry routes invoke() through invoker map OpenAPI plugin: - OperationBinding: minimal invocation data (method, path, params, body) - OpenApiOperationStore: plugin's own pluggable storage interface - makeOpenApiInvoker: single invoker looks up binding from store - plugin.ts is just registration (166 lines, down from 302) - No per-tool closures, no duplicated schemas In-memory tools plugin: - Single invoker with shared handler map - Registrations are pure data
Showing the changes to packages/plugins/openapi/src/openapi-utils.ts (1 of 10 files). Show all
Unified · Split
| @@ -4,6 +4,7 @@ · 3 unmodified lines | ||
| 4 | 4 | // Wraps the openapi-types V3/V3_1 union mess and provides clean ref resolution. |
| 5 | 5 | // --------------------------------------------------------------------------- |
| 6 | 6 | |
| 7 | +import { Option } from "effect"; | |
| 7 | 8 | import type { OpenAPIV3, OpenAPIV3_1 } from "openapi-types"; |
| 8 | 9 | import type { ParsedDocument } from "./parse"; |
| 9 | 10 | |
| @@ -49,6 +50,25 @@ export class DocResolver { · 39 unmodified lines | ||
| 49 | 50 | const isRef = (value: unknown): value is { $ref: string } => |
| 50 | 51 | typeof value === "object" && value !== null && "$ref" in value; |
| 51 | 52 | |
| 53 | +// --------------------------------------------------------------------------- | |
| 54 | +// Server URL resolution | |
| 55 | +// --------------------------------------------------------------------------- | |
| 56 | + | |
| 57 | +export const resolveBaseUrl = ( | |
| 58 | + servers: readonly { url: string; variables: import("effect/Option").Option<Record<string, string>> }[], | |
| 59 | +): string => { | |
| 60 | + const server = servers[0]; | |
| 61 | + if (!server) return ""; | |
| 62 | + | |
| 63 | + let url = server.url; | |
| 64 | + if (Option.isSome(server.variables)) { | |
| 65 | + for (const [name, value] of Object.entries(server.variables.value)) { | |
| 66 | + url = url.replaceAll(`{${name}}`, value); | |
| 67 | + } | |
| 68 | + } | |
| 69 | + return url; | |
| 70 | +}; | |
| 71 | + | |
| 52 | 72 | // --------------------------------------------------------------------------- |
| 53 | 73 | // Content negotiation |
| 54 | 74 | // --------------------------------------------------------------------------- |