Showing the changes to packages/codemode-openapi/src (1 of 9 files). Show all
Unified · Split
| @@ -1,7 +1,12 @@ | |||
| 1 | import * as Data from "effect/Data"; | 1 | import * as Data from "effect/Data"; |
| 2 | import * as Effect from "effect/Effect"; | 2 | import * as Effect from "effect/Effect"; |
| 3 | 3 | ||
| 4 | import { toTool, type ToolMap } from "@executor-v3/codemode-core"; | 4 | import { |
| 5 | standardSchemaFromJsonSchema, | ||
| 6 | toTool, | ||
| 7 | type ToolMap, | ||
| 8 | unknownInputSchema, | ||
| 9 | } from "@executor-v3/codemode-core"; | ||
| 5 | 10 | ||
| 6 | import { | 11 | import { |
| 7 | extractOpenApiManifest, | 12 | extractOpenApiManifest, |
| @@ -179,6 +184,22 @@ const decodeFetchResponseBody = async (response: Response): Promise<unknown> => · 171 unmodified lines | |||
| 179 | return response.text(); | 184 | return response.text(); |
| 180 | }; | 185 | }; |
| 181 | 186 | ||
| 187 | const inputSchemaFromTypingJson = (inputSchemaJson: string | undefined) => { | ||
| 188 | if (!inputSchemaJson) { | ||
| 189 | return unknownInputSchema; | ||
| 190 | } | ||
| 191 | |||
| 192 | try { | ||
| 193 | return standardSchemaFromJsonSchema(JSON.parse(inputSchemaJson), { | ||
| 194 | vendor: "openapi", | ||
| 195 | fallback: unknownInputSchema, | ||
| 196 | }); | ||
| 197 | } catch { | ||
| 198 | return unknownInputSchema; | ||
| 199 | } | ||
| 200 | }; | ||
| 201 | |||
| 202 | |||
| 182 | type CreateOpenApiToolsFromManifestInput = { | 203 | type CreateOpenApiToolsFromManifestInput = { |
| 183 | manifest: OpenApiToolManifest; | 204 | manifest: OpenApiToolManifest; |
| 184 | baseUrl: string; | 205 | baseUrl: string; |
| @@ -297,6 +318,7 @@ export const createOpenApiToolsFromManifest = ( · 112 unmodified lines | |||
| 297 | result[toolPath] = toTool({ | 318 | result[toolPath] = toTool({ |
| 298 | tool: { | 319 | tool: { |
| 299 | description, | 320 | description, |
| 321 | inputSchema: inputSchemaFromTypingJson(extracted.typing?.inputSchemaJson), | ||
| 300 | execute: async (args: unknown) => { | 322 | execute: async (args: unknown) => { |
| 301 | const decodedArgs = asToolArgs(args); | 323 | const decodedArgs = asToolArgs(args); |
| 302 | const request = buildFetchRequest({ | 324 | const request = buildFetchRequest({ |