History

refactor: separate tool registration from invocation

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

Rhys Sullivan committed 7 months ago

Commit af627af1 parent 60368a210 files · +494 −274Browse files

Showing the changes to packages/plugins/openapi/src/openapi-utils.ts (1 of 10 files). Show all

Unified · Split

packages/plugins/openapi/src/openapi-utils.ts+20−0
@@ -4,6 +4,7 @@ · 3 unmodified lines
4// Wraps the openapi-types V3/V3_1 union mess and provides clean ref resolution.4// Wraps the openapi-types V3/V3_1 union mess and provides clean ref resolution.
5// ---------------------------------------------------------------------------5// ---------------------------------------------------------------------------
6 6
7import { Option } from "effect";
7import type { OpenAPIV3, OpenAPIV3_1 } from "openapi-types";8import type { OpenAPIV3, OpenAPIV3_1 } from "openapi-types";
8import type { ParsedDocument } from "./parse";9import type { ParsedDocument } from "./parse";
9 10
@@ -49,6 +50,25 @@ export class DocResolver { · 39 unmodified lines
49const isRef = (value: unknown): value is { $ref: string } =>50const isRef = (value: unknown): value is { $ref: string } =>
50 typeof value === "object" && value !== null && "$ref" in value;51 typeof value === "object" && value !== null && "$ref" in value;
51 52
53// ---------------------------------------------------------------------------
54// Server URL resolution
55// ---------------------------------------------------------------------------
56
57export 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// Content negotiation73// Content negotiation
54// ---------------------------------------------------------------------------74// ---------------------------------------------------------------------------

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t