feat(core): rework workspace integration and adaptor interface (#15895)

This commit is contained in:
James Long
2026-03-03 21:35:38 -05:00
committed by GitHub
parent e79d41c70e
commit 7f37acdaaa
23 changed files with 1720 additions and 580 deletions

View File

@@ -88,6 +88,7 @@ export const ExperimentalRoutes = lazy(() =>
)
},
)
.route("/workspace", WorkspaceRoutes())
.post(
"/worktree",
describeRoute({
@@ -113,7 +114,6 @@ export const ExperimentalRoutes = lazy(() =>
return c.json(worktree)
},
)
.route("/workspace", WorkspaceRoutes())
.get(
"/worktree",
describeRoute({

View File

@@ -16,13 +16,11 @@ import { Log } from "../../util/log"
import { PermissionNext } from "@/permission/next"
import { errors } from "../error"
import { lazy } from "../../util/lazy"
import { SessionProxyMiddleware } from "../../control-plane/session-proxy-middleware"
const log = Log.create({ service: "server" })
export const SessionRoutes = lazy(() =>
new Hono()
.use(SessionProxyMiddleware)
.get(
"/",
describeRoute({

View File

@@ -9,7 +9,7 @@ import { lazy } from "../../util/lazy"
export const WorkspaceRoutes = lazy(() =>
new Hono()
.post(
"/:id",
"/",
describeRoute({
summary: "Create workspace",
description: "Create a workspace for the current project.",
@@ -26,27 +26,17 @@ export const WorkspaceRoutes = lazy(() =>
...errors(400),
},
}),
validator(
"param",
z.object({
id: Workspace.Info.shape.id,
}),
),
validator(
"json",
z.object({
branch: Workspace.Info.shape.branch,
config: Workspace.Info.shape.config,
Workspace.create.schema.omit({
projectID: true,
}),
),
async (c) => {
const { id } = c.req.valid("param")
const body = c.req.valid("json")
const workspace = await Workspace.create({
id,
projectID: Instance.project.id,
branch: body.branch,
config: body.config,
...body,
})
return c.json(workspace)
},

View File

@@ -22,6 +22,7 @@ import { Flag } from "../flag/flag"
import { Command } from "../command"
import { Global } from "../global"
import { WorkspaceContext } from "../control-plane/workspace-context"
import { WorkspaceRouterMiddleware } from "../control-plane/workspace-router-middleware"
import { ProjectRoutes } from "./routes/project"
import { SessionRoutes } from "./routes/session"
import { PtyRoutes } from "./routes/pty"
@@ -218,6 +219,7 @@ export namespace Server {
},
})
})
.use(WorkspaceRouterMiddleware)
.get(
"/doc",
openAPIRouteHandler(app, {