/
Alex_Ural
/
opencode
Обзор
Документация
Войти
/
Alex_Ural
/
opencode
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
packages/server/src/handlers/fs.ts
39 строк
1 KB
Kit Langton
refactor(protocol): extract server contracts (#33708)
25 июн 2026, 05:15
Не верифицирован
25 июн 2026, 05:15
56a37c3
Код
Авторство
О чём код?
import { FileSystem } from "@opencode-ai/core/filesystem" import { RelativePath } from "@opencode-ai/core/schema" import { Effect } from "effect" import { HttpServerResponse } from "effect/unstable/http" import { HttpApiBuilder } from "effect/unstable/httpapi" import { Api } from "../api" import { response } from "../location" export const FileSystemHandler = HttpApiBuilder.group(Api, "server.fs", (handlers) => Effect.gen(function* () { return handlers .handleRaw("fs.read", (ctx) => Effect.gen(function* () { const file = yield* (yield* FileSystem.Service).read({ path: RelativePath.make( decodeURIComponent(new URL(ctx.request.url, "http://localhost").pathname.slice(13)), ), }) return HttpServerResponse.uint8Array(file.content, { contentType: file.mime }) }), ) .handle("fs.list", (ctx) => response( Effect.gen(function* () { const fs = yield* FileSystem.Service return yield* fs.list(ctx.query) }), ), ) .handle("fs.find", (ctx) => response( Effect.gen(function* () { const fs = yield* FileSystem.Service return yield* fs.find(ctx.query) }), ), ) }), )