feat(server): expose location paths
This commit is contained in:
parent
6e8aefcfa0
commit
a7855aa169
7 changed files with 65 additions and 1 deletions
|
|
@ -26,6 +26,7 @@ import { CredentialHandler } from "./handlers/credential"
|
|||
import { ProjectHandler } from "./handlers/project"
|
||||
import { ProjectCopyHandler } from "./handlers/project-copy"
|
||||
import { VcsHandler } from "./handlers/vcs"
|
||||
import { PathHandler } from "./handlers/path"
|
||||
import { EventFeed } from "./event-feed"
|
||||
|
||||
export const handlers = Layer.mergeAll(
|
||||
|
|
@ -56,4 +57,5 @@ export const handlers = Layer.mergeAll(
|
|||
ReferenceHandler,
|
||||
ProjectCopyHandler,
|
||||
VcsHandler,
|
||||
PathHandler,
|
||||
)
|
||||
|
|
|
|||
22
packages/server/src/handlers/path.ts
Normal file
22
packages/server/src/handlers/path.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { Location } from "@opencode-ai/core/location"
|
||||
import { AbsolutePath } from "@opencode-ai/core/schema"
|
||||
import { Global } from "@opencode-ai/util/global"
|
||||
import { Effect } from "effect"
|
||||
import { HttpApiBuilder } from "effect/unstable/httpapi"
|
||||
import { Api } from "../api"
|
||||
|
||||
export const PathHandler = HttpApiBuilder.group(Api, "server.path", (handlers) =>
|
||||
handlers.handle("path.get", () =>
|
||||
Effect.gen(function* () {
|
||||
const global = yield* Global.Service
|
||||
const location = yield* Location.Service
|
||||
return {
|
||||
home: AbsolutePath.make(global.home),
|
||||
state: AbsolutePath.make(global.state),
|
||||
config: AbsolutePath.make(global.config),
|
||||
worktree: location.project.directory,
|
||||
directory: location.directory,
|
||||
}
|
||||
}),
|
||||
),
|
||||
)
|
||||
|
|
@ -60,6 +60,7 @@ const applicationServices = LayerNode.group([
|
|||
WellKnown.node,
|
||||
PtyEnvironment.node,
|
||||
LocationServiceMap.node,
|
||||
Global.node,
|
||||
SessionRestart.node,
|
||||
])
|
||||
|
||||
|
|
@ -134,7 +135,9 @@ function makeRoutes<AuthError, AuthServices>(
|
|||
Layer.flatMap((context) => {
|
||||
const services = Layer.succeedContext(context)
|
||||
const requestServices = Layer.merge(
|
||||
Layer.succeedContext(Context.pick(PermissionSaved.Service, Project.Service, WellKnown.Service)(context)),
|
||||
Layer.succeedContext(
|
||||
Context.pick(Global.Service, PermissionSaved.Service, Project.Service, WellKnown.Service)(context),
|
||||
),
|
||||
ServerInfo.layer(serviceURLs, options.app),
|
||||
)
|
||||
return HttpApiBuilder.layer(Api, { openapiPath: "/openapi.json" }).pipe(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue