mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-02 16:26:14 -04:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9de001d92f | |||
| 3cd894d40a | |||
| 0e705e2a05 | |||
| 421d649019 | |||
| a7855aa169 |
@@ -1030,13 +1030,22 @@ export interface VcsApi<E = never> {
|
|||||||
readonly diff: VcsDiffOperation<E>
|
readonly diff: VcsDiffOperation<E>
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Endpoint26_0Output = EffectValue<ReturnType<RawClient["server.debug"]["debug.location"]>>
|
type Endpoint26_0Request = Parameters<RawClient["server.path"]["path.get"]>[0]
|
||||||
export type DebugLocationListOperation<E = never> = () => Effect.Effect<Endpoint26_0Output, E>
|
export type Endpoint26_0Input = { readonly location?: Endpoint26_0Request["query"]["location"] }
|
||||||
|
export type Endpoint26_0Output = EffectValue<ReturnType<RawClient["server.path"]["path.get"]>>
|
||||||
|
export type PathGetOperation<E = never> = (input?: Endpoint26_0Input) => Effect.Effect<Endpoint26_0Output, E>
|
||||||
|
|
||||||
type Endpoint26_1Request = Parameters<RawClient["server.debug"]["debug.location.evict"]>[0]
|
export interface PathApi<E = never> {
|
||||||
export type Endpoint26_1Input = { readonly location?: Endpoint26_1Request["query"]["location"] }
|
readonly get: PathGetOperation<E>
|
||||||
export type Endpoint26_1Output = EffectValue<ReturnType<RawClient["server.debug"]["debug.location.evict"]>>
|
}
|
||||||
export type DebugLocationEvictOperation<E = never> = (input?: Endpoint26_1Input) => Effect.Effect<Endpoint26_1Output, E>
|
|
||||||
|
export type Endpoint27_0Output = EffectValue<ReturnType<RawClient["server.debug"]["debug.location"]>>
|
||||||
|
export type DebugLocationListOperation<E = never> = () => Effect.Effect<Endpoint27_0Output, E>
|
||||||
|
|
||||||
|
type Endpoint27_1Request = Parameters<RawClient["server.debug"]["debug.location.evict"]>[0]
|
||||||
|
export type Endpoint27_1Input = { readonly location?: Endpoint27_1Request["query"]["location"] }
|
||||||
|
export type Endpoint27_1Output = EffectValue<ReturnType<RawClient["server.debug"]["debug.location.evict"]>>
|
||||||
|
export type DebugLocationEvictOperation<E = never> = (input?: Endpoint27_1Input) => Effect.Effect<Endpoint27_1Output, E>
|
||||||
|
|
||||||
export interface DebugApi<E = never> {
|
export interface DebugApi<E = never> {
|
||||||
readonly location: { readonly list: DebugLocationListOperation<E>; readonly evict: DebugLocationEvictOperation<E> }
|
readonly location: { readonly list: DebugLocationListOperation<E>; readonly evict: DebugLocationEvictOperation<E> }
|
||||||
@@ -1069,5 +1078,6 @@ export interface AppApi<E = never> {
|
|||||||
readonly reference: ReferenceApi<E>
|
readonly reference: ReferenceApi<E>
|
||||||
readonly projectCopy: ProjectCopyApi<E>
|
readonly projectCopy: ProjectCopyApi<E>
|
||||||
readonly vcs: VcsApi<E>
|
readonly vcs: VcsApi<E>
|
||||||
|
readonly path: PathApi<E>
|
||||||
readonly debug: DebugApi<E>
|
readonly debug: DebugApi<E>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1232,16 +1232,23 @@ const Endpoint25_1 = (raw: RawClient["server.vcs"]) => (input: Endpoint25_1Input
|
|||||||
|
|
||||||
const adaptGroup25 = (raw: RawClient["server.vcs"]) => ({ status: Endpoint25_0(raw), diff: Endpoint25_1(raw) })
|
const adaptGroup25 = (raw: RawClient["server.vcs"]) => ({ status: Endpoint25_0(raw), diff: Endpoint25_1(raw) })
|
||||||
|
|
||||||
const Endpoint26_0 = (raw: RawClient["server.debug"]) => () =>
|
type Endpoint26_0Request = Parameters<RawClient["server.path"]["path.get"]>[0]
|
||||||
|
type Endpoint26_0Input = { readonly location?: Endpoint26_0Request["query"]["location"] }
|
||||||
|
const Endpoint26_0 = (raw: RawClient["server.path"]) => (input?: Endpoint26_0Input) =>
|
||||||
|
raw["path.get"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError))
|
||||||
|
|
||||||
|
const adaptGroup26 = (raw: RawClient["server.path"]) => ({ get: Endpoint26_0(raw) })
|
||||||
|
|
||||||
|
const Endpoint27_0 = (raw: RawClient["server.debug"]) => () =>
|
||||||
raw["debug.location"]({}).pipe(Effect.mapError(mapClientError))
|
raw["debug.location"]({}).pipe(Effect.mapError(mapClientError))
|
||||||
|
|
||||||
type Endpoint26_1Request = Parameters<RawClient["server.debug"]["debug.location.evict"]>[0]
|
type Endpoint27_1Request = Parameters<RawClient["server.debug"]["debug.location.evict"]>[0]
|
||||||
type Endpoint26_1Input = { readonly location?: Endpoint26_1Request["query"]["location"] }
|
type Endpoint27_1Input = { readonly location?: Endpoint27_1Request["query"]["location"] }
|
||||||
const Endpoint26_1 = (raw: RawClient["server.debug"]) => (input?: Endpoint26_1Input) =>
|
const Endpoint27_1 = (raw: RawClient["server.debug"]) => (input?: Endpoint27_1Input) =>
|
||||||
raw["debug.location.evict"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError))
|
raw["debug.location.evict"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError))
|
||||||
|
|
||||||
const adaptGroup26 = (raw: RawClient["server.debug"]) => ({
|
const adaptGroup27 = (raw: RawClient["server.debug"]) => ({
|
||||||
location: { list: Endpoint26_0(raw), evict: Endpoint26_1(raw) },
|
location: { list: Endpoint27_0(raw), evict: Endpoint27_1(raw) },
|
||||||
})
|
})
|
||||||
|
|
||||||
const adaptClient = (raw: RawClient) => ({
|
const adaptClient = (raw: RawClient) => ({
|
||||||
@@ -1271,7 +1278,8 @@ const adaptClient = (raw: RawClient) => ({
|
|||||||
reference: adaptGroup23(raw["server.reference"]),
|
reference: adaptGroup23(raw["server.reference"]),
|
||||||
projectCopy: adaptGroup24(raw["server.projectCopy"]),
|
projectCopy: adaptGroup24(raw["server.projectCopy"]),
|
||||||
vcs: adaptGroup25(raw["server.vcs"]),
|
vcs: adaptGroup25(raw["server.vcs"]),
|
||||||
debug: adaptGroup26(raw["server.debug"]),
|
path: adaptGroup26(raw["server.path"]),
|
||||||
|
debug: adaptGroup27(raw["server.debug"]),
|
||||||
})
|
})
|
||||||
|
|
||||||
export const make = (options?: { readonly baseUrl?: URL | string }) =>
|
export const make = (options?: { readonly baseUrl?: URL | string }) =>
|
||||||
|
|||||||
@@ -3,13 +3,22 @@ type Client = ReturnType<typeof import("./generated/client.js").make>
|
|||||||
export type AgentApi = Client["agent"]
|
export type AgentApi = Client["agent"]
|
||||||
export type CommandApi = Client["command"]
|
export type CommandApi = Client["command"]
|
||||||
export type EventApi = Client["event"]
|
export type EventApi = Client["event"]
|
||||||
|
export type FileApi = Client["file"]
|
||||||
export type IntegrationApi = Client["integration"]
|
export type IntegrationApi = Client["integration"]
|
||||||
|
export type MessageApi = Client["message"]
|
||||||
|
export type McpApi = Client["mcp"]
|
||||||
export type ModelApi = Client["model"]
|
export type ModelApi = Client["model"]
|
||||||
export type PluginApi = Client["plugin"]
|
export type PluginApi = Client["plugin"]
|
||||||
|
export type PermissionApi = Client["permission"]
|
||||||
|
export type PathApi = Client["path"]
|
||||||
|
export type ProjectApi = Client["project"]
|
||||||
export type ProviderApi = Client["provider"]
|
export type ProviderApi = Client["provider"]
|
||||||
|
export type QuestionApi = Client["question"]
|
||||||
export type ReferenceApi = Client["reference"]
|
export type ReferenceApi = Client["reference"]
|
||||||
export type SessionApi = Client["session"]
|
export type SessionApi = Client["session"]
|
||||||
export type SkillApi = Client["skill"]
|
export type SkillApi = Client["skill"]
|
||||||
|
export type PtyApi = Client["pty"]
|
||||||
|
export type VcsApi = Client["vcs"]
|
||||||
|
|
||||||
export interface CatalogApi {
|
export interface CatalogApi {
|
||||||
readonly provider: ProviderApi
|
readonly provider: ProviderApi
|
||||||
|
|||||||
@@ -204,6 +204,8 @@ import type {
|
|||||||
VcsStatusOutput,
|
VcsStatusOutput,
|
||||||
VcsDiffInput,
|
VcsDiffInput,
|
||||||
VcsDiffOutput,
|
VcsDiffOutput,
|
||||||
|
PathGetInput,
|
||||||
|
PathGetOutput,
|
||||||
DebugLocationListOutput,
|
DebugLocationListOutput,
|
||||||
DebugLocationEvictInput,
|
DebugLocationEvictInput,
|
||||||
DebugLocationEvictOutput,
|
DebugLocationEvictOutput,
|
||||||
@@ -1708,6 +1710,20 @@ export function make(options: ClientOptions) {
|
|||||||
requestOptions,
|
requestOptions,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
path: {
|
||||||
|
get: (input?: PathGetInput, requestOptions?: RequestOptions) =>
|
||||||
|
request<PathGetOutput>(
|
||||||
|
{
|
||||||
|
method: "GET",
|
||||||
|
path: `/api/path`,
|
||||||
|
query: { location: input?.["location"] },
|
||||||
|
successStatus: 200,
|
||||||
|
declaredStatuses: [401, 400],
|
||||||
|
empty: false,
|
||||||
|
},
|
||||||
|
requestOptions,
|
||||||
|
),
|
||||||
|
},
|
||||||
debug: {
|
debug: {
|
||||||
location: {
|
location: {
|
||||||
list: (requestOptions?: RequestOptions) =>
|
list: (requestOptions?: RequestOptions) =>
|
||||||
|
|||||||
@@ -533,6 +533,8 @@ export type VcsFileStatus = {
|
|||||||
status: "added" | "deleted" | "modified"
|
status: "added" | "deleted" | "modified"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type PathInfo = { home: string; state: string; config: string; worktree: string; directory: string }
|
||||||
|
|
||||||
export type SessionMessageModelSelected = {
|
export type SessionMessageModelSelected = {
|
||||||
id: string
|
id: string
|
||||||
metadata?: { [x: string]: JsonValue }
|
metadata?: { [x: string]: JsonValue }
|
||||||
@@ -549,6 +551,7 @@ export type CommandInfo = {
|
|||||||
agent?: string
|
agent?: string
|
||||||
model?: ModelRef
|
model?: ModelRef
|
||||||
subtask?: boolean
|
subtask?: boolean
|
||||||
|
source?: "command" | "mcp"
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ProviderRequest = {
|
export type ProviderRequest = {
|
||||||
@@ -4952,6 +4955,14 @@ export type VcsDiffOutput = {
|
|||||||
data: Array<FileDiffInfo>
|
data: Array<FileDiffInfo>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type PathGetInput = {
|
||||||
|
readonly location?: {
|
||||||
|
readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
|
||||||
|
}["location"]
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PathGetOutput = PathInfo
|
||||||
|
|
||||||
export type DebugLocationListOutput = Array<LocationRef>
|
export type DebugLocationListOutput = Array<LocationRef>
|
||||||
|
|
||||||
export type DebugLocationEvictInput = {
|
export type DebugLocationEvictInput = {
|
||||||
|
|||||||
@@ -4,13 +4,22 @@ export type {
|
|||||||
CatalogApi,
|
CatalogApi,
|
||||||
CommandApi,
|
CommandApi,
|
||||||
EventApi,
|
EventApi,
|
||||||
|
FileApi,
|
||||||
IntegrationApi,
|
IntegrationApi,
|
||||||
|
MessageApi,
|
||||||
|
McpApi,
|
||||||
ModelApi,
|
ModelApi,
|
||||||
|
PermissionApi,
|
||||||
|
PathApi,
|
||||||
PluginApi,
|
PluginApi,
|
||||||
|
ProjectApi,
|
||||||
ProviderApi,
|
ProviderApi,
|
||||||
|
QuestionApi,
|
||||||
ReferenceApi,
|
ReferenceApi,
|
||||||
SessionApi,
|
SessionApi,
|
||||||
SkillApi,
|
SkillApi,
|
||||||
|
PtyApi,
|
||||||
|
VcsApi,
|
||||||
} from "./api.js"
|
} from "./api.js"
|
||||||
export type { EventSubscribeOutput as OpenCodeEvent } from "./generated/types"
|
export type { EventSubscribeOutput as OpenCodeEvent } from "./generated/types"
|
||||||
export type OpenCodeClient = ReturnType<typeof import("./generated/client").make>
|
export type OpenCodeClient = ReturnType<typeof import("./generated/client").make>
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ test("exposes every standard HTTP API group", () => {
|
|||||||
"reference",
|
"reference",
|
||||||
"projectCopy",
|
"projectCopy",
|
||||||
"vcs",
|
"vcs",
|
||||||
|
"path",
|
||||||
"debug",
|
"debug",
|
||||||
])
|
])
|
||||||
expect(Object.keys(client.debug)).toEqual(["location"])
|
expect(Object.keys(client.debug)).toEqual(["location"])
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ export const layer = (options?: ShellSelect.Options) => Layer.effect(
|
|||||||
name: mcpCommandName(prompt.server, prompt.name),
|
name: mcpCommandName(prompt.server, prompt.name),
|
||||||
template: "",
|
template: "",
|
||||||
description: prompt.description,
|
description: prompt.description,
|
||||||
|
source: "mcp",
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -98,7 +99,10 @@ export const layer = (options?: ShellSelect.Options) => Layer.effect(
|
|||||||
return (yield* mcpCommands()).find((command) => command.name === name)
|
return (yield* mcpCommands()).find((command) => command.name === name)
|
||||||
}),
|
}),
|
||||||
list: Effect.fn("CommandV2.list")(function* () {
|
list: Effect.fn("CommandV2.list")(function* () {
|
||||||
const commands = Array.from(state.get().commands.values()) as Info[]
|
const commands = Array.from(state.get().commands.values()).map((command) => ({
|
||||||
|
...command,
|
||||||
|
source: command.source ?? "command" as const,
|
||||||
|
}))
|
||||||
const names = new Set(commands.map((command) => command.name))
|
const names = new Set(commands.map((command) => command.name))
|
||||||
return [
|
return [
|
||||||
...commands,
|
...commands,
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ describe("CommandV2", () => {
|
|||||||
providerID: ProviderV2.ID.make("anthropic"),
|
providerID: ProviderV2.ID.make("anthropic"),
|
||||||
variant: ModelV2.VariantID.make("high"),
|
variant: ModelV2.VariantID.make("high"),
|
||||||
},
|
},
|
||||||
|
source: "command",
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -95,9 +95,10 @@ Review files`,
|
|||||||
variant: ModelV2.VariantID.make("high"),
|
variant: ModelV2.VariantID.make("high"),
|
||||||
},
|
},
|
||||||
subtask: true,
|
subtask: true,
|
||||||
|
source: "command",
|
||||||
}),
|
}),
|
||||||
CommandV2.Info.make({ name: "empty", template: "" }),
|
CommandV2.Info.make({ name: "empty", template: "", source: "command" }),
|
||||||
CommandV2.Info.make({ name: "nested/docs", template: "Write docs" }),
|
CommandV2.Info.make({ name: "nested/docs", template: "Write docs", source: "command" }),
|
||||||
])
|
])
|
||||||
|
|
||||||
yield* Effect.promise(() => fs.writeFile(path.join(tmp.path, "commands", "review.md"), "Review again"))
|
yield* Effect.promise(() => fs.writeFile(path.join(tmp.path, "commands", "review.md"), "Review again"))
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import { CredentialGroup } from "./groups/credential.js"
|
|||||||
import { ProjectGroup } from "./groups/project.js"
|
import { ProjectGroup } from "./groups/project.js"
|
||||||
import { ProjectCopyGroup } from "./groups/project-copy.js"
|
import { ProjectCopyGroup } from "./groups/project-copy.js"
|
||||||
import { VcsGroup } from "./groups/vcs.js"
|
import { VcsGroup } from "./groups/vcs.js"
|
||||||
|
import { PathGroup } from "./groups/path.js"
|
||||||
|
|
||||||
type LocationGroups<LocationId extends HttpApiMiddleware.AnyId> =
|
type LocationGroups<LocationId extends HttpApiMiddleware.AnyId> =
|
||||||
| HttpApiGroup.AddMiddleware<typeof LocationGroup, LocationId>
|
| HttpApiGroup.AddMiddleware<typeof LocationGroup, LocationId>
|
||||||
@@ -50,6 +51,7 @@ type LocationGroups<LocationId extends HttpApiMiddleware.AnyId> =
|
|||||||
| HttpApiGroup.AddMiddleware<typeof ReferenceGroup, LocationId>
|
| HttpApiGroup.AddMiddleware<typeof ReferenceGroup, LocationId>
|
||||||
| HttpApiGroup.AddMiddleware<typeof ProjectCopyGroup, LocationId>
|
| HttpApiGroup.AddMiddleware<typeof ProjectCopyGroup, LocationId>
|
||||||
| HttpApiGroup.AddMiddleware<typeof VcsGroup, LocationId>
|
| HttpApiGroup.AddMiddleware<typeof VcsGroup, LocationId>
|
||||||
|
| HttpApiGroup.AddMiddleware<typeof PathGroup, LocationId>
|
||||||
|
|
||||||
type SessionGroups<SessionLocationId extends HttpApiMiddleware.AnyId, SessionLocationService> =
|
type SessionGroups<SessionLocationId extends HttpApiMiddleware.AnyId, SessionLocationService> =
|
||||||
| ReturnType<typeof makeSessionGroup<SessionLocationId, SessionLocationService>>
|
| ReturnType<typeof makeSessionGroup<SessionLocationId, SessionLocationService>>
|
||||||
@@ -168,6 +170,7 @@ const makeApiFromGroup = <
|
|||||||
.add(ReferenceGroup.middleware(locationMiddleware))
|
.add(ReferenceGroup.middleware(locationMiddleware))
|
||||||
.add(ProjectCopyGroup.middleware(locationMiddleware))
|
.add(ProjectCopyGroup.middleware(locationMiddleware))
|
||||||
.add(VcsGroup.middleware(locationMiddleware))
|
.add(VcsGroup.middleware(locationMiddleware))
|
||||||
|
.add(PathGroup.middleware(locationMiddleware))
|
||||||
.add(DebugGroup)
|
.add(DebugGroup)
|
||||||
.annotateMerge(
|
.annotateMerge(
|
||||||
OpenApi.annotations({
|
OpenApi.annotations({
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ export const groupNames = {
|
|||||||
"server.project": "project",
|
"server.project": "project",
|
||||||
"server.projectCopy": "projectCopy",
|
"server.projectCopy": "projectCopy",
|
||||||
"server.vcs": "vcs",
|
"server.vcs": "vcs",
|
||||||
|
"server.path": "path",
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
export const promiseOmitEndpoints = new Set(["pty.connect", "pty.connectToken"])
|
export const promiseOmitEndpoints = new Set(["pty.connect", "pty.connectToken"])
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { Path } from "@opencode-ai/schema/path"
|
||||||
|
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi"
|
||||||
|
import { LocationQuery, locationQueryOpenApi } from "./location.js"
|
||||||
|
|
||||||
|
export const PathGroup = HttpApiGroup.make("server.path")
|
||||||
|
.add(
|
||||||
|
HttpApiEndpoint.get("path.get", "/api/path", {
|
||||||
|
query: LocationQuery,
|
||||||
|
success: Path.Info,
|
||||||
|
})
|
||||||
|
.annotateMerge(locationQueryOpenApi)
|
||||||
|
.annotateMerge(
|
||||||
|
OpenApi.annotations({
|
||||||
|
identifier: "v2.path.get",
|
||||||
|
summary: "Get paths",
|
||||||
|
description: "Get process and location paths.",
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.annotateMerge(OpenApi.annotations({ title: "path", description: "Location and process paths." }))
|
||||||
@@ -16,6 +16,7 @@ export const Info = Schema.Struct({
|
|||||||
agent: Agent.ID.pipe(optional),
|
agent: Agent.ID.pipe(optional),
|
||||||
model: Model.Ref.pipe(optional),
|
model: Model.Ref.pipe(optional),
|
||||||
subtask: Schema.Boolean.pipe(optional),
|
subtask: Schema.Boolean.pipe(optional),
|
||||||
|
source: Schema.Literals(["command", "mcp"]).pipe(optional),
|
||||||
}).annotate({ identifier: "Command.Info" })
|
}).annotate({ identifier: "Command.Info" })
|
||||||
|
|
||||||
export const Event = {
|
export const Event = {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ export { Model } from "./model.js"
|
|||||||
export { Money } from "./money.js"
|
export { Money } from "./money.js"
|
||||||
export { Permission } from "./permission.js"
|
export { Permission } from "./permission.js"
|
||||||
export { PermissionSaved } from "./permission-saved.js"
|
export { PermissionSaved } from "./permission-saved.js"
|
||||||
|
export { Path } from "./path.js"
|
||||||
export { Project } from "./project.js"
|
export { Project } from "./project.js"
|
||||||
export { ProjectCopy } from "./project-copy.js"
|
export { ProjectCopy } from "./project-copy.js"
|
||||||
export { Provider } from "./provider.js"
|
export { Provider } from "./provider.js"
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
export * as Path from "./path.js"
|
||||||
|
|
||||||
|
import { Schema } from "effect"
|
||||||
|
import { AbsolutePath } from "./schema.js"
|
||||||
|
|
||||||
|
export const Info = Schema.Struct({
|
||||||
|
home: AbsolutePath,
|
||||||
|
state: AbsolutePath,
|
||||||
|
config: AbsolutePath,
|
||||||
|
worktree: AbsolutePath,
|
||||||
|
directory: AbsolutePath,
|
||||||
|
}).annotate({ identifier: "Path.Info" })
|
||||||
|
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
||||||
@@ -26,6 +26,7 @@ import { CredentialHandler } from "./handlers/credential"
|
|||||||
import { ProjectHandler } from "./handlers/project"
|
import { ProjectHandler } from "./handlers/project"
|
||||||
import { ProjectCopyHandler } from "./handlers/project-copy"
|
import { ProjectCopyHandler } from "./handlers/project-copy"
|
||||||
import { VcsHandler } from "./handlers/vcs"
|
import { VcsHandler } from "./handlers/vcs"
|
||||||
|
import { PathHandler } from "./handlers/path"
|
||||||
import { EventFeed } from "./event-feed"
|
import { EventFeed } from "./event-feed"
|
||||||
|
|
||||||
export const handlers = Layer.mergeAll(
|
export const handlers = Layer.mergeAll(
|
||||||
@@ -56,4 +57,5 @@ export const handlers = Layer.mergeAll(
|
|||||||
ReferenceHandler,
|
ReferenceHandler,
|
||||||
ProjectCopyHandler,
|
ProjectCopyHandler,
|
||||||
VcsHandler,
|
VcsHandler,
|
||||||
|
PathHandler,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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,
|
WellKnown.node,
|
||||||
PtyEnvironment.node,
|
PtyEnvironment.node,
|
||||||
LocationServiceMap.node,
|
LocationServiceMap.node,
|
||||||
|
Global.node,
|
||||||
SessionRestart.node,
|
SessionRestart.node,
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -134,7 +135,9 @@ function makeRoutes<AuthError, AuthServices>(
|
|||||||
Layer.flatMap((context) => {
|
Layer.flatMap((context) => {
|
||||||
const services = Layer.succeedContext(context)
|
const services = Layer.succeedContext(context)
|
||||||
const requestServices = Layer.merge(
|
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),
|
ServerInfo.layer(serviceURLs, options.app),
|
||||||
)
|
)
|
||||||
return HttpApiBuilder.layer(Api, { openapiPath: "/openapi.json" }).pipe(
|
return HttpApiBuilder.layer(Api, { openapiPath: "/openapi.json" }).pipe(
|
||||||
|
|||||||
Reference in New Issue
Block a user