diff --git a/packages/opencode/src/control-plane/workspace-context.ts b/packages/opencode/src/control-plane/workspace-context.ts index 3d4fa5baeff0..85ef596e7a8c 100644 --- a/packages/opencode/src/control-plane/workspace-context.ts +++ b/packages/opencode/src/control-plane/workspace-context.ts @@ -2,13 +2,13 @@ import { LocalContext } from "../util" import type { WorkspaceID } from "../control-plane/schema" export interface WorkspaceContext { - workspaceID: WorkspaceID + workspaceID: WorkspaceID | undefined } const context = LocalContext.create("instance") export const WorkspaceContext = { - async provide(input: { workspaceID: WorkspaceID; fn: () => R }): Promise { + async provide(input: { workspaceID?: WorkspaceID; fn: () => R }): Promise { return context.provide({ workspaceID: input.workspaceID }, () => input.fn()) }, diff --git a/packages/opencode/src/server/control/index.ts b/packages/opencode/src/server/routes/control/index.ts similarity index 96% rename from packages/opencode/src/server/control/index.ts rename to packages/opencode/src/server/routes/control/index.ts index 737f958d6b75..3fd60636fffd 100644 --- a/packages/opencode/src/server/control/index.ts +++ b/packages/opencode/src/server/routes/control/index.ts @@ -6,13 +6,12 @@ import { ProviderID } from "@/provider/schema" import { Hono } from "hono" import { describeRoute, resolver, validator, openAPIRouteHandler } from "hono-openapi" import z from "zod" -import { errors } from "../error" -import { GlobalRoutes } from "../instance/global" +import { errors } from "../../error" +import { WorkspaceRoutes } from "./workspace" export function ControlPlaneRoutes(): Hono { const app = new Hono() return app - .route("/global", GlobalRoutes()) .put( "/auth/:providerID", describeRoute({ @@ -159,4 +158,5 @@ export function ControlPlaneRoutes(): Hono { return c.json(true) }, ) + .route("/experimental/workspace", WorkspaceRoutes()) } diff --git a/packages/opencode/src/server/instance/workspace.ts b/packages/opencode/src/server/routes/control/workspace.ts similarity index 95% rename from packages/opencode/src/server/instance/workspace.ts rename to packages/opencode/src/server/routes/control/workspace.ts index 59369ef8e76d..9ff747b68a59 100644 --- a/packages/opencode/src/server/instance/workspace.ts +++ b/packages/opencode/src/server/routes/control/workspace.ts @@ -1,11 +1,11 @@ import { Hono } from "hono" import { describeRoute, resolver, validator } from "hono-openapi" import z from "zod" -import { listAdaptors } from "../../control-plane/adaptors" -import { Workspace } from "../../control-plane/workspace" -import { Instance } from "../../project/instance" -import { errors } from "../error" -import { lazy } from "../../util/lazy" +import { listAdaptors } from "@/control-plane/adaptors" +import { Workspace } from "@/control-plane/workspace" +import { Instance } from "@/project/instance" +import { errors } from "../../error" +import { lazy } from "@/util/lazy" import { Log } from "@/util" import { errorData } from "@/util/error" diff --git a/packages/opencode/src/server/instance/global.ts b/packages/opencode/src/server/routes/global.ts similarity index 100% rename from packages/opencode/src/server/instance/global.ts rename to packages/opencode/src/server/routes/global.ts diff --git a/packages/opencode/src/server/instance/config.ts b/packages/opencode/src/server/routes/instance/config.ts similarity index 92% rename from packages/opencode/src/server/instance/config.ts rename to packages/opencode/src/server/routes/instance/config.ts index 15c393fe5a0a..235f5682e229 100644 --- a/packages/opencode/src/server/instance/config.ts +++ b/packages/opencode/src/server/routes/instance/config.ts @@ -1,11 +1,11 @@ import { Hono } from "hono" import { describeRoute, validator, resolver } from "hono-openapi" import z from "zod" -import { Config } from "../../config" -import { Provider } from "../../provider" -import { errors } from "../error" -import { lazy } from "../../util/lazy" -import { AppRuntime } from "../../effect/app-runtime" +import { Config } from "@/config" +import { Provider } from "@/provider" +import { errors } from "../../error" +import { lazy } from "@/util/lazy" +import { AppRuntime } from "@/effect/app-runtime" import { jsonRequest } from "./trace" export const ConfigRoutes = lazy(() => diff --git a/packages/opencode/src/server/instance/event.ts b/packages/opencode/src/server/routes/instance/event.ts similarity index 97% rename from packages/opencode/src/server/instance/event.ts rename to packages/opencode/src/server/routes/instance/event.ts index 103d3d7cfbc6..1d883bd88314 100644 --- a/packages/opencode/src/server/instance/event.ts +++ b/packages/opencode/src/server/routes/instance/event.ts @@ -5,7 +5,7 @@ import { streamSSE } from "hono/streaming" import { Log } from "@/util" import { BusEvent } from "@/bus/bus-event" import { Bus } from "@/bus" -import { AsyncQueue } from "../../util/queue" +import { AsyncQueue } from "@/util/queue" const log = Log.create({ service: "server" }) diff --git a/packages/opencode/src/server/instance/experimental.ts b/packages/opencode/src/server/routes/instance/experimental.ts similarity index 94% rename from packages/opencode/src/server/instance/experimental.ts rename to packages/opencode/src/server/routes/instance/experimental.ts index 6fe99a8c3b0a..f7ecc8255ba0 100644 --- a/packages/opencode/src/server/instance/experimental.ts +++ b/packages/opencode/src/server/routes/instance/experimental.ts @@ -1,22 +1,21 @@ import { Hono } from "hono" import { describeRoute, validator, resolver } from "hono-openapi" import z from "zod" -import { ProviderID, ModelID } from "../../provider/schema" -import { ToolRegistry } from "../../tool" -import { Worktree } from "../../worktree" -import { Instance } from "../../project/instance" -import { Project } from "../../project" -import { MCP } from "../../mcp" -import { Session } from "../../session" -import { Config } from "../../config" -import { ConsoleState } from "../../config/console-state" -import { Account } from "../../account/account" -import { AccountID, OrgID } from "../../account/schema" -import { AppRuntime } from "../../effect/app-runtime" -import { errors } from "../error" -import { lazy } from "../../util/lazy" +import { ProviderID, ModelID } from "@/provider/schema" +import { ToolRegistry } from "@/tool" +import { Worktree } from "@/worktree" +import { Instance } from "@/project/instance" +import { Project } from "@/project" +import { MCP } from "@/mcp" +import { Session } from "@/session" +import { Config } from "@/config" +import { ConsoleState } from "@/config/console-state" +import { Account } from "@/account/account" +import { AccountID, OrgID } from "@/account/schema" +import { AppRuntime } from "@/effect/app-runtime" +import { errors } from "../../error" +import { lazy } from "@/util/lazy" import { Effect, Option } from "effect" -import { WorkspaceRoutes } from "./workspace" import { Agent } from "@/agent/agent" const ConsoleOrgOption = z.object({ @@ -231,7 +230,6 @@ export const ExperimentalRoutes = lazy(() => ) }, ) - .route("/workspace", WorkspaceRoutes()) .post( "/worktree", describeRoute({ diff --git a/packages/opencode/src/server/instance/file.ts b/packages/opencode/src/server/routes/instance/file.ts similarity index 95% rename from packages/opencode/src/server/instance/file.ts rename to packages/opencode/src/server/routes/instance/file.ts index db5e227770f8..a82e5687d836 100644 --- a/packages/opencode/src/server/instance/file.ts +++ b/packages/opencode/src/server/routes/instance/file.ts @@ -2,12 +2,12 @@ import { Hono } from "hono" import { describeRoute, validator, resolver } from "hono-openapi" import { Effect } from "effect" import z from "zod" -import { AppRuntime } from "../../effect/app-runtime" -import { File } from "../../file" -import { Ripgrep } from "../../file/ripgrep" -import { LSP } from "../../lsp" -import { Instance } from "../../project/instance" -import { lazy } from "../../util/lazy" +import { AppRuntime } from "@/effect/app-runtime" +import { File } from "@/file" +import { Ripgrep } from "@/file/ripgrep" +import { LSP } from "@/lsp" +import { Instance } from "@/project/instance" +import { lazy } from "@/util/lazy" export const FileRoutes = lazy(() => new Hono() diff --git a/packages/opencode/src/server/instance/httpapi/config.ts b/packages/opencode/src/server/routes/instance/httpapi/config.ts similarity index 100% rename from packages/opencode/src/server/instance/httpapi/config.ts rename to packages/opencode/src/server/routes/instance/httpapi/config.ts diff --git a/packages/opencode/src/server/instance/httpapi/permission.ts b/packages/opencode/src/server/routes/instance/httpapi/permission.ts similarity index 100% rename from packages/opencode/src/server/instance/httpapi/permission.ts rename to packages/opencode/src/server/routes/instance/httpapi/permission.ts diff --git a/packages/opencode/src/server/instance/httpapi/project.ts b/packages/opencode/src/server/routes/instance/httpapi/project.ts similarity index 100% rename from packages/opencode/src/server/instance/httpapi/project.ts rename to packages/opencode/src/server/routes/instance/httpapi/project.ts diff --git a/packages/opencode/src/server/instance/httpapi/provider.ts b/packages/opencode/src/server/routes/instance/httpapi/provider.ts similarity index 100% rename from packages/opencode/src/server/instance/httpapi/provider.ts rename to packages/opencode/src/server/routes/instance/httpapi/provider.ts diff --git a/packages/opencode/src/server/instance/httpapi/question.ts b/packages/opencode/src/server/routes/instance/httpapi/question.ts similarity index 100% rename from packages/opencode/src/server/instance/httpapi/question.ts rename to packages/opencode/src/server/routes/instance/httpapi/question.ts diff --git a/packages/opencode/src/server/instance/httpapi/server.ts b/packages/opencode/src/server/routes/instance/httpapi/server.ts similarity index 100% rename from packages/opencode/src/server/instance/httpapi/server.ts rename to packages/opencode/src/server/routes/instance/httpapi/server.ts diff --git a/packages/opencode/src/server/instance/index.ts b/packages/opencode/src/server/routes/instance/index.ts similarity index 95% rename from packages/opencode/src/server/instance/index.ts rename to packages/opencode/src/server/routes/instance/index.ts index cfcaffc59693..017541b8fc91 100644 --- a/packages/opencode/src/server/instance/index.ts +++ b/packages/opencode/src/server/routes/instance/index.ts @@ -3,15 +3,15 @@ import { Hono } from "hono" import type { UpgradeWebSocket } from "hono/ws" import { Context, Effect } from "effect" import z from "zod" -import { Format } from "../../format" +import { Format } from "@/format" import { TuiRoutes } from "./tui" -import { Instance } from "../../project/instance" -import { Vcs } from "../../project" -import { Agent } from "../../agent/agent" -import { Skill } from "../../skill" -import { Global } from "../../global" -import { LSP } from "../../lsp" -import { Command } from "../../command" +import { Instance } from "@/project/instance" +import { Vcs } from "@/project" +import { Agent } from "@/agent/agent" +import { Skill } from "@/skill" +import { Global } from "@/global" +import { LSP } from "@/lsp" +import { Command } from "@/command" import { QuestionRoutes } from "./question" import { PermissionRoutes } from "./permission" import { Flag } from "@/flag/flag" @@ -26,11 +26,10 @@ import { ExperimentalRoutes } from "./experimental" import { ProviderRoutes } from "./provider" import { EventRoutes } from "./event" import { SyncRoutes } from "./sync" -import { WorkspaceRouterMiddleware } from "./middleware" import { AppRuntime } from "@/effect/app-runtime" export const InstanceRoutes = (upgrade: UpgradeWebSocket): Hono => { - const app = new Hono().use(WorkspaceRouterMiddleware(upgrade)) + const app = new Hono() if (Flag.OPENCODE_EXPERIMENTAL_HTTPAPI) { const handler = ExperimentalHttpApiServer.webHandler().handler diff --git a/packages/opencode/src/server/instance/mcp.ts b/packages/opencode/src/server/routes/instance/mcp.ts similarity index 96% rename from packages/opencode/src/server/instance/mcp.ts rename to packages/opencode/src/server/routes/instance/mcp.ts index f6e6f1eddb09..197185bde008 100644 --- a/packages/opencode/src/server/instance/mcp.ts +++ b/packages/opencode/src/server/routes/instance/mcp.ts @@ -1,12 +1,12 @@ import { Hono } from "hono" import { describeRoute, validator, resolver } from "hono-openapi" import z from "zod" -import { MCP } from "../../mcp" -import { Config } from "../../config" -import { ConfigMCP } from "../../config/mcp" -import { AppRuntime } from "../../effect/app-runtime" -import { errors } from "../error" -import { lazy } from "../../util/lazy" +import { MCP } from "@/mcp" +import { Config } from "@/config" +import { ConfigMCP } from "@/config/mcp" +import { AppRuntime } from "@/effect/app-runtime" +import { errors } from "../../error" +import { lazy } from "@/util/lazy" import { Effect } from "effect" export const McpRoutes = lazy(() => diff --git a/packages/opencode/src/server/instance/permission.ts b/packages/opencode/src/server/routes/instance/permission.ts similarity index 96% rename from packages/opencode/src/server/instance/permission.ts rename to packages/opencode/src/server/routes/instance/permission.ts index b8c22441405f..c3f9c8201104 100644 --- a/packages/opencode/src/server/instance/permission.ts +++ b/packages/opencode/src/server/routes/instance/permission.ts @@ -4,8 +4,8 @@ import z from "zod" import { AppRuntime } from "@/effect/app-runtime" import { Permission } from "@/permission" import { PermissionID } from "@/permission/schema" -import { errors } from "../error" -import { lazy } from "../../util/lazy" +import { errors } from "../../error" +import { lazy } from "@/util/lazy" export const PermissionRoutes = lazy(() => new Hono() diff --git a/packages/opencode/src/server/instance/project.ts b/packages/opencode/src/server/routes/instance/project.ts similarity index 92% rename from packages/opencode/src/server/instance/project.ts rename to packages/opencode/src/server/routes/instance/project.ts index 95b5862fd571..060542c4b440 100644 --- a/packages/opencode/src/server/instance/project.ts +++ b/packages/opencode/src/server/routes/instance/project.ts @@ -1,13 +1,13 @@ import { Hono } from "hono" import { describeRoute, validator } from "hono-openapi" import { resolver } from "hono-openapi" -import { Instance } from "../../project/instance" -import { Project } from "../../project" +import { Instance } from "@/project/instance" +import { Project } from "@/project" import z from "zod" -import { ProjectID } from "../../project/schema" -import { errors } from "../error" -import { lazy } from "../../util/lazy" -import { InstanceBootstrap } from "../../project/bootstrap" +import { ProjectID } from "@/project/schema" +import { errors } from "../../error" +import { lazy } from "@/util/lazy" +import { InstanceBootstrap } from "@/project/bootstrap" import { AppRuntime } from "@/effect/app-runtime" export const ProjectRoutes = lazy(() => diff --git a/packages/opencode/src/server/instance/provider.ts b/packages/opencode/src/server/routes/instance/provider.ts similarity index 93% rename from packages/opencode/src/server/instance/provider.ts rename to packages/opencode/src/server/routes/instance/provider.ts index a81ae00d5908..57aa895e3d26 100644 --- a/packages/opencode/src/server/instance/provider.ts +++ b/packages/opencode/src/server/routes/instance/provider.ts @@ -1,15 +1,15 @@ import { Hono } from "hono" import { describeRoute, validator, resolver } from "hono-openapi" import z from "zod" -import { Config } from "../../config" -import { Provider } from "../../provider" -import { ModelsDev } from "../../provider" -import { ProviderAuth } from "../../provider" -import { ProviderID } from "../../provider/schema" -import { AppRuntime } from "../../effect/app-runtime" +import { Config } from "@/config" +import { Provider } from "@/provider" +import { ModelsDev } from "@/provider" +import { ProviderAuth } from "@/provider" +import { ProviderID } from "@/provider/schema" +import { AppRuntime } from "@/effect/app-runtime" import { mapValues } from "remeda" -import { errors } from "../error" -import { lazy } from "../../util/lazy" +import { errors } from "../../error" +import { lazy } from "@/util/lazy" import { Effect } from "effect" export const ProviderRoutes = lazy(() => diff --git a/packages/opencode/src/server/instance/pty.ts b/packages/opencode/src/server/routes/instance/pty.ts similarity index 98% rename from packages/opencode/src/server/instance/pty.ts rename to packages/opencode/src/server/routes/instance/pty.ts index 79437251209d..b3f71c235c5e 100644 --- a/packages/opencode/src/server/instance/pty.ts +++ b/packages/opencode/src/server/routes/instance/pty.ts @@ -6,8 +6,8 @@ import z from "zod" import { AppRuntime } from "@/effect/app-runtime" import { Pty } from "@/pty" import { PtyID } from "@/pty/schema" -import { NotFoundError } from "../../storage" -import { errors } from "../error" +import { NotFoundError } from "@/storage" +import { errors } from "../../error" export function PtyRoutes(upgradeWebSocket: UpgradeWebSocket) { return new Hono() diff --git a/packages/opencode/src/server/instance/question.ts b/packages/opencode/src/server/routes/instance/question.ts similarity index 96% rename from packages/opencode/src/server/instance/question.ts rename to packages/opencode/src/server/routes/instance/question.ts index 0f61a186728f..9b8f461e39c6 100644 --- a/packages/opencode/src/server/instance/question.ts +++ b/packages/opencode/src/server/routes/instance/question.ts @@ -2,11 +2,11 @@ import { Hono } from "hono" import { describeRoute, validator } from "hono-openapi" import { resolver } from "hono-openapi" import { QuestionID } from "@/question/schema" -import { Question } from "../../question" +import { Question } from "@/question" import { AppRuntime } from "@/effect/app-runtime" import z from "zod" -import { errors } from "../error" -import { lazy } from "../../util/lazy" +import { errors } from "../../error" +import { lazy } from "@/util/lazy" const Reply = z.object({ answers: Question.Answer.zod diff --git a/packages/opencode/src/server/instance/session.ts b/packages/opencode/src/server/routes/instance/session.ts similarity index 98% rename from packages/opencode/src/server/instance/session.ts rename to packages/opencode/src/server/routes/instance/session.ts index 1511e99e8d01..ae6185abb822 100644 --- a/packages/opencode/src/server/instance/session.ts +++ b/packages/opencode/src/server/routes/instance/session.ts @@ -3,28 +3,28 @@ import { stream } from "hono/streaming" import { describeRoute, validator, resolver } from "hono-openapi" import { SessionID, MessageID, PartID } from "@/session/schema" import z from "zod" -import { Session } from "../../session" -import { MessageV2 } from "../../session/message-v2" -import { SessionPrompt } from "../../session/prompt" +import { Session } from "@/session" +import { MessageV2 } from "@/session/message-v2" +import { SessionPrompt } from "@/session/prompt" import { SessionRunState } from "@/session/run-state" -import { SessionCompaction } from "../../session/compaction" -import { SessionRevert } from "../../session/revert" +import { SessionCompaction } from "@/session/compaction" +import { SessionRevert } from "@/session/revert" import { SessionShare } from "@/share" import { SessionStatus } from "@/session/status" import { SessionSummary } from "@/session/summary" -import { Todo } from "../../session/todo" +import { Todo } from "@/session/todo" import { Effect } from "effect" -import { AppRuntime } from "../../effect/app-runtime" -import { Agent } from "../../agent/agent" +import { AppRuntime } from "@/effect/app-runtime" +import { Agent } from "@/agent/agent" import { Snapshot } from "@/snapshot" -import { Command } from "../../command" -import { Log } from "../../util" +import { Command } from "@/command" +import { Log } from "@/util" import { Permission } from "@/permission" import { PermissionID } from "@/permission/schema" import { ModelID, ProviderID } from "@/provider/schema" -import { errors } from "../error" -import { lazy } from "../../util/lazy" -import { Bus } from "../../bus" +import { errors } from "../../error" +import { lazy } from "@/util/lazy" +import { Bus } from "@/bus" import { NamedError } from "@opencode-ai/shared/util/error" import { jsonRequest } from "./trace" diff --git a/packages/opencode/src/server/instance/sync.ts b/packages/opencode/src/server/routes/instance/sync.ts similarity index 98% rename from packages/opencode/src/server/instance/sync.ts rename to packages/opencode/src/server/routes/instance/sync.ts index ac43b638eb2e..c6a067997b0d 100644 --- a/packages/opencode/src/server/instance/sync.ts +++ b/packages/opencode/src/server/routes/instance/sync.ts @@ -6,7 +6,7 @@ import { Database, asc, and, not, or, lte, eq } from "@/storage" import { EventTable } from "@/sync/event.sql" import { lazy } from "@/util/lazy" import { Log } from "@/util" -import { errors } from "../error" +import { errors } from "../../error" const ReplayEvent = z.object({ id: z.string(), diff --git a/packages/opencode/src/server/instance/trace.ts b/packages/opencode/src/server/routes/instance/trace.ts similarity index 93% rename from packages/opencode/src/server/instance/trace.ts rename to packages/opencode/src/server/routes/instance/trace.ts index b3adbb4c8099..3e1f72d8b242 100644 --- a/packages/opencode/src/server/instance/trace.ts +++ b/packages/opencode/src/server/routes/instance/trace.ts @@ -1,6 +1,6 @@ import type { Context } from "hono" import { Effect } from "effect" -import { AppRuntime } from "../../effect/app-runtime" +import { AppRuntime } from "@/effect/app-runtime" type AppEnv = Parameters[0] extends Effect.Effect ? R : never diff --git a/packages/opencode/src/server/instance/tui.ts b/packages/opencode/src/server/routes/instance/tui.ts similarity index 98% rename from packages/opencode/src/server/instance/tui.ts rename to packages/opencode/src/server/routes/instance/tui.ts index 0073ef98c9f0..2f856c34884f 100644 --- a/packages/opencode/src/server/instance/tui.ts +++ b/packages/opencode/src/server/routes/instance/tui.ts @@ -1,13 +1,13 @@ import { Hono, type Context } from "hono" import { describeRoute, validator, resolver } from "hono-openapi" import z from "zod" -import { Bus } from "../../bus" -import { Session } from "../../session" +import { Bus } from "@/bus" +import { Session } from "@/session" import { TuiEvent } from "@/cli/cmd/tui/event" import { AppRuntime } from "@/effect/app-runtime" -import { AsyncQueue } from "../../util/queue" -import { errors } from "../error" -import { lazy } from "../../util/lazy" +import { AsyncQueue } from "@/util/queue" +import { errors } from "../../error" +import { lazy } from "@/util/lazy" const TuiRequest = z.object({ path: z.string(), diff --git a/packages/opencode/src/server/ui/index.ts b/packages/opencode/src/server/routes/ui.ts similarity index 100% rename from packages/opencode/src/server/ui/index.ts rename to packages/opencode/src/server/routes/ui.ts diff --git a/packages/opencode/src/server/server.ts b/packages/opencode/src/server/server.ts index 892a99a77ccd..2201c75b4c02 100644 --- a/packages/opencode/src/server/server.ts +++ b/packages/opencode/src/server/server.ts @@ -1,16 +1,25 @@ import { generateSpecs } from "hono-openapi" import { Hono } from "hono" +import type { MiddlewareHandler } from "hono" import { adapter } from "#hono" -import { MDNS } from "./mdns" import { lazy } from "@/util/lazy" +import { Log } from "@/util" +import { Flag } from "@/flag/flag" +import { Instance } from "@/project/instance" +import { InstanceBootstrap } from "@/project/bootstrap" +import { AppRuntime } from "@/effect/app-runtime" +import { AppFileSystem } from "@opencode-ai/shared/filesystem" +import { WorkspaceID } from "@/control-plane/schema" +import { WorkspaceContext } from "@/control-plane/workspace-context" +import { MDNS } from "./mdns" import { AuthMiddleware, CompressionMiddleware, CorsMiddleware, ErrorMiddleware, LoggerMiddleware } from "./middleware" import { FenceMiddleware } from "./fence" -import { InstanceRoutes } from "./instance" import { initProjectors } from "./projectors" -import { Log } from "@/util" -import { Flag } from "@/flag/flag" -import { ControlPlaneRoutes } from "./control" -import { UIRoutes } from "./ui" +import { InstanceRoutes } from "./routes/instance" +import { ControlPlaneRoutes } from "./routes/control" +import { UIRoutes } from "./routes/ui" +import { GlobalRoutes } from "./routes/global" +import { WorkspaceRouterMiddleware } from "./workspace" // @ts-ignore This global is needed to prevent ai-sdk from logging warnings to stdout https://github.com/vercel/ai/blob/2dc67e0ef538307f21368db32d5a12345d98831b/packages/ai/src/logger/log-warnings.ts#L85 globalThis.AI_SDK_LOG_WARNINGS = false @@ -30,18 +39,48 @@ export const Default = lazy(() => create({})) function create(opts: { cors?: string[] }) { const app = new Hono() + .onError(ErrorMiddleware) + .use(AuthMiddleware) + .use(LoggerMiddleware) + .use(CompressionMiddleware) + .use(CorsMiddleware(opts)) + .route("/global", GlobalRoutes()) + const runtime = adapter.create(app) + function InstanceMiddleware(workspaceID?: WorkspaceID): MiddlewareHandler { + return async (c, next) => { + const raw = c.req.query("directory") || c.req.header("x-opencode-directory") || process.cwd() + const directory = AppFileSystem.resolve( + (() => { + try { + return decodeURIComponent(raw) + } catch { + return raw + } + })(), + ) + + return WorkspaceContext.provide({ + workspaceID, + async fn() { + return Instance.provide({ + directory, + init: () => AppRuntime.runPromise(InstanceBootstrap), + async fn() { + return next() + }, + }) + }, + }) + } + } + if (Flag.OPENCODE_WORKSPACE_ID) { return { app: app - .onError(ErrorMiddleware) - .use(AuthMiddleware) - .use(LoggerMiddleware) - .use(CompressionMiddleware) - .use(CorsMiddleware(opts)) + .use(InstanceMiddleware(Flag.OPENCODE_WORKSPACE_ID ? WorkspaceID.make(Flag.OPENCODE_WORKSPACE_ID) : undefined)) .use(FenceMiddleware) - .route("/", ControlPlaneRoutes()) .route("/", InstanceRoutes(runtime.upgradeWebSocket)), runtime, } @@ -49,12 +88,9 @@ function create(opts: { cors?: string[] }) { return { app: app - .onError(ErrorMiddleware) - .use(AuthMiddleware) - .use(LoggerMiddleware) - .use(CompressionMiddleware) - .use(CorsMiddleware(opts)) + .use(InstanceMiddleware()) .route("/", ControlPlaneRoutes()) + .use(WorkspaceRouterMiddleware(runtime.upgradeWebSocket)) .route("/", InstanceRoutes(runtime.upgradeWebSocket)) .route("/", UIRoutes()), runtime, diff --git a/packages/opencode/src/server/instance/middleware.ts b/packages/opencode/src/server/workspace.ts similarity index 79% rename from packages/opencode/src/server/instance/middleware.ts rename to packages/opencode/src/server/workspace.ts index 7b66072c23e2..c141d10956dd 100644 --- a/packages/opencode/src/server/instance/middleware.ts +++ b/packages/opencode/src/server/workspace.ts @@ -2,17 +2,16 @@ import type { MiddlewareHandler } from "hono" import type { UpgradeWebSocket } from "hono/ws" import { getAdaptor } from "@/control-plane/adaptors" import { WorkspaceID } from "@/control-plane/schema" +import { WorkspaceContext } from "@/control-plane/workspace-context" import { Workspace } from "@/control-plane/workspace" -import { ServerProxy } from "../proxy" -import { Instance } from "@/project/instance" -import { InstanceBootstrap } from "@/project/bootstrap" import { Flag } from "@/flag/flag" +import { InstanceBootstrap } from "@/project/bootstrap" +import { Instance } from "@/project/instance" import { Session } from "@/session" import { SessionID } from "@/session/schema" -import { WorkspaceContext } from "@/control-plane/workspace-context" import { AppRuntime } from "@/effect/app-runtime" import { Log } from "@/util" -import { AppFileSystem } from "@opencode-ai/shared/filesystem" +import { ServerProxy } from "./proxy" type Rule = { method?: string; path: string; exact?: boolean; action: "local" | "forward" } @@ -51,45 +50,13 @@ export function WorkspaceRouterMiddleware(upgrade: UpgradeWebSocket): Middleware const log = Log.create({ service: "workspace-router" }) return async (c, next) => { - const raw = c.req.query("directory") || c.req.header("x-opencode-directory") || process.cwd() - const directory = AppFileSystem.resolve( - (() => { - try { - return decodeURIComponent(raw) - } catch { - return raw - } - })(), - ) - const url = new URL(c.req.url) const sessionWorkspaceID = await getSessionWorkspace(url) const workspaceID = sessionWorkspaceID || url.searchParams.get("workspace") if (!workspaceID || url.pathname.startsWith("/console") || Flag.OPENCODE_WORKSPACE_ID) { - if (Flag.OPENCODE_WORKSPACE_ID) { - return WorkspaceContext.provide({ - workspaceID: WorkspaceID.make(Flag.OPENCODE_WORKSPACE_ID), - async fn() { - return Instance.provide({ - directory, - init: () => AppRuntime.runPromise(InstanceBootstrap), - async fn() { - return next() - }, - }) - }, - }) - } - - return Instance.provide({ - directory, - init: () => AppRuntime.runPromise(InstanceBootstrap), - async fn() { - return next() - }, - }) + return next() } const workspace = await Workspace.get(WorkspaceID.make(workspaceID)) diff --git a/packages/opencode/test/server/session-messages.test.ts b/packages/opencode/test/server/session-messages.test.ts index 50b765896932..23e8b5014535 100644 --- a/packages/opencode/test/server/session-messages.test.ts +++ b/packages/opencode/test/server/session-messages.test.ts @@ -165,16 +165,3 @@ describe("session messages endpoint", () => { ) }) }) - -describe("session.prompt_async error handling", () => { - test("prompt_async route has error handler for detached prompt call", async () => { - const src = await Bun.file(new URL("../../src/server/instance/session.ts", import.meta.url)).text() - const start = src.indexOf('"/:sessionID/prompt_async"') - const end = src.indexOf('"/:sessionID/command"', start) - expect(start).toBeGreaterThan(-1) - expect(end).toBeGreaterThan(start) - const route = src.slice(start, end) - expect(route).toContain(".catch(") - expect(route).toContain("Bus.publish(Session.Event.Error") - }) -}) diff --git a/packages/sdk/js/src/v2/gen/sdk.gen.ts b/packages/sdk/js/src/v2/gen/sdk.gen.ts index d7bf43f506f8..f484147a40cf 100644 --- a/packages/sdk/js/src/v2/gen/sdk.gen.ts +++ b/packages/sdk/js/src/v2/gen/sdk.gen.ts @@ -510,11 +510,11 @@ export class App extends HeyApiClient { } } -export class Project extends HeyApiClient { +export class Adaptor extends HeyApiClient { /** - * List all projects + * List workspace adaptors * - * Get a list of projects that have been opened with OpenCode. + * List all available workspace adaptors for the current project. */ public list( parameters?: { @@ -534,19 +534,21 @@ export class Project extends HeyApiClient { }, ], ) - return (options?.client ?? this.client).get({ - url: "/project", + return (options?.client ?? this.client).get({ + url: "/experimental/workspace/adaptor", ...options, ...params, }) } +} +export class Workspace extends HeyApiClient { /** - * Get current project + * List workspaces * - * Retrieve the currently active project that OpenCode is working with. + * List all workspaces. */ - public current( + public list( parameters?: { directory?: string workspace?: string @@ -564,22 +566,26 @@ export class Project extends HeyApiClient { }, ], ) - return (options?.client ?? this.client).get({ - url: "/project/current", + return (options?.client ?? this.client).get({ + url: "/experimental/workspace", ...options, ...params, }) } /** - * Initialize git repository + * Create workspace * - * Create a git repository for the current project and return the refreshed project info. + * Create a workspace for the current project. */ - public initGit( + public create( parameters?: { directory?: string workspace?: string + id?: string + type?: string + branch?: string | null + extra?: unknown | null }, options?: Options, ) { @@ -590,39 +596,39 @@ export class Project extends HeyApiClient { args: [ { in: "query", key: "directory" }, { in: "query", key: "workspace" }, + { in: "body", key: "id" }, + { in: "body", key: "type" }, + { in: "body", key: "branch" }, + { in: "body", key: "extra" }, ], }, ], ) - return (options?.client ?? this.client).post({ - url: "/project/git/init", + return (options?.client ?? this.client).post< + ExperimentalWorkspaceCreateResponses, + ExperimentalWorkspaceCreateErrors, + ThrowOnError + >({ + url: "/experimental/workspace", ...options, ...params, + headers: { + "Content-Type": "application/json", + ...options?.headers, + ...params.headers, + }, }) } /** - * Update project + * Workspace status * - * Update project properties such as name, icon, and commands. + * Get connection status for workspaces in the current project. */ - public update( - parameters: { - projectID: string + public status( + parameters?: { directory?: string workspace?: string - name?: string - icon?: { - url?: string - override?: string - color?: string - } - commands?: { - /** - * Startup script to run when creating a new workspace (worktree) - */ - start?: string - } }, options?: Options, ) { @@ -631,37 +637,27 @@ export class Project extends HeyApiClient { [ { args: [ - { in: "path", key: "projectID" }, { in: "query", key: "directory" }, { in: "query", key: "workspace" }, - { in: "body", key: "name" }, - { in: "body", key: "icon" }, - { in: "body", key: "commands" }, ], }, ], ) - return (options?.client ?? this.client).patch({ - url: "/project/{projectID}", + return (options?.client ?? this.client).get({ + url: "/experimental/workspace/status", ...options, ...params, - headers: { - "Content-Type": "application/json", - ...options?.headers, - ...params.headers, - }, }) } -} -export class Pty extends HeyApiClient { /** - * List PTY sessions + * Remove workspace * - * Get a list of all active pseudo-terminal (PTY) sessions managed by OpenCode. + * Remove an existing workspace. */ - public list( - parameters?: { + public remove( + parameters: { + id: string directory?: string workspace?: string }, @@ -672,35 +668,35 @@ export class Pty extends HeyApiClient { [ { args: [ + { in: "path", key: "id" }, { in: "query", key: "directory" }, { in: "query", key: "workspace" }, ], }, ], ) - return (options?.client ?? this.client).get({ - url: "/pty", + return (options?.client ?? this.client).delete< + ExperimentalWorkspaceRemoveResponses, + ExperimentalWorkspaceRemoveErrors, + ThrowOnError + >({ + url: "/experimental/workspace/{id}", ...options, ...params, }) } /** - * Create PTY session + * Restore session into workspace * - * Create a new pseudo-terminal (PTY) session for running shell commands and processes. + * Replay a session's sync events into the target workspace in batches. */ - public create( - parameters?: { + public sessionRestore( + parameters: { + id: string directory?: string workspace?: string - command?: string - args?: Array - cwd?: string - title?: string - env?: { - [key: string]: string - } + sessionID?: string }, options?: Options, ) { @@ -709,19 +705,20 @@ export class Pty extends HeyApiClient { [ { args: [ + { in: "path", key: "id" }, { in: "query", key: "directory" }, { in: "query", key: "workspace" }, - { in: "body", key: "command" }, - { in: "body", key: "args" }, - { in: "body", key: "cwd" }, - { in: "body", key: "title" }, - { in: "body", key: "env" }, + { in: "body", key: "sessionID" }, ], }, ], ) - return (options?.client ?? this.client).post({ - url: "/pty", + return (options?.client ?? this.client).post< + ExperimentalWorkspaceSessionRestoreResponses, + ExperimentalWorkspaceSessionRestoreErrors, + ThrowOnError + >({ + url: "/experimental/workspace/{id}/session-restore", ...options, ...params, headers: { @@ -732,14 +729,20 @@ export class Pty extends HeyApiClient { }) } + private _adaptor?: Adaptor + get adaptor(): Adaptor { + return (this._adaptor ??= new Adaptor({ client: this.client })) + } +} + +export class Console extends HeyApiClient { /** - * Remove PTY session + * Get active Console provider metadata * - * Remove and terminate a specific pseudo-terminal (PTY) session. + * Get the active Console org name and the set of provider IDs managed by that Console org. */ - public remove( - parameters: { - ptyID: string + public get( + parameters?: { directory?: string workspace?: string }, @@ -750,28 +753,26 @@ export class Pty extends HeyApiClient { [ { args: [ - { in: "path", key: "ptyID" }, { in: "query", key: "directory" }, { in: "query", key: "workspace" }, ], }, ], ) - return (options?.client ?? this.client).delete({ - url: "/pty/{ptyID}", + return (options?.client ?? this.client).get({ + url: "/experimental/console", ...options, ...params, }) } /** - * Get PTY session + * List switchable Console orgs * - * Retrieve detailed information about a specific pseudo-terminal (PTY) session. + * Get the available Console orgs across logged-in accounts, including the current active org. */ - public get( - parameters: { - ptyID: string + public listOrgs( + parameters?: { directory?: string workspace?: string }, @@ -782,35 +783,30 @@ export class Pty extends HeyApiClient { [ { args: [ - { in: "path", key: "ptyID" }, { in: "query", key: "directory" }, { in: "query", key: "workspace" }, ], }, ], ) - return (options?.client ?? this.client).get({ - url: "/pty/{ptyID}", + return (options?.client ?? this.client).get({ + url: "/experimental/console/orgs", ...options, ...params, }) } /** - * Update PTY session + * Switch active Console org * - * Update properties of an existing pseudo-terminal (PTY) session. + * Persist a new active Console account/org selection for the current local OpenCode state. */ - public update( - parameters: { - ptyID: string + public switchOrg( + parameters?: { directory?: string workspace?: string - title?: string - size?: { - rows: number - cols: number - } + accountID?: string + orgID?: string }, options?: Options, ) { @@ -819,17 +815,16 @@ export class Pty extends HeyApiClient { [ { args: [ - { in: "path", key: "ptyID" }, { in: "query", key: "directory" }, { in: "query", key: "workspace" }, - { in: "body", key: "title" }, - { in: "body", key: "size" }, + { in: "body", key: "accountID" }, + { in: "body", key: "orgID" }, ], }, ], ) - return (options?.client ?? this.client).put({ - url: "/pty/{ptyID}", + return (options?.client ?? this.client).post({ + url: "/experimental/console/switch", ...options, ...params, headers: { @@ -839,17 +834,24 @@ export class Pty extends HeyApiClient { }, }) } +} +export class Session extends HeyApiClient { /** - * Connect to PTY session + * List sessions * - * Establish a WebSocket connection to interact with a pseudo-terminal (PTY) session in real-time. + * Get a list of all OpenCode sessions across projects, sorted by most recently updated. Archived sessions are excluded by default. */ - public connect( - parameters: { - ptyID: string + public list( + parameters?: { directory?: string workspace?: string + roots?: boolean + start?: number + cursor?: number + search?: string + limit?: number + archived?: boolean }, options?: Options, ) { @@ -858,28 +860,33 @@ export class Pty extends HeyApiClient { [ { args: [ - { in: "path", key: "ptyID" }, { in: "query", key: "directory" }, { in: "query", key: "workspace" }, + { in: "query", key: "roots" }, + { in: "query", key: "start" }, + { in: "query", key: "cursor" }, + { in: "query", key: "search" }, + { in: "query", key: "limit" }, + { in: "query", key: "archived" }, ], }, ], ) - return (options?.client ?? this.client).get({ - url: "/pty/{ptyID}/connect", + return (options?.client ?? this.client).get({ + url: "/experimental/session", ...options, ...params, }) } } -export class Config2 extends HeyApiClient { +export class Resource extends HeyApiClient { /** - * Get configuration + * Get MCP resources * - * Retrieve the current OpenCode configuration settings and preferences. + * Get all available MCP resources from connected servers. Optionally filter by name. */ - public get( + public list( parameters?: { directory?: string workspace?: string @@ -897,23 +904,46 @@ export class Config2 extends HeyApiClient { }, ], ) - return (options?.client ?? this.client).get({ - url: "/config", + return (options?.client ?? this.client).get({ + url: "/experimental/resource", ...options, ...params, }) } +} +export class Experimental extends HeyApiClient { + private _workspace?: Workspace + get workspace(): Workspace { + return (this._workspace ??= new Workspace({ client: this.client })) + } + + private _console?: Console + get console(): Console { + return (this._console ??= new Console({ client: this.client })) + } + + private _session?: Session + get session(): Session { + return (this._session ??= new Session({ client: this.client })) + } + + private _resource?: Resource + get resource(): Resource { + return (this._resource ??= new Resource({ client: this.client })) + } +} + +export class Project extends HeyApiClient { /** - * Update configuration + * List all projects * - * Update OpenCode configuration settings and preferences. + * Get a list of projects that have been opened with OpenCode. */ - public update( + public list( parameters?: { directory?: string workspace?: string - config?: Config3 }, options?: Options, ) { @@ -924,29 +954,23 @@ export class Config2 extends HeyApiClient { args: [ { in: "query", key: "directory" }, { in: "query", key: "workspace" }, - { key: "config", map: "body" }, ], }, ], ) - return (options?.client ?? this.client).patch({ - url: "/config", + return (options?.client ?? this.client).get({ + url: "/project", ...options, ...params, - headers: { - "Content-Type": "application/json", - ...options?.headers, - ...params.headers, - }, }) } /** - * List config providers + * Get current project * - * Get a list of all configured AI providers and their default models. + * Retrieve the currently active project that OpenCode is working with. */ - public providers( + public current( parameters?: { directory?: string workspace?: string @@ -964,21 +988,19 @@ export class Config2 extends HeyApiClient { }, ], ) - return (options?.client ?? this.client).get({ - url: "/config/providers", + return (options?.client ?? this.client).get({ + url: "/project/current", ...options, ...params, }) } -} -export class Console extends HeyApiClient { /** - * Get active Console provider metadata + * Initialize git repository * - * Get the active Console org name and the set of provider IDs managed by that Console org. + * Create a git repository for the current project and return the refreshed project info. */ - public get( + public initGit( parameters?: { directory?: string workspace?: string @@ -996,19 +1018,73 @@ export class Console extends HeyApiClient { }, ], ) - return (options?.client ?? this.client).get({ - url: "/experimental/console", + return (options?.client ?? this.client).post({ + url: "/project/git/init", + ...options, + ...params, + }) + } + + /** + * Update project + * + * Update project properties such as name, icon, and commands. + */ + public update( + parameters: { + projectID: string + directory?: string + workspace?: string + name?: string + icon?: { + url?: string + override?: string + color?: string + } + commands?: { + /** + * Startup script to run when creating a new workspace (worktree) + */ + start?: string + } + }, + options?: Options, + ) { + const params = buildClientParams( + [parameters], + [ + { + args: [ + { in: "path", key: "projectID" }, + { in: "query", key: "directory" }, + { in: "query", key: "workspace" }, + { in: "body", key: "name" }, + { in: "body", key: "icon" }, + { in: "body", key: "commands" }, + ], + }, + ], + ) + return (options?.client ?? this.client).patch({ + url: "/project/{projectID}", ...options, ...params, + headers: { + "Content-Type": "application/json", + ...options?.headers, + ...params.headers, + }, }) } +} +export class Pty extends HeyApiClient { /** - * List switchable Console orgs + * List PTY sessions * - * Get the available Console orgs across logged-in accounts, including the current active org. + * Get a list of all active pseudo-terminal (PTY) sessions managed by OpenCode. */ - public listOrgs( + public list( parameters?: { directory?: string workspace?: string @@ -1026,24 +1102,29 @@ export class Console extends HeyApiClient { }, ], ) - return (options?.client ?? this.client).get({ - url: "/experimental/console/orgs", + return (options?.client ?? this.client).get({ + url: "/pty", ...options, ...params, }) } /** - * Switch active Console org + * Create PTY session * - * Persist a new active Console account/org selection for the current local OpenCode state. + * Create a new pseudo-terminal (PTY) session for running shell commands and processes. */ - public switchOrg( + public create( parameters?: { directory?: string workspace?: string - accountID?: string - orgID?: string + command?: string + args?: Array + cwd?: string + title?: string + env?: { + [key: string]: string + } }, options?: Options, ) { @@ -1054,14 +1135,17 @@ export class Console extends HeyApiClient { args: [ { in: "query", key: "directory" }, { in: "query", key: "workspace" }, - { in: "body", key: "accountID" }, - { in: "body", key: "orgID" }, + { in: "body", key: "command" }, + { in: "body", key: "args" }, + { in: "body", key: "cwd" }, + { in: "body", key: "title" }, + { in: "body", key: "env" }, ], }, ], ) - return (options?.client ?? this.client).post({ - url: "/experimental/console/switch", + return (options?.client ?? this.client).post({ + url: "/pty", ...options, ...params, headers: { @@ -1071,16 +1155,15 @@ export class Console extends HeyApiClient { }, }) } -} -export class Adaptor extends HeyApiClient { /** - * List workspace adaptors + * Remove PTY session * - * List all available workspace adaptors for the current project. + * Remove and terminate a specific pseudo-terminal (PTY) session. */ - public list( - parameters?: { + public remove( + parameters: { + ptyID: string directory?: string workspace?: string }, @@ -1091,28 +1174,28 @@ export class Adaptor extends HeyApiClient { [ { args: [ + { in: "path", key: "ptyID" }, { in: "query", key: "directory" }, { in: "query", key: "workspace" }, ], }, ], ) - return (options?.client ?? this.client).get({ - url: "/experimental/workspace/adaptor", + return (options?.client ?? this.client).delete({ + url: "/pty/{ptyID}", ...options, ...params, }) } -} -export class Workspace extends HeyApiClient { /** - * List workspaces + * Get PTY session * - * List all workspaces. + * Retrieve detailed information about a specific pseudo-terminal (PTY) session. */ - public list( - parameters?: { + public get( + parameters: { + ptyID: string directory?: string workspace?: string }, @@ -1123,32 +1206,35 @@ export class Workspace extends HeyApiClient { [ { args: [ + { in: "path", key: "ptyID" }, { in: "query", key: "directory" }, { in: "query", key: "workspace" }, ], }, ], ) - return (options?.client ?? this.client).get({ - url: "/experimental/workspace", + return (options?.client ?? this.client).get({ + url: "/pty/{ptyID}", ...options, ...params, }) } /** - * Create workspace + * Update PTY session * - * Create a workspace for the current project. + * Update properties of an existing pseudo-terminal (PTY) session. */ - public create( - parameters?: { + public update( + parameters: { + ptyID: string directory?: string workspace?: string - id?: string - type?: string - branch?: string | null - extra?: unknown | null + title?: string + size?: { + rows: number + cols: number + } }, options?: Options, ) { @@ -1157,22 +1243,17 @@ export class Workspace extends HeyApiClient { [ { args: [ + { in: "path", key: "ptyID" }, { in: "query", key: "directory" }, { in: "query", key: "workspace" }, - { in: "body", key: "id" }, - { in: "body", key: "type" }, - { in: "body", key: "branch" }, - { in: "body", key: "extra" }, + { in: "body", key: "title" }, + { in: "body", key: "size" }, ], }, ], ) - return (options?.client ?? this.client).post< - ExperimentalWorkspaceCreateResponses, - ExperimentalWorkspaceCreateErrors, - ThrowOnError - >({ - url: "/experimental/workspace", + return (options?.client ?? this.client).put({ + url: "/pty/{ptyID}", ...options, ...params, headers: { @@ -1184,12 +1265,13 @@ export class Workspace extends HeyApiClient { } /** - * Workspace status + * Connect to PTY session * - * Get connection status for workspaces in the current project. + * Establish a WebSocket connection to interact with a pseudo-terminal (PTY) session in real-time. */ - public status( - parameters?: { + public connect( + parameters: { + ptyID: string directory?: string workspace?: string }, @@ -1200,27 +1282,29 @@ export class Workspace extends HeyApiClient { [ { args: [ + { in: "path", key: "ptyID" }, { in: "query", key: "directory" }, { in: "query", key: "workspace" }, ], }, ], ) - return (options?.client ?? this.client).get({ - url: "/experimental/workspace/status", + return (options?.client ?? this.client).get({ + url: "/pty/{ptyID}/connect", ...options, ...params, }) } +} +export class Config2 extends HeyApiClient { /** - * Remove workspace + * Get configuration * - * Remove an existing workspace. + * Retrieve the current OpenCode configuration settings and preferences. */ - public remove( - parameters: { - id: string + public get( + parameters?: { directory?: string workspace?: string }, @@ -1231,35 +1315,29 @@ export class Workspace extends HeyApiClient { [ { args: [ - { in: "path", key: "id" }, { in: "query", key: "directory" }, { in: "query", key: "workspace" }, ], }, ], ) - return (options?.client ?? this.client).delete< - ExperimentalWorkspaceRemoveResponses, - ExperimentalWorkspaceRemoveErrors, - ThrowOnError - >({ - url: "/experimental/workspace/{id}", + return (options?.client ?? this.client).get({ + url: "/config", ...options, ...params, }) } /** - * Restore session into workspace + * Update configuration * - * Replay a session's sync events into the target workspace in batches. + * Update OpenCode configuration settings and preferences. */ - public sessionRestore( - parameters: { - id: string + public update( + parameters?: { directory?: string workspace?: string - sessionID?: string + config?: Config3 }, options?: Options, ) { @@ -1268,20 +1346,15 @@ export class Workspace extends HeyApiClient { [ { args: [ - { in: "path", key: "id" }, { in: "query", key: "directory" }, { in: "query", key: "workspace" }, - { in: "body", key: "sessionID" }, + { key: "config", map: "body" }, ], }, ], ) - return (options?.client ?? this.client).post< - ExperimentalWorkspaceSessionRestoreResponses, - ExperimentalWorkspaceSessionRestoreErrors, - ThrowOnError - >({ - url: "/experimental/workspace/{id}/session-restore", + return (options?.client ?? this.client).patch({ + url: "/config", ...options, ...params, headers: { @@ -1292,63 +1365,12 @@ export class Workspace extends HeyApiClient { }) } - private _adaptor?: Adaptor - get adaptor(): Adaptor { - return (this._adaptor ??= new Adaptor({ client: this.client })) - } -} - -export class Session extends HeyApiClient { - /** - * List sessions - * - * Get a list of all OpenCode sessions across projects, sorted by most recently updated. Archived sessions are excluded by default. - */ - public list( - parameters?: { - directory?: string - workspace?: string - roots?: boolean - start?: number - cursor?: number - search?: string - limit?: number - archived?: boolean - }, - options?: Options, - ) { - const params = buildClientParams( - [parameters], - [ - { - args: [ - { in: "query", key: "directory" }, - { in: "query", key: "workspace" }, - { in: "query", key: "roots" }, - { in: "query", key: "start" }, - { in: "query", key: "cursor" }, - { in: "query", key: "search" }, - { in: "query", key: "limit" }, - { in: "query", key: "archived" }, - ], - }, - ], - ) - return (options?.client ?? this.client).get({ - url: "/experimental/session", - ...options, - ...params, - }) - } -} - -export class Resource extends HeyApiClient { /** - * Get MCP resources + * List config providers * - * Get all available MCP resources from connected servers. Optionally filter by name. + * Get a list of all configured AI providers and their default models. */ - public list( + public providers( parameters?: { directory?: string workspace?: string @@ -1366,36 +1388,14 @@ export class Resource extends HeyApiClient { }, ], ) - return (options?.client ?? this.client).get({ - url: "/experimental/resource", + return (options?.client ?? this.client).get({ + url: "/config/providers", ...options, ...params, }) } } -export class Experimental extends HeyApiClient { - private _console?: Console - get console(): Console { - return (this._console ??= new Console({ client: this.client })) - } - - private _workspace?: Workspace - get workspace(): Workspace { - return (this._workspace ??= new Workspace({ client: this.client })) - } - - private _session?: Session - get session(): Session { - return (this._session ??= new Session({ client: this.client })) - } - - private _resource?: Resource - get resource(): Resource { - return (this._resource ??= new Resource({ client: this.client })) - } -} - export class Tool extends HeyApiClient { /** * List tool IDs @@ -4314,6 +4314,11 @@ export class OpencodeClient extends HeyApiClient { return (this._app ??= new App({ client: this.client })) } + private _experimental?: Experimental + get experimental(): Experimental { + return (this._experimental ??= new Experimental({ client: this.client })) + } + private _project?: Project get project(): Project { return (this._project ??= new Project({ client: this.client })) @@ -4329,11 +4334,6 @@ export class OpencodeClient extends HeyApiClient { return (this._config ??= new Config2({ client: this.client })) } - private _experimental?: Experimental - get experimental(): Experimental { - return (this._experimental ??= new Experimental({ client: this.client })) - } - private _tool?: Tool get tool(): Tool { return (this._tool ??= new Tool({ client: this.client })) diff --git a/packages/sdk/js/src/v2/gen/types.gen.ts b/packages/sdk/js/src/v2/gen/types.gen.ts index 25c3cfa66981..839dae8b223a 100644 --- a/packages/sdk/js/src/v2/gen/types.gen.ts +++ b/packages/sdk/js/src/v2/gen/types.gen.ts @@ -1706,6 +1706,16 @@ export type WellKnownAuth = { export type Auth = OAuth | ApiAuth | WellKnownAuth +export type Workspace = { + id: string + type: string + name: string + branch: string | null + directory: string | null + extra: unknown | null + projectID: string +} + export type NotFoundError = { name: "NotFoundError" data: { @@ -1808,16 +1818,6 @@ export type ToolListItem = { export type ToolList = Array -export type Workspace = { - id: string - type: string - name: string - branch: string | null - directory: string | null - extra: unknown | null - projectID: string -} - export type Worktree = { name: string branch: string @@ -2394,6 +2394,177 @@ export type AppLogResponses = { export type AppLogResponse = AppLogResponses[keyof AppLogResponses] +export type ExperimentalWorkspaceAdaptorListData = { + body?: never + path?: never + query?: { + directory?: string + workspace?: string + } + url: "/experimental/workspace/adaptor" +} + +export type ExperimentalWorkspaceAdaptorListResponses = { + /** + * Workspace adaptors + */ + 200: Array<{ + type: string + name: string + description: string + }> +} + +export type ExperimentalWorkspaceAdaptorListResponse = + ExperimentalWorkspaceAdaptorListResponses[keyof ExperimentalWorkspaceAdaptorListResponses] + +export type ExperimentalWorkspaceListData = { + body?: never + path?: never + query?: { + directory?: string + workspace?: string + } + url: "/experimental/workspace" +} + +export type ExperimentalWorkspaceListResponses = { + /** + * Workspaces + */ + 200: Array +} + +export type ExperimentalWorkspaceListResponse = + ExperimentalWorkspaceListResponses[keyof ExperimentalWorkspaceListResponses] + +export type ExperimentalWorkspaceCreateData = { + body?: { + id?: string + type: string + branch: string | null + extra: unknown | null + } + path?: never + query?: { + directory?: string + workspace?: string + } + url: "/experimental/workspace" +} + +export type ExperimentalWorkspaceCreateErrors = { + /** + * Bad request + */ + 400: BadRequestError +} + +export type ExperimentalWorkspaceCreateError = + ExperimentalWorkspaceCreateErrors[keyof ExperimentalWorkspaceCreateErrors] + +export type ExperimentalWorkspaceCreateResponses = { + /** + * Workspace created + */ + 200: Workspace +} + +export type ExperimentalWorkspaceCreateResponse = + ExperimentalWorkspaceCreateResponses[keyof ExperimentalWorkspaceCreateResponses] + +export type ExperimentalWorkspaceStatusData = { + body?: never + path?: never + query?: { + directory?: string + workspace?: string + } + url: "/experimental/workspace/status" +} + +export type ExperimentalWorkspaceStatusResponses = { + /** + * Workspace status + */ + 200: Array<{ + workspaceID: string + status: "connected" | "connecting" | "disconnected" | "error" + error?: string + }> +} + +export type ExperimentalWorkspaceStatusResponse = + ExperimentalWorkspaceStatusResponses[keyof ExperimentalWorkspaceStatusResponses] + +export type ExperimentalWorkspaceRemoveData = { + body?: never + path: { + id: string + } + query?: { + directory?: string + workspace?: string + } + url: "/experimental/workspace/{id}" +} + +export type ExperimentalWorkspaceRemoveErrors = { + /** + * Bad request + */ + 400: BadRequestError +} + +export type ExperimentalWorkspaceRemoveError = + ExperimentalWorkspaceRemoveErrors[keyof ExperimentalWorkspaceRemoveErrors] + +export type ExperimentalWorkspaceRemoveResponses = { + /** + * Workspace removed + */ + 200: Workspace +} + +export type ExperimentalWorkspaceRemoveResponse = + ExperimentalWorkspaceRemoveResponses[keyof ExperimentalWorkspaceRemoveResponses] + +export type ExperimentalWorkspaceSessionRestoreData = { + body?: { + sessionID: string + } + path: { + id: string + } + query?: { + directory?: string + workspace?: string + } + url: "/experimental/workspace/{id}/session-restore" +} + +export type ExperimentalWorkspaceSessionRestoreErrors = { + /** + * Bad request + */ + 400: BadRequestError +} + +export type ExperimentalWorkspaceSessionRestoreError = + ExperimentalWorkspaceSessionRestoreErrors[keyof ExperimentalWorkspaceSessionRestoreErrors] + +export type ExperimentalWorkspaceSessionRestoreResponses = { + /** + * Session replay started + */ + 200: { + total: number + } +} + +export type ExperimentalWorkspaceSessionRestoreResponse = + ExperimentalWorkspaceSessionRestoreResponses[keyof ExperimentalWorkspaceSessionRestoreResponses] + export type ProjectListData = { body?: never path?: never @@ -2883,177 +3054,6 @@ export type ToolListResponses = { export type ToolListResponse = ToolListResponses[keyof ToolListResponses] -export type ExperimentalWorkspaceAdaptorListData = { - body?: never - path?: never - query?: { - directory?: string - workspace?: string - } - url: "/experimental/workspace/adaptor" -} - -export type ExperimentalWorkspaceAdaptorListResponses = { - /** - * Workspace adaptors - */ - 200: Array<{ - type: string - name: string - description: string - }> -} - -export type ExperimentalWorkspaceAdaptorListResponse = - ExperimentalWorkspaceAdaptorListResponses[keyof ExperimentalWorkspaceAdaptorListResponses] - -export type ExperimentalWorkspaceListData = { - body?: never - path?: never - query?: { - directory?: string - workspace?: string - } - url: "/experimental/workspace" -} - -export type ExperimentalWorkspaceListResponses = { - /** - * Workspaces - */ - 200: Array -} - -export type ExperimentalWorkspaceListResponse = - ExperimentalWorkspaceListResponses[keyof ExperimentalWorkspaceListResponses] - -export type ExperimentalWorkspaceCreateData = { - body?: { - id?: string - type: string - branch: string | null - extra: unknown | null - } - path?: never - query?: { - directory?: string - workspace?: string - } - url: "/experimental/workspace" -} - -export type ExperimentalWorkspaceCreateErrors = { - /** - * Bad request - */ - 400: BadRequestError -} - -export type ExperimentalWorkspaceCreateError = - ExperimentalWorkspaceCreateErrors[keyof ExperimentalWorkspaceCreateErrors] - -export type ExperimentalWorkspaceCreateResponses = { - /** - * Workspace created - */ - 200: Workspace -} - -export type ExperimentalWorkspaceCreateResponse = - ExperimentalWorkspaceCreateResponses[keyof ExperimentalWorkspaceCreateResponses] - -export type ExperimentalWorkspaceStatusData = { - body?: never - path?: never - query?: { - directory?: string - workspace?: string - } - url: "/experimental/workspace/status" -} - -export type ExperimentalWorkspaceStatusResponses = { - /** - * Workspace status - */ - 200: Array<{ - workspaceID: string - status: "connected" | "connecting" | "disconnected" | "error" - error?: string - }> -} - -export type ExperimentalWorkspaceStatusResponse = - ExperimentalWorkspaceStatusResponses[keyof ExperimentalWorkspaceStatusResponses] - -export type ExperimentalWorkspaceRemoveData = { - body?: never - path: { - id: string - } - query?: { - directory?: string - workspace?: string - } - url: "/experimental/workspace/{id}" -} - -export type ExperimentalWorkspaceRemoveErrors = { - /** - * Bad request - */ - 400: BadRequestError -} - -export type ExperimentalWorkspaceRemoveError = - ExperimentalWorkspaceRemoveErrors[keyof ExperimentalWorkspaceRemoveErrors] - -export type ExperimentalWorkspaceRemoveResponses = { - /** - * Workspace removed - */ - 200: Workspace -} - -export type ExperimentalWorkspaceRemoveResponse = - ExperimentalWorkspaceRemoveResponses[keyof ExperimentalWorkspaceRemoveResponses] - -export type ExperimentalWorkspaceSessionRestoreData = { - body?: { - sessionID: string - } - path: { - id: string - } - query?: { - directory?: string - workspace?: string - } - url: "/experimental/workspace/{id}/session-restore" -} - -export type ExperimentalWorkspaceSessionRestoreErrors = { - /** - * Bad request - */ - 400: BadRequestError -} - -export type ExperimentalWorkspaceSessionRestoreError = - ExperimentalWorkspaceSessionRestoreErrors[keyof ExperimentalWorkspaceSessionRestoreErrors] - -export type ExperimentalWorkspaceSessionRestoreResponses = { - /** - * Session replay started - */ - 200: { - total: number - } -} - -export type ExperimentalWorkspaceSessionRestoreResponse = - ExperimentalWorkspaceSessionRestoreResponses[keyof ExperimentalWorkspaceSessionRestoreResponses] - export type WorktreeRemoveData = { body?: WorktreeRemoveInput path?: never diff --git a/packages/sdk/openapi.json b/packages/sdk/openapi.json index 9193b11ad975..cf14026eae4d 100644 --- a/packages/sdk/openapi.json +++ b/packages/sdk/openapi.json @@ -415,9 +415,9 @@ ] } }, - "/project": { + "/experimental/workspace/adaptor": { "get": { - "operationId": "project.list", + "operationId": "experimental.workspace.adaptor.list", "parameters": [ { "in": "query", @@ -434,17 +434,29 @@ } } ], - "summary": "List all projects", - "description": "Get a list of projects that have been opened with OpenCode.", + "summary": "List workspace adaptors", + "description": "List all available workspace adaptors for the current project.", "responses": { "200": { - "description": "List of projects", + "description": "Workspace adaptors", "content": { "application/json": { "schema": { "type": "array", "items": { - "$ref": "#/components/schemas/Project" + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "required": ["type", "name", "description"] } } } @@ -454,14 +466,14 @@ "x-codeSamples": [ { "lang": "js", - "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.project.list({\n ...\n})" + "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.experimental.workspace.adaptor.list({\n ...\n})" } ] } }, - "/project/current": { - "get": { - "operationId": "project.current", + "/experimental/workspace": { + "post": { + "operationId": "experimental.workspace.create", "parameters": [ { "in": "query", @@ -478,31 +490,76 @@ } } ], - "summary": "Get current project", - "description": "Retrieve the currently active project that OpenCode is working with.", + "summary": "Create workspace", + "description": "Create a workspace for the current project.", "responses": { "200": { - "description": "Current project information", + "description": "Workspace created", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Project" + "$ref": "#/components/schemas/Workspace" + } + } + } + }, + "400": { + "description": "Bad request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BadRequestError" } } } } }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string", + "pattern": "^wrk.*" + }, + "type": { + "type": "string" + }, + "branch": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "extra": { + "anyOf": [ + {}, + { + "type": "null" + } + ] + } + }, + "required": ["type", "branch", "extra"] + } + } + } + }, "x-codeSamples": [ { "lang": "js", - "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.project.current({\n ...\n})" + "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.experimental.workspace.create({\n ...\n})" } ] - } - }, - "/project/git/init": { - "post": { - "operationId": "project.initGit", + }, + "get": { + "operationId": "experimental.workspace.list", "parameters": [ { "in": "query", @@ -519,15 +576,18 @@ } } ], - "summary": "Initialize git repository", - "description": "Create a git repository for the current project and return the refreshed project info.", + "summary": "List workspaces", + "description": "List all workspaces.", "responses": { "200": { - "description": "Project information after git initialization", + "description": "Workspaces", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Project" + "type": "array", + "items": { + "$ref": "#/components/schemas/Workspace" + } } } } @@ -536,14 +596,14 @@ "x-codeSamples": [ { "lang": "js", - "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.project.initGit({\n ...\n})" + "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.experimental.workspace.list({\n ...\n})" } ] } }, - "/project/{projectID}": { - "patch": { - "operationId": "project.update", + "/experimental/workspace/status": { + "get": { + "operationId": "experimental.workspace.status", "parameters": [ { "in": "query", @@ -558,81 +618,33 @@ "schema": { "type": "string" } - }, - { - "in": "path", - "name": "projectID", - "schema": { - "type": "string" - }, - "required": true } ], - "summary": "Update project", - "description": "Update project properties such as name, icon, and commands.", + "summary": "Workspace status", + "description": "Get connection status for workspaces in the current project.", "responses": { "200": { - "description": "Updated project information", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Project" - } - } - } - }, - "400": { - "description": "Bad request", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/BadRequestError" - } - } - } - }, - "404": { - "description": "Not found", + "description": "Workspace status", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/NotFoundError" - } - } - } - } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "icon": { + "type": "array", + "items": { "type": "object", "properties": { - "url": { - "type": "string" + "workspaceID": { + "type": "string", + "pattern": "^wrk.*" }, - "override": { - "type": "string" + "status": { + "type": "string", + "enum": ["connected", "connecting", "disconnected", "error"] }, - "color": { - "type": "string" - } - } - }, - "commands": { - "type": "object", - "properties": { - "start": { - "description": "Startup script to run when creating a new workspace (worktree)", + "error": { "type": "string" } - } + }, + "required": ["workspaceID", "status"] } } } @@ -642,14 +654,14 @@ "x-codeSamples": [ { "lang": "js", - "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.project.update({\n ...\n})" + "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.experimental.workspace.status({\n ...\n})" } ] } }, - "/pty": { - "get": { - "operationId": "pty.list", + "/experimental/workspace/{id}": { + "delete": { + "operationId": "experimental.workspace.remove", "parameters": [ { "in": "query", @@ -664,20 +676,36 @@ "schema": { "type": "string" } + }, + { + "in": "path", + "name": "id", + "schema": { + "type": "string", + "pattern": "^wrk.*" + }, + "required": true } ], - "summary": "List PTY sessions", - "description": "Get a list of all active pseudo-terminal (PTY) sessions managed by OpenCode.", + "summary": "Remove workspace", + "description": "Remove an existing workspace.", "responses": { "200": { - "description": "List of sessions", + "description": "Workspace removed", "content": { "application/json": { "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Pty" - } + "$ref": "#/components/schemas/Workspace" + } + } + } + }, + "400": { + "description": "Bad request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BadRequestError" } } } @@ -686,12 +714,14 @@ "x-codeSamples": [ { "lang": "js", - "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.pty.list({\n ...\n})" + "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.experimental.workspace.remove({\n ...\n})" } ] - }, + } + }, + "/experimental/workspace/{id}/session-restore": { "post": { - "operationId": "pty.create", + "operationId": "experimental.workspace.sessionRestore", "parameters": [ { "in": "query", @@ -706,19 +736,36 @@ "schema": { "type": "string" } + }, + { + "in": "path", + "name": "id", + "schema": { + "type": "string", + "pattern": "^wrk.*" + }, + "required": true } ], - "summary": "Create PTY session", - "description": "Create a new pseudo-terminal (PTY) session for running shell commands and processes.", + "summary": "Restore session into workspace", + "description": "Replay a session's sync events into the target workspace in batches.", "responses": { "200": { - "description": "Created session", + "description": "Session replay started", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Pty" - } - } + "type": "object", + "properties": { + "total": { + "type": "integer", + "minimum": 0, + "maximum": 9007199254740991 + } + }, + "required": ["total"] + } + } } }, "400": { @@ -738,31 +785,12 @@ "schema": { "type": "object", "properties": { - "command": { - "type": "string" - }, - "args": { - "type": "array", - "items": { - "type": "string" - } - }, - "cwd": { - "type": "string" - }, - "title": { - "type": "string" - }, - "env": { - "type": "object", - "propertyNames": { - "type": "string" - }, - "additionalProperties": { - "type": "string" - } + "sessionID": { + "type": "string", + "pattern": "^ses.*" } - } + }, + "required": ["sessionID"] } } } @@ -770,14 +798,14 @@ "x-codeSamples": [ { "lang": "js", - "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.pty.create({\n ...\n})" + "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.experimental.workspace.sessionRestore({\n ...\n})" } ] } }, - "/pty/{ptyID}": { + "/project": { "get": { - "operationId": "pty.get", + "operationId": "project.list", "parameters": [ { "in": "query", @@ -792,36 +820,20 @@ "schema": { "type": "string" } - }, - { - "in": "path", - "name": "ptyID", - "schema": { - "type": "string", - "pattern": "^pty.*" - }, - "required": true } ], - "summary": "Get PTY session", - "description": "Retrieve detailed information about a specific pseudo-terminal (PTY) session.", + "summary": "List all projects", + "description": "Get a list of projects that have been opened with OpenCode.", "responses": { "200": { - "description": "Session info", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pty" - } - } - } - }, - "404": { - "description": "Not found", + "description": "List of projects", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/NotFoundError" + "type": "array", + "items": { + "$ref": "#/components/schemas/Project" + } } } } @@ -830,12 +842,14 @@ "x-codeSamples": [ { "lang": "js", - "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.pty.get({\n ...\n})" + "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.project.list({\n ...\n})" } ] - }, - "put": { - "operationId": "pty.update", + } + }, + "/project/current": { + "get": { + "operationId": "project.current", "parameters": [ { "in": "query", @@ -850,62 +864,17 @@ "schema": { "type": "string" } - }, - { - "in": "path", - "name": "ptyID", - "schema": { - "type": "string", - "pattern": "^pty.*" - }, - "required": true } ], - "summary": "Update PTY session", - "description": "Update properties of an existing pseudo-terminal (PTY) session.", + "summary": "Get current project", + "description": "Retrieve the currently active project that OpenCode is working with.", "responses": { "200": { - "description": "Updated session", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pty" - } - } - } - }, - "400": { - "description": "Bad request", + "description": "Current project information", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/BadRequestError" - } - } - } - } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "title": { - "type": "string" - }, - "size": { - "type": "object", - "properties": { - "rows": { - "type": "number" - }, - "cols": { - "type": "number" - } - }, - "required": ["rows", "cols"] - } + "$ref": "#/components/schemas/Project" } } } @@ -914,12 +883,14 @@ "x-codeSamples": [ { "lang": "js", - "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.pty.update({\n ...\n})" + "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.project.current({\n ...\n})" } ] - }, - "delete": { - "operationId": "pty.remove", + } + }, + "/project/git/init": { + "post": { + "operationId": "project.initGit", "parameters": [ { "in": "query", @@ -934,36 +905,17 @@ "schema": { "type": "string" } - }, - { - "in": "path", - "name": "ptyID", - "schema": { - "type": "string", - "pattern": "^pty.*" - }, - "required": true } ], - "summary": "Remove PTY session", - "description": "Remove and terminate a specific pseudo-terminal (PTY) session.", + "summary": "Initialize git repository", + "description": "Create a git repository for the current project and return the refreshed project info.", "responses": { "200": { - "description": "Session removed", - "content": { - "application/json": { - "schema": { - "type": "boolean" - } - } - } - }, - "404": { - "description": "Not found", + "description": "Project information after git initialization", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/NotFoundError" + "$ref": "#/components/schemas/Project" } } } @@ -972,14 +924,14 @@ "x-codeSamples": [ { "lang": "js", - "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.pty.remove({\n ...\n})" + "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.project.initGit({\n ...\n})" } ] } }, - "/pty/{ptyID}/connect": { - "get": { - "operationId": "pty.connect", + "/project/{projectID}": { + "patch": { + "operationId": "project.update", "parameters": [ { "in": "query", @@ -997,23 +949,32 @@ }, { "in": "path", - "name": "ptyID", + "name": "projectID", "schema": { - "type": "string", - "pattern": "^pty.*" + "type": "string" }, "required": true } ], - "summary": "Connect to PTY session", - "description": "Establish a WebSocket connection to interact with a pseudo-terminal (PTY) session in real-time.", + "summary": "Update project", + "description": "Update project properties such as name, icon, and commands.", "responses": { "200": { - "description": "Connected session", + "description": "Updated project information", "content": { "application/json": { "schema": { - "type": "boolean" + "$ref": "#/components/schemas/Project" + } + } + } + }, + "400": { + "description": "Bad request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BadRequestError" } } } @@ -1029,17 +990,54 @@ } } }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "icon": { + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "override": { + "type": "string" + }, + "color": { + "type": "string" + } + } + }, + "commands": { + "type": "object", + "properties": { + "start": { + "description": "Startup script to run when creating a new workspace (worktree)", + "type": "string" + } + } + } + } + } + } + } + }, "x-codeSamples": [ { "lang": "js", - "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.pty.connect({\n ...\n})" + "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.project.update({\n ...\n})" } ] } }, - "/config": { + "/pty": { "get": { - "operationId": "config.get", + "operationId": "pty.list", "parameters": [ { "in": "query", @@ -1056,15 +1054,18 @@ } } ], - "summary": "Get configuration", - "description": "Retrieve the current OpenCode configuration settings and preferences.", + "summary": "List PTY sessions", + "description": "Get a list of all active pseudo-terminal (PTY) sessions managed by OpenCode.", "responses": { "200": { - "description": "Get config info", + "description": "List of sessions", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Config" + "type": "array", + "items": { + "$ref": "#/components/schemas/Pty" + } } } } @@ -1073,12 +1074,12 @@ "x-codeSamples": [ { "lang": "js", - "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.config.get({\n ...\n})" + "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.pty.list({\n ...\n})" } ] }, - "patch": { - "operationId": "config.update", + "post": { + "operationId": "pty.create", "parameters": [ { "in": "query", @@ -1095,15 +1096,15 @@ } } ], - "summary": "Update configuration", - "description": "Update OpenCode configuration settings and preferences.", + "summary": "Create PTY session", + "description": "Create a new pseudo-terminal (PTY) session for running shell commands and processes.", "responses": { "200": { - "description": "Successfully updated config", + "description": "Created session", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Config" + "$ref": "#/components/schemas/Pty" } } } @@ -1123,7 +1124,33 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Config" + "type": "object", + "properties": { + "command": { + "type": "string" + }, + "args": { + "type": "array", + "items": { + "type": "string" + } + }, + "cwd": { + "type": "string" + }, + "title": { + "type": "string" + }, + "env": { + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "string" + } + } + } } } } @@ -1131,14 +1158,14 @@ "x-codeSamples": [ { "lang": "js", - "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.config.update({\n ...\n})" + "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.pty.create({\n ...\n})" } ] } }, - "/config/providers": { + "/pty/{ptyID}": { "get": { - "operationId": "config.providers", + "operationId": "pty.get", "parameters": [ { "in": "query", @@ -1153,35 +1180,36 @@ "schema": { "type": "string" } + }, + { + "in": "path", + "name": "ptyID", + "schema": { + "type": "string", + "pattern": "^pty.*" + }, + "required": true } ], - "summary": "List config providers", - "description": "Get a list of all configured AI providers and their default models.", + "summary": "Get PTY session", + "description": "Retrieve detailed information about a specific pseudo-terminal (PTY) session.", "responses": { "200": { - "description": "List of providers", + "description": "Session info", "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "providers": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Provider" - } - }, - "default": { - "type": "object", - "propertyNames": { - "type": "string" - }, - "additionalProperties": { - "type": "string" - } - } - }, - "required": ["providers", "default"] + "$ref": "#/components/schemas/Pty" + } + } + } + }, + "404": { + "description": "Not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NotFoundError" } } } @@ -1190,14 +1218,12 @@ "x-codeSamples": [ { "lang": "js", - "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.config.providers({\n ...\n})" + "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.pty.get({\n ...\n})" } ] - } - }, - "/experimental/console": { - "get": { - "operationId": "experimental.console.get", + }, + "put": { + "operationId": "pty.update", "parameters": [ { "in": "query", @@ -1212,34 +1238,62 @@ "schema": { "type": "string" } + }, + { + "in": "path", + "name": "ptyID", + "schema": { + "type": "string", + "pattern": "^pty.*" + }, + "required": true } ], - "summary": "Get active Console provider metadata", - "description": "Get the active Console org name and the set of provider IDs managed by that Console org.", + "summary": "Update PTY session", + "description": "Update properties of an existing pseudo-terminal (PTY) session.", "responses": { "200": { - "description": "Active Console provider metadata", + "description": "Updated session", "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "consoleManagedProviders": { - "type": "array", - "items": { - "type": "string" + "$ref": "#/components/schemas/Pty" + } + } + } + }, + "400": { + "description": "Bad request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BadRequestError" + } + } + } + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "size": { + "type": "object", + "properties": { + "rows": { + "type": "number" + }, + "cols": { + "type": "number" } }, - "activeOrgName": { - "type": "string" - }, - "switchableOrgCount": { - "type": "integer", - "minimum": 0, - "maximum": 9007199254740991 - } - }, - "required": ["consoleManagedProviders", "switchableOrgCount"] + "required": ["rows", "cols"] + } } } } @@ -1248,14 +1302,12 @@ "x-codeSamples": [ { "lang": "js", - "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.experimental.console.get({\n ...\n})" + "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.pty.update({\n ...\n})" } ] - } - }, - "/experimental/console/orgs": { - "get": { - "operationId": "experimental.console.listOrgs", + }, + "delete": { + "operationId": "pty.remove", "parameters": [ { "in": "query", @@ -1270,47 +1322,36 @@ "schema": { "type": "string" } + }, + { + "in": "path", + "name": "ptyID", + "schema": { + "type": "string", + "pattern": "^pty.*" + }, + "required": true } ], - "summary": "List switchable Console orgs", - "description": "Get the available Console orgs across logged-in accounts, including the current active org.", + "summary": "Remove PTY session", + "description": "Remove and terminate a specific pseudo-terminal (PTY) session.", "responses": { "200": { - "description": "Switchable Console orgs", + "description": "Session removed", "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "orgs": { - "type": "array", - "items": { - "type": "object", - "properties": { - "accountID": { - "type": "string" - }, - "accountEmail": { - "type": "string" - }, - "accountUrl": { - "type": "string" - }, - "orgID": { - "type": "string" - }, - "orgName": { - "type": "string" - }, - "active": { - "type": "boolean" - } - }, - "required": ["accountID", "accountEmail", "accountUrl", "orgID", "orgName", "active"] - } - } - }, - "required": ["orgs"] + "type": "boolean" + } + } + } + }, + "404": { + "description": "Not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NotFoundError" } } } @@ -1319,14 +1360,14 @@ "x-codeSamples": [ { "lang": "js", - "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.experimental.console.listOrgs({\n ...\n})" + "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.pty.remove({\n ...\n})" } ] } }, - "/experimental/console/switch": { - "post": { - "operationId": "experimental.console.switchOrg", + "/pty/{ptyID}/connect": { + "get": { + "operationId": "pty.connect", "parameters": [ { "in": "query", @@ -1341,13 +1382,22 @@ "schema": { "type": "string" } + }, + { + "in": "path", + "name": "ptyID", + "schema": { + "type": "string", + "pattern": "^pty.*" + }, + "required": true } ], - "summary": "Switch active Console org", - "description": "Persist a new active Console account/org selection for the current local OpenCode state.", + "summary": "Connect to PTY session", + "description": "Establish a WebSocket connection to interact with a pseudo-terminal (PTY) session in real-time.", "responses": { "200": { - "description": "Switch success", + "description": "Connected session", "content": { "application/json": { "schema": { @@ -1355,22 +1405,14 @@ } } } - } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "accountID": { - "type": "string" - }, - "orgID": { - "type": "string" - } - }, - "required": ["accountID", "orgID"] + }, + "404": { + "description": "Not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NotFoundError" + } } } } @@ -1378,14 +1420,14 @@ "x-codeSamples": [ { "lang": "js", - "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.experimental.console.switchOrg({\n ...\n})" + "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.pty.connect({\n ...\n})" } ] } }, - "/experimental/tool/ids": { + "/config": { "get": { - "operationId": "tool.ids", + "operationId": "config.get", "parameters": [ { "in": "query", @@ -1402,25 +1444,15 @@ } } ], - "summary": "List tool IDs", - "description": "Get a list of all available tool IDs, including both built-in tools and dynamically registered tools.", + "summary": "Get configuration", + "description": "Retrieve the current OpenCode configuration settings and preferences.", "responses": { "200": { - "description": "Tool IDs", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ToolIDs" - } - } - } - }, - "400": { - "description": "Bad request", + "description": "Get config info", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/BadRequestError" + "$ref": "#/components/schemas/Config" } } } @@ -1429,14 +1461,12 @@ "x-codeSamples": [ { "lang": "js", - "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.tool.ids({\n ...\n})" + "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.config.get({\n ...\n})" } ] - } - }, - "/experimental/tool": { - "get": { - "operationId": "tool.list", + }, + "patch": { + "operationId": "config.update", "parameters": [ { "in": "query", @@ -1451,33 +1481,17 @@ "schema": { "type": "string" } - }, - { - "in": "query", - "name": "provider", - "schema": { - "type": "string" - }, - "required": true - }, - { - "in": "query", - "name": "model", - "schema": { - "type": "string" - }, - "required": true } ], - "summary": "List tools", - "description": "Get a list of available tools with their JSON schema parameters for a specific provider and model combination.", + "summary": "Update configuration", + "description": "Update OpenCode configuration settings and preferences.", "responses": { "200": { - "description": "Tools", + "description": "Successfully updated config", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ToolList" + "$ref": "#/components/schemas/Config" } } } @@ -1493,17 +1507,26 @@ } } }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Config" + } + } + } + }, "x-codeSamples": [ { "lang": "js", - "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.tool.list({\n ...\n})" + "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.config.update({\n ...\n})" } ] } }, - "/experimental/workspace/adaptor": { + "/config/providers": { "get": { - "operationId": "experimental.workspace.adaptor.list", + "operationId": "config.providers", "parameters": [ { "in": "query", @@ -1520,30 +1543,33 @@ } } ], - "summary": "List workspace adaptors", - "description": "List all available workspace adaptors for the current project.", + "summary": "List config providers", + "description": "Get a list of all configured AI providers and their default models.", "responses": { "200": { - "description": "Workspace adaptors", + "description": "List of providers", "content": { "application/json": { "schema": { - "type": "array", - "items": { - "type": "object", - "properties": { - "type": { - "type": "string" - }, - "name": { + "type": "object", + "properties": { + "providers": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Provider" + } + }, + "default": { + "type": "object", + "propertyNames": { "type": "string" }, - "description": { + "additionalProperties": { "type": "string" } - }, - "required": ["type", "name", "description"] - } + } + }, + "required": ["providers", "default"] } } } @@ -1552,14 +1578,14 @@ "x-codeSamples": [ { "lang": "js", - "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.experimental.workspace.adaptor.list({\n ...\n})" + "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.config.providers({\n ...\n})" } ] } }, - "/experimental/workspace": { - "post": { - "operationId": "experimental.workspace.create", + "/experimental/console": { + "get": { + "operationId": "experimental.console.get", "parameters": [ { "in": "query", @@ -1576,63 +1602,33 @@ } } ], - "summary": "Create workspace", - "description": "Create a workspace for the current project.", + "summary": "Get active Console provider metadata", + "description": "Get the active Console org name and the set of provider IDs managed by that Console org.", "responses": { "200": { - "description": "Workspace created", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Workspace" - } - } - } - }, - "400": { - "description": "Bad request", + "description": "Active Console provider metadata", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/BadRequestError" - } - } - } - } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "id": { - "type": "string", - "pattern": "^wrk.*" - }, - "type": { - "type": "string" - }, - "branch": { - "anyOf": [ - { + "type": "object", + "properties": { + "consoleManagedProviders": { + "type": "array", + "items": { "type": "string" - }, - { - "type": "null" } - ] + }, + "activeOrgName": { + "type": "string" + }, + "switchableOrgCount": { + "type": "integer", + "minimum": 0, + "maximum": 9007199254740991 + } }, - "extra": { - "anyOf": [ - {}, - { - "type": "null" - } - ] - } - }, - "required": ["type", "branch", "extra"] + "required": ["consoleManagedProviders", "switchableOrgCount"] + } } } } @@ -1640,12 +1636,14 @@ "x-codeSamples": [ { "lang": "js", - "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.experimental.workspace.create({\n ...\n})" + "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.experimental.console.get({\n ...\n})" } ] - }, + } + }, + "/experimental/console/orgs": { "get": { - "operationId": "experimental.workspace.list", + "operationId": "experimental.console.listOrgs", "parameters": [ { "in": "query", @@ -1662,18 +1660,45 @@ } } ], - "summary": "List workspaces", - "description": "List all workspaces.", + "summary": "List switchable Console orgs", + "description": "Get the available Console orgs across logged-in accounts, including the current active org.", "responses": { "200": { - "description": "Workspaces", + "description": "Switchable Console orgs", "content": { "application/json": { "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Workspace" - } + "type": "object", + "properties": { + "orgs": { + "type": "array", + "items": { + "type": "object", + "properties": { + "accountID": { + "type": "string" + }, + "accountEmail": { + "type": "string" + }, + "accountUrl": { + "type": "string" + }, + "orgID": { + "type": "string" + }, + "orgName": { + "type": "string" + }, + "active": { + "type": "boolean" + } + }, + "required": ["accountID", "accountEmail", "accountUrl", "orgID", "orgName", "active"] + } + } + }, + "required": ["orgs"] } } } @@ -1682,14 +1707,14 @@ "x-codeSamples": [ { "lang": "js", - "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.experimental.workspace.list({\n ...\n})" + "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.experimental.console.listOrgs({\n ...\n})" } ] } }, - "/experimental/workspace/status": { - "get": { - "operationId": "experimental.workspace.status", + "/experimental/console/switch": { + "post": { + "operationId": "experimental.console.switchOrg", "parameters": [ { "in": "query", @@ -1706,48 +1731,49 @@ } } ], - "summary": "Workspace status", - "description": "Get connection status for workspaces in the current project.", + "summary": "Switch active Console org", + "description": "Persist a new active Console account/org selection for the current local OpenCode state.", "responses": { "200": { - "description": "Workspace status", + "description": "Switch success", "content": { "application/json": { "schema": { - "type": "array", - "items": { - "type": "object", - "properties": { - "workspaceID": { - "type": "string", - "pattern": "^wrk.*" - }, - "status": { - "type": "string", - "enum": ["connected", "connecting", "disconnected", "error"] - }, - "error": { - "type": "string" - } - }, - "required": ["workspaceID", "status"] - } + "type": "boolean" } } } } }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "accountID": { + "type": "string" + }, + "orgID": { + "type": "string" + } + }, + "required": ["accountID", "orgID"] + } + } + } + }, "x-codeSamples": [ { "lang": "js", - "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.experimental.workspace.status({\n ...\n})" + "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.experimental.console.switchOrg({\n ...\n})" } ] } }, - "/experimental/workspace/{id}": { - "delete": { - "operationId": "experimental.workspace.remove", + "/experimental/tool/ids": { + "get": { + "operationId": "tool.ids", "parameters": [ { "in": "query", @@ -1762,26 +1788,17 @@ "schema": { "type": "string" } - }, - { - "in": "path", - "name": "id", - "schema": { - "type": "string", - "pattern": "^wrk.*" - }, - "required": true } ], - "summary": "Remove workspace", - "description": "Remove an existing workspace.", + "summary": "List tool IDs", + "description": "Get a list of all available tool IDs, including both built-in tools and dynamically registered tools.", "responses": { "200": { - "description": "Workspace removed", + "description": "Tool IDs", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Workspace" + "$ref": "#/components/schemas/ToolIDs" } } } @@ -1800,14 +1817,14 @@ "x-codeSamples": [ { "lang": "js", - "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.experimental.workspace.remove({\n ...\n})" + "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.tool.ids({\n ...\n})" } ] } }, - "/experimental/workspace/{id}/session-restore": { - "post": { - "operationId": "experimental.workspace.sessionRestore", + "/experimental/tool": { + "get": { + "operationId": "tool.list", "parameters": [ { "in": "query", @@ -1824,32 +1841,31 @@ } }, { - "in": "path", - "name": "id", + "in": "query", + "name": "provider", "schema": { - "type": "string", - "pattern": "^wrk.*" + "type": "string" + }, + "required": true + }, + { + "in": "query", + "name": "model", + "schema": { + "type": "string" }, "required": true } ], - "summary": "Restore session into workspace", - "description": "Replay a session's sync events into the target workspace in batches.", + "summary": "List tools", + "description": "Get a list of available tools with their JSON schema parameters for a specific provider and model combination.", "responses": { "200": { - "description": "Session replay started", + "description": "Tools", "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "total": { - "type": "integer", - "minimum": 0, - "maximum": 9007199254740991 - } - }, - "required": ["total"] + "$ref": "#/components/schemas/ToolList" } } } @@ -1865,26 +1881,10 @@ } } }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "sessionID": { - "type": "string", - "pattern": "^ses.*" - } - }, - "required": ["sessionID"] - } - } - } - }, "x-codeSamples": [ { "lang": "js", - "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.experimental.workspace.sessionRestore({\n ...\n})" + "source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.tool.list({\n ...\n})" } ] } @@ -12003,6 +12003,53 @@ } ] }, + "Workspace": { + "type": "object", + "properties": { + "id": { + "type": "string", + "pattern": "^wrk.*" + }, + "type": { + "type": "string" + }, + "name": { + "type": "string" + }, + "branch": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "directory": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "extra": { + "anyOf": [ + {}, + { + "type": "null" + } + ] + }, + "projectID": { + "type": "string" + } + }, + "required": ["id", "type", "name", "branch", "directory", "extra", "projectID"] + }, "NotFoundError": { "type": "object", "properties": { @@ -12309,53 +12356,6 @@ "$ref": "#/components/schemas/ToolListItem" } }, - "Workspace": { - "type": "object", - "properties": { - "id": { - "type": "string", - "pattern": "^wrk.*" - }, - "type": { - "type": "string" - }, - "name": { - "type": "string" - }, - "branch": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ] - }, - "directory": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ] - }, - "extra": { - "anyOf": [ - {}, - { - "type": "null" - } - ] - }, - "projectID": { - "type": "string" - } - }, - "required": ["id", "type", "name", "branch", "directory", "extra", "projectID"] - }, "Worktree": { "type": "object", "properties": {