refactor(server): serve raw filesystem content (#31911)
This commit is contained in:
parent
31b233e9db
commit
31c5454ee6
12 changed files with 67 additions and 93 deletions
|
|
@ -2,14 +2,9 @@ import { FileSystem } from "@opencode-ai/core/filesystem"
|
|||
import { Location } from "@opencode-ai/core/location"
|
||||
import { PositiveInt, RelativePath } from "@opencode-ai/core/schema"
|
||||
import { Schema } from "effect"
|
||||
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi"
|
||||
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/unstable/httpapi"
|
||||
import { LocationQuery, locationQueryOpenApi, LocationMiddleware } from "./location"
|
||||
|
||||
const ReadQuery = Schema.Struct({
|
||||
...LocationQuery.fields,
|
||||
path: RelativePath,
|
||||
})
|
||||
|
||||
const ListQuery = Schema.Struct({
|
||||
...LocationQuery.fields,
|
||||
path: RelativePath.pipe(Schema.optional),
|
||||
|
|
@ -24,16 +19,16 @@ const FindQuery = Schema.Struct({
|
|||
|
||||
export const FileSystemGroup = HttpApiGroup.make("server.fs")
|
||||
.add(
|
||||
HttpApiEndpoint.get("fs.read", "/api/fs/read", {
|
||||
query: ReadQuery,
|
||||
success: Location.response(FileSystem.Content),
|
||||
HttpApiEndpoint.get("fs.read", "/api/fs/read/*", {
|
||||
query: LocationQuery,
|
||||
success: Schema.Uint8Array.pipe(HttpApiSchema.asUint8Array()),
|
||||
})
|
||||
.annotateMerge(locationQueryOpenApi)
|
||||
.annotateMerge(
|
||||
OpenApi.annotations({
|
||||
identifier: "v2.fs.read",
|
||||
summary: "Read file",
|
||||
description: "Read one file relative to the requested location.",
|
||||
description: "Serve one file relative to the requested location.",
|
||||
}),
|
||||
),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue