Download packages/protocol/src/groups/location.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/protocol/src/groups/location.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/protocol/src/groups/location.ts
-
curl -L -o location.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/protocol/src/groups/location.ts
1.32 kB
| import { Location } from "@opencode-ai/schema/location" | |
| import { Schema } from "effect" | |
| import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi" | |
| export const LocationQuery = Schema.Struct({ | |
| location: Schema.optional( | |
| Schema.Struct({ | |
| directory: Schema.optional(Schema.String), | |
| workspace: Schema.optional(Schema.String), | |
| }), | |
| ), | |
| }).annotate({ identifier: "LocationQuery" }) | |
| export const locationQueryOpenApi = OpenApi.annotations({ | |
| transform: (operation) => { | |
| const parameters = operation.parameters | |
| if (!Array.isArray(parameters)) return operation | |
| return { | |
| ...operation, | |
| parameters: parameters.map((parameter) => | |
| parameter?.name === "location" && parameter?.in === "query" | |
| ? { ...parameter, style: "deepObject", explode: true } | |
| : parameter, | |
| ), | |
| } | |
| }, | |
| }) | |
| export const LocationGroup = HttpApiGroup.make("server.location").add( | |
| HttpApiEndpoint.get("location.get", "/api/location", { | |
| query: LocationQuery, | |
| success: Location.Info, | |
| }) | |
| .annotateMerge(locationQueryOpenApi) | |
| .annotateMerge( | |
| OpenApi.annotations({ | |
| identifier: "v2.location.get", | |
| summary: "Get location", | |
| description: "Resolve the requested location or the server default location.", | |
| }), | |
| ), | |
| ) | |