feat(api): add experimental wellknown connections
This commit is contained in:
parent
6bf92aa7de
commit
5fb0470b44
33 changed files with 1070 additions and 138 deletions
|
|
@ -4,6 +4,7 @@ import { HttpApiBuilder, HttpApiSchema } from "effect/unstable/httpapi"
|
|||
import { Api } from "../api"
|
||||
import { InvalidRequestError } from "@opencode-ai/protocol/errors"
|
||||
import { response } from "../location"
|
||||
import { WellKnown } from "@opencode-ai/core/wellknown"
|
||||
|
||||
const authorize = <A, R>(effect: Effect.Effect<A, Integration.AuthorizationError, R>) =>
|
||||
effect.pipe(
|
||||
|
|
@ -33,6 +34,22 @@ export const IntegrationHandler = HttpApiBuilder.group(Api, "server.integration"
|
|||
return yield* response(service.get(ctx.params.integrationID))
|
||||
}),
|
||||
)
|
||||
.handle(
|
||||
"integration.wellknown.add",
|
||||
Effect.fn(function* (ctx) {
|
||||
const wellknown = yield* WellKnown.Service
|
||||
const integration = yield* Integration.Service
|
||||
yield* wellknown
|
||||
.add(ctx.payload.url)
|
||||
.pipe(
|
||||
Effect.mapError(
|
||||
(error) => new InvalidRequestError({ message: error.message, kind: "well_known_discovery" }),
|
||||
),
|
||||
)
|
||||
yield* integration.reload()
|
||||
return HttpApiSchema.NoContent.make()
|
||||
}),
|
||||
)
|
||||
.handle(
|
||||
"integration.connect.key",
|
||||
Effect.fn(function* (ctx) {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import { SessionRestart } from "@opencode-ai/core/session/execution/restart"
|
|||
import { PluginRuntime } from "@opencode-ai/core/plugin/runtime"
|
||||
import { SdkPlugins } from "@opencode-ai/core/plugin/sdk"
|
||||
import { ToolOutputStore } from "@opencode-ai/core/tool-output-store"
|
||||
import { WellKnown } from "@opencode-ai/core/wellknown"
|
||||
import { HttpRouter, HttpServer } from "effect/unstable/http"
|
||||
import { HttpApiBuilder } from "effect/unstable/httpapi"
|
||||
import { Context, Effect, Layer, Option } from "effect"
|
||||
|
|
@ -44,6 +45,7 @@ const applicationServices = LayerNode.group([
|
|||
PermissionSaved.node,
|
||||
PtyTicket.node,
|
||||
Credential.node,
|
||||
WellKnown.node,
|
||||
PtyEnvironment.node,
|
||||
LocationServiceMap.node,
|
||||
SessionRestart.node,
|
||||
|
|
@ -85,7 +87,7 @@ function makeRoutes<AuthError, AuthServices>(
|
|||
Layer.flatMap((context) => {
|
||||
const services = Layer.succeedContext(context)
|
||||
const requestServices = Layer.merge(
|
||||
Layer.succeedContext(Context.pick(PermissionSaved.Service, Project.Service)(context)),
|
||||
Layer.succeedContext(Context.pick(PermissionSaved.Service, Project.Service, WellKnown.Service)(context)),
|
||||
ServerInfo.layer(serviceURLs),
|
||||
)
|
||||
return HttpApiBuilder.layer(Api, { openapiPath: "/openapi.json" }).pipe(
|
||||
|
|
@ -109,5 +111,4 @@ function simulateEnabled() {
|
|||
return !!process.env.OPENCODE_SIMULATE
|
||||
}
|
||||
|
||||
export const webHandler = () =>
|
||||
HttpRouter.toWebHandler(createRoutes().pipe(Layer.provide(HttpServer.layerServices)))
|
||||
export const webHandler = () => HttpRouter.toWebHandler(createRoutes().pipe(Layer.provide(HttpServer.layerServices)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue