From c1763e2b64b434eed47b4f0d1000f1b4f5d34080 Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Mon, 24 Aug 2026 17:36:02 -0400 Subject: [PATCH] fix(server): make text generation locationless (#44773) --- packages/client/src/effect/api/api.ts | 6 +- .../client/src/effect/generated/client.ts | 5 +- .../client/src/promise/generated/client.ts | 1 - .../client/src/promise/generated/types.ts | 3 - packages/client/test/promise.test.ts | 15 ++ packages/protocol/openapi.json | 123 +++++---- packages/protocol/src/api.ts | 4 +- packages/protocol/src/groups/generate.ts | 20 +- packages/server/src/handlers/generate.ts | 9 +- packages/server/test/generate.test.ts | 88 +++++++ packages/www/openapi.json | 238 +++++++----------- packages/www/public/openapi.json | 238 +++++++----------- 12 files changed, 387 insertions(+), 363 deletions(-) create mode 100644 packages/server/test/generate.test.ts diff --git a/packages/client/src/effect/api/api.ts b/packages/client/src/effect/api/api.ts index 74313f14e6d..e08ab950bf2 100644 --- a/packages/client/src/effect/api/api.ts +++ b/packages/client/src/effect/api/api.ts @@ -1108,11 +1108,7 @@ export interface ModelApi { readonly default: ModelDefaultOperation } -export type GenerateTextInput = { - readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined - readonly prompt: string - readonly model?: Model.Ref | undefined -} +export type GenerateTextInput = { readonly prompt: string; readonly model?: Model.Ref | undefined } export type GenerateTextOutput = { readonly text: string } export type GenerateTextOperation = (input: GenerateTextInput) => Effect.Effect diff --git a/packages/client/src/effect/generated/client.ts b/packages/client/src/effect/generated/client.ts index 962aae8ad80..81ae3209649 100644 --- a/packages/client/src/effect/generated/client.ts +++ b/packages/client/src/effect/generated/client.ts @@ -719,10 +719,7 @@ const adaptGroupModel = (raw: RawClient["server.model"]) => ({ const EndpointGenerateText = (raw: RawClient["server.generate"]) => (input: GenerateTextInput) => preserveEffect()( - raw["generate.text"]({ - query: { location: input["location"] }, - payload: { prompt: input["prompt"], model: input["model"] }, - }).pipe( + raw["generate.text"]({ payload: { prompt: input["prompt"], model: input["model"] } }).pipe( Effect.mapError(mapClientError), Effect.map((value) => value.data), ), diff --git a/packages/client/src/promise/generated/client.ts b/packages/client/src/promise/generated/client.ts index 47127fc2e5c..539504647c2 100644 --- a/packages/client/src/promise/generated/client.ts +++ b/packages/client/src/promise/generated/client.ts @@ -977,7 +977,6 @@ export function make(options: ClientOptions) { { method: "POST", path: `/api/generate`, - query: { location: input["location"] }, body: { prompt: input["prompt"], model: input["model"] }, successStatus: 200, declaredStatuses: [400, 503, 401], diff --git a/packages/client/src/promise/generated/types.ts b/packages/client/src/promise/generated/types.ts index 35d7defcc4a..8e57bab7bac 100644 --- a/packages/client/src/promise/generated/types.ts +++ b/packages/client/src/promise/generated/types.ts @@ -4029,9 +4029,6 @@ export type ModelDefaultOutput = { } export type GenerateTextInput = { - readonly location?: { - readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined - }["location"] readonly prompt: { readonly prompt: string readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null diff --git a/packages/client/test/promise.test.ts b/packages/client/test/promise.test.ts index f06a63bb607..d1df007910c 100644 --- a/packages/client/test/promise.test.ts +++ b/packages/client/test/promise.test.ts @@ -82,6 +82,21 @@ test("config.get returns ordered config entries for a location", async () => { expect(request?.url).toBe("http://localhost:3000/api/config?location%5Bdirectory%5D=%2Ftmp%2Fproject") }) +test("generate.text uses the locationless public contract", async () => { + let request: Request | undefined + const client = OpenCode.make({ + baseUrl: "http://localhost:3000", + fetch: async (input, init) => { + request = input instanceof Request ? input : new Request(input, init) + return Response.json({ data: { text: "pong" } }) + }, + }) + + expect(await client.generate.text({ prompt: "ping" })).toEqual({ text: "pong" }) + expect(request?.url).toBe("http://localhost:3000/api/generate") + expect(await request?.json()).toEqual({ prompt: "ping" }) +}) + test("websearch.query uses the public HTTP contract", async () => { let request: Request | undefined const client = OpenCode.make({ diff --git a/packages/protocol/openapi.json b/packages/protocol/openapi.json index f8a6f27921a..faaeb1a9bca 100644 --- a/packages/protocol/openapi.json +++ b/packages/protocol/openapi.json @@ -4448,48 +4448,7 @@ "post": { "tags": ["generate"], "operationId": "v2.generate.text", - "parameters": [ - { - "name": "location", - "in": "query", - "schema": { - "anyOf": [ - { - "type": "object", - "properties": { - "directory": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ] - }, - "workspace": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false - }, - { - "type": "null" - } - ] - }, - "required": false, - "style": "deepObject", - "explode": true - } - ], + "parameters": [], "security": [], "responses": { "200": { @@ -4540,7 +4499,7 @@ } } }, - "description": "Run one stateless model generation at the requested location and return the assistant text. Uses the location's default model when none is specified.", + "description": "Run one stateless model generation using the server's base configuration and return the assistant text. Uses the base configuration's default model when none is specified.", "summary": "Generate text", "requestBody": { "content": { @@ -10655,6 +10614,68 @@ "summary": "Refresh worktrees" } }, + "/api/workspace/{workspaceID}": { + "delete": { + "tags": ["workspace"], + "operationId": "v2.workspace.destroy", + "parameters": [ + { + "name": "workspaceID", + "in": "path", + "schema": { + "type": "string", + "pattern": "^wrk" + }, + "required": true + } + ], + "security": [], + "responses": { + "200": { + "description": "Reports whether this request destroyed an existing workspace.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WorkspaceDestroyResult" + } + } + } + }, + "400": { + "description": "InvalidRequestError", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/InvalidRequestErrorEncoded" + } + } + } + }, + "401": { + "description": "UnauthorizedError", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UnauthorizedErrorEncoded" + } + } + } + }, + "500": { + "description": "UnknownError", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UnknownErrorEncoded" + } + } + } + } + }, + "description": "Make a workspace not exist. This operation is idempotent: an already-missing workspace succeeds with `destroyed: false`, while a workspace removed by this request returns `destroyed: true`.", + "summary": "Destroy workspace" + } + }, "/api/vcs": { "get": { "tags": ["vcs"], @@ -17093,6 +17114,18 @@ "required": ["url", "time"], "additionalProperties": false }, + "WorkspaceDestroyResult": { + "type": "object", + "properties": { + "destroyed": { + "type": "boolean", + "description": "True when this request transitioned the workspace from existing to destroyed." + } + }, + "required": ["destroyed"], + "additionalProperties": false, + "description": "Reports whether this request destroyed an existing workspace." + }, "Worktree.Directory": { "type": "object", "properties": { @@ -17249,6 +17282,10 @@ "name": "worktree", "description": "Project worktree management routes." }, + { + "name": "workspace", + "description": "Workspace lifecycle routes." + }, { "name": "vcs", "description": "Location-scoped version control routes." diff --git a/packages/protocol/src/api.ts b/packages/protocol/src/api.ts index 0f8c6ffa538..6606189a6bb 100644 --- a/packages/protocol/src/api.ts +++ b/packages/protocol/src/api.ts @@ -39,7 +39,6 @@ type LocationGroups = | HttpApiGroup.AddMiddleware | HttpApiGroup.AddMiddleware | HttpApiGroup.AddMiddleware - | HttpApiGroup.AddMiddleware | HttpApiGroup.AddMiddleware | HttpApiGroup.AddMiddleware | HttpApiGroup.AddMiddleware @@ -88,6 +87,7 @@ type ApiGroups< | typeof MigrationGroup | typeof WorktreeGroup | typeof WorkspaceGroup + | typeof GenerateGroup | LocationGroups | FormGroups | SessionGroups @@ -155,7 +155,7 @@ const makeApiFromGroup = < .add(makeSessionGroup(sessionLocationMiddleware)) .add(MessageGroup) .add(ModelGroup.middleware(locationMiddleware)) - .add(GenerateGroup.middleware(locationMiddleware)) + .add(GenerateGroup) .add(ProviderGroup.middleware(locationMiddleware)) .add(IntegrationGroup.middleware(locationMiddleware)) .add(McpGroup.middleware(locationMiddleware)) diff --git a/packages/protocol/src/groups/generate.ts b/packages/protocol/src/groups/generate.ts index fcf7e6f2655..e4280d81076 100644 --- a/packages/protocol/src/groups/generate.ts +++ b/packages/protocol/src/groups/generate.ts @@ -2,12 +2,10 @@ import { Model } from "@opencode-ai/schema/model" import { Schema } from "effect" import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi" import { InvalidRequestError, ServiceUnavailableError } from "../errors.js" -import { LocationQuery, locationQueryOpenApi } from "./location.js" export const GenerateGroup = HttpApiGroup.make("server.generate") .add( HttpApiEndpoint.post("generate.text", "/api/generate", { - query: LocationQuery, payload: Schema.Struct({ prompt: Schema.String, model: Model.Ref.pipe(Schema.optional), @@ -16,16 +14,14 @@ export const GenerateGroup = HttpApiGroup.make("server.generate") data: Schema.Struct({ text: Schema.String }), }).annotate({ identifier: "GenerateTextResponse" }), error: [InvalidRequestError, ServiceUnavailableError], - }) - .annotateMerge(locationQueryOpenApi) - .annotateMerge( - OpenApi.annotations({ - identifier: "v2.generate.text", - summary: "Generate text", - description: - "Run one stateless model generation at the requested location and return the assistant text. Uses the location's default model when none is specified.", - }), - ), + }).annotateMerge( + OpenApi.annotations({ + identifier: "v2.generate.text", + summary: "Generate text", + description: + "Run one stateless model generation using the server's base configuration and return the assistant text. Uses the base configuration's default model when none is specified.", + }), + ), ) .annotateMerge( OpenApi.annotations({ diff --git a/packages/server/src/handlers/generate.ts b/packages/server/src/handlers/generate.ts index f190aa01656..620511b82be 100644 --- a/packages/server/src/handlers/generate.ts +++ b/packages/server/src/handlers/generate.ts @@ -1,15 +1,22 @@ import { Generate } from "@opencode-ai/core/generate" +import { Location } from "@opencode-ai/core/location" +import { LocationServiceMap } from "@opencode-ai/core/location-services" +import { AbsolutePath } from "@opencode-ai/core/schema" import { InvalidRequestError, ServiceUnavailableError } from "@opencode-ai/protocol/errors" +import { Global } from "@opencode-ai/util/global" import { Effect } from "effect" import { HttpApiBuilder } from "effect/unstable/httpapi" import { Api } from "../api" export const GenerateHandler = HttpApiBuilder.group(Api, "server.generate", (handlers) => Effect.gen(function* () { + const global = yield* Global.Service + const locations = yield* LocationServiceMap.Service + const services = locations.get(Location.Ref.make({ directory: AbsolutePath.make(global.config) })) return handlers.handle( "generate.text", Effect.fn("server.generate.text")(function* (request) { - const generate = yield* Generate.Service + const generate = yield* Generate.Service.pipe(Effect.provide(services)) const text = yield* generate .text(request.payload) .pipe( diff --git a/packages/server/test/generate.test.ts b/packages/server/test/generate.test.ts new file mode 100644 index 00000000000..ffa39713df9 --- /dev/null +++ b/packages/server/test/generate.test.ts @@ -0,0 +1,88 @@ +import fs from "node:fs/promises" +import path from "node:path" +import { expect } from "bun:test" +import { Config } from "@opencode-ai/core/config" +import { Generate } from "@opencode-ai/core/generate" +import { makeLocationNode } from "@opencode-ai/util/effect/app-node" +import { Effect, Layer, Predicate } from "effect" +import { tmpdir } from "../../core/test/fixture/tmpdir" +import { it } from "../../core/test/lib/effect" +import { ServerFetch } from "../src/fetch" + +const generate = makeLocationNode({ + service: Generate.Service, + layer: Layer.effect( + Generate.Service, + Effect.gen(function* () { + const config = yield* Config.Service + return Generate.Service.of({ + text: () => + config.entries().pipe( + Effect.map((entries) => + JSON.stringify({ + model: Config.latest(entries, "model"), + }), + ), + ), + }) + }), + ), + deps: [Config.node], +}) + +it.live("uses base configuration without depending on process.cwd()", () => + Effect.acquireUseRelease( + Effect.promise(() => tmpdir("opencode-generate-endpoint-")), + (tmp) => + Effect.gen(function* () { + const global = path.join(tmp.path, "global") + const project = path.join(tmp.path, "project") + yield* Effect.promise(() => Promise.all([fs.mkdir(global), fs.mkdir(project)])) + yield* Effect.promise(() => + Promise.all([ + fs.writeFile(path.join(global, "opencode.json"), JSON.stringify({ model: "base/default" })), + fs.writeFile(path.join(project, "opencode.json"), JSON.stringify({ model: "project/default" })), + ]), + ) + const handler = yield* ServerFetch.make( + { + database: { path: ":memory:" }, + config: { directory: global }, + fs: { filewatcher: false }, + }, + { overrides: [[Generate.node, generate]] }, + ) + + expect(global).not.toBe(process.cwd()) + expect(yield* request(handler, new URL("http://opencode.local/api/generate"))).toEqual({ + model: { providerID: "base", model: "default" }, + }) + + const legacy = new URL("http://opencode.local/api/generate") + legacy.searchParams.set("location[directory]", project) + expect(yield* request(handler, legacy)).toEqual({ + model: { providerID: "base", model: "default" }, + }) + }), + (tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()), + ), +) + +function request(handler: (request: Request) => Promise, url: URL) { + return Effect.promise(() => + handler( + new Request(url, { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ prompt: "hello" }), + }), + ).then(async (response) => { + expect(response.status).toBe(200) + const body: unknown = await response.json() + if (!Predicate.isObject(body) || !Predicate.isObject(body.data) || typeof body.data.text !== "string") + throw new Error("Expected a generate response") + const result: unknown = JSON.parse(body.data.text) + return result + }), + ) +} diff --git a/packages/www/openapi.json b/packages/www/openapi.json index 9a073b2d8c2..6a2f34241fd 100644 --- a/packages/www/openapi.json +++ b/packages/www/openapi.json @@ -1915,36 +1915,15 @@ ], "security": [], "responses": { - "200": { - "description": "Success", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "data": { - "$ref": "#/components/schemas/Session.Inbox.User" - } - }, - "required": ["data"], - "additionalProperties": false - } - } - } + "204": { + "description": "" }, "400": { "description": "InvalidRequestError", "content": { "application/json": { "schema": { - "anyOf": [ - { - "$ref": "#/components/schemas/InvalidRequestErrorEncoded" - }, - { - "$ref": "#/components/schemas/InvalidRequestErrorEncoded" - } - ] + "$ref": "#/components/schemas/InvalidRequestErrorEncoded" } } } @@ -1979,28 +1958,18 @@ } } }, - "409": { - "description": "ConflictError", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ConflictErrorEncoded" - } - } - } - }, "500": { - "description": "CommandEvaluationError", + "description": "CommandExecutionError", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/CommandEvaluationErrorEncoded" + "$ref": "#/components/schemas/CommandExecutionErrorEncoded" } } } } }, - "description": "Resolve a slash command into prompt input, admit it durably, and schedule execution unless resume is false.", + "description": "Execute a slash command callback immediately.", "summary": "Run command", "requestBody": { "content": { @@ -2008,49 +1977,11 @@ "schema": { "type": "object", "properties": { - "id": { - "anyOf": [ - { - "type": "string", - "pattern": "^msg_" - }, - { - "type": "null" - } - ] - }, "command": { "type": "string" }, - "arguments": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ] - }, - "agent": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ] - }, - "model": { - "anyOf": [ - { - "$ref": "#/components/schemas/Model.Ref" - }, - { - "type": "null" - } - ] + "text": { + "type": "string" }, "files": { "type": "array", @@ -2079,19 +2010,9 @@ "type": "null" } ] - }, - "resume": { - "anyOf": [ - { - "type": "boolean" - }, - { - "type": "null" - } - ] } }, - "required": ["command"], + "required": ["command", "text"], "additionalProperties": false } } @@ -4520,48 +4441,7 @@ "post": { "tags": ["generate"], "operationId": "v2.generate.text", - "parameters": [ - { - "name": "location", - "in": "query", - "schema": { - "anyOf": [ - { - "type": "object", - "properties": { - "directory": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ] - }, - "workspace": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false - }, - { - "type": "null" - } - ] - }, - "required": false, - "style": "deepObject", - "explode": true - } - ], + "parameters": [], "security": [], "responses": { "200": { @@ -4612,7 +4492,7 @@ } } }, - "description": "Run one stateless model generation at the requested location and return the assistant text. Uses the location's default model when none is specified.", + "description": "Run one stateless model generation using the server's base configuration and return the assistant text. Uses the base configuration's default model when none is specified.", "summary": "Generate text", "requestBody": { "content": { @@ -10727,6 +10607,68 @@ "summary": "Refresh worktrees" } }, + "/api/workspace/{workspaceID}": { + "delete": { + "tags": ["workspace"], + "operationId": "v2.workspace.destroy", + "parameters": [ + { + "name": "workspaceID", + "in": "path", + "schema": { + "type": "string", + "pattern": "^wrk" + }, + "required": true + } + ], + "security": [], + "responses": { + "200": { + "description": "Reports whether this request destroyed an existing workspace.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WorkspaceDestroyResult" + } + } + } + }, + "400": { + "description": "InvalidRequestError", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/InvalidRequestErrorEncoded" + } + } + } + }, + "401": { + "description": "UnauthorizedError", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UnauthorizedErrorEncoded" + } + } + } + }, + "500": { + "description": "UnknownError", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UnknownErrorEncoded" + } + } + } + } + }, + "description": "Make a workspace not exist. This operation is idempotent: an already-missing workspace succeeds with `destroyed: false`, while a workspace removed by this request returns `destroyed: true`.", + "summary": "Destroy workspace" + } + }, "/api/vcs": { "get": { "tags": ["vcs"], @@ -11658,31 +11600,19 @@ "name": { "type": "string" }, - "template": { - "type": "string" - }, "description": { "type": "string" - }, - "agent": { - "type": "string" - }, - "model": { - "$ref": "#/components/schemas/Model.Ref" - }, - "subtask": { - "type": "boolean" } }, - "required": ["name", "template"], + "required": ["name"], "additionalProperties": false }, - "CommandEvaluationErrorEncoded": { + "CommandExecutionErrorEncoded": { "type": "object", "properties": { "_tag": { "type": "string", - "enum": ["CommandEvaluationError"] + "enum": ["CommandExecutionError"] }, "command": { "type": "string" @@ -17166,6 +17096,18 @@ "required": ["url", "time"], "additionalProperties": false }, + "WorkspaceDestroyResult": { + "type": "object", + "properties": { + "destroyed": { + "type": "boolean", + "description": "True when this request transitioned the workspace from existing to destroyed." + } + }, + "required": ["destroyed"], + "additionalProperties": false, + "description": "Reports whether this request destroyed an existing workspace." + }, "Worktree.Directory": { "type": "object", "properties": { @@ -17322,6 +17264,10 @@ "name": "worktree", "description": "Project worktree management routes." }, + { + "name": "workspace", + "description": "Workspace lifecycle routes." + }, { "name": "vcs", "description": "Location-scoped version control routes." diff --git a/packages/www/public/openapi.json b/packages/www/public/openapi.json index 9a073b2d8c2..6a2f34241fd 100644 --- a/packages/www/public/openapi.json +++ b/packages/www/public/openapi.json @@ -1915,36 +1915,15 @@ ], "security": [], "responses": { - "200": { - "description": "Success", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "data": { - "$ref": "#/components/schemas/Session.Inbox.User" - } - }, - "required": ["data"], - "additionalProperties": false - } - } - } + "204": { + "description": "" }, "400": { "description": "InvalidRequestError", "content": { "application/json": { "schema": { - "anyOf": [ - { - "$ref": "#/components/schemas/InvalidRequestErrorEncoded" - }, - { - "$ref": "#/components/schemas/InvalidRequestErrorEncoded" - } - ] + "$ref": "#/components/schemas/InvalidRequestErrorEncoded" } } } @@ -1979,28 +1958,18 @@ } } }, - "409": { - "description": "ConflictError", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ConflictErrorEncoded" - } - } - } - }, "500": { - "description": "CommandEvaluationError", + "description": "CommandExecutionError", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/CommandEvaluationErrorEncoded" + "$ref": "#/components/schemas/CommandExecutionErrorEncoded" } } } } }, - "description": "Resolve a slash command into prompt input, admit it durably, and schedule execution unless resume is false.", + "description": "Execute a slash command callback immediately.", "summary": "Run command", "requestBody": { "content": { @@ -2008,49 +1977,11 @@ "schema": { "type": "object", "properties": { - "id": { - "anyOf": [ - { - "type": "string", - "pattern": "^msg_" - }, - { - "type": "null" - } - ] - }, "command": { "type": "string" }, - "arguments": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ] - }, - "agent": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ] - }, - "model": { - "anyOf": [ - { - "$ref": "#/components/schemas/Model.Ref" - }, - { - "type": "null" - } - ] + "text": { + "type": "string" }, "files": { "type": "array", @@ -2079,19 +2010,9 @@ "type": "null" } ] - }, - "resume": { - "anyOf": [ - { - "type": "boolean" - }, - { - "type": "null" - } - ] } }, - "required": ["command"], + "required": ["command", "text"], "additionalProperties": false } } @@ -4520,48 +4441,7 @@ "post": { "tags": ["generate"], "operationId": "v2.generate.text", - "parameters": [ - { - "name": "location", - "in": "query", - "schema": { - "anyOf": [ - { - "type": "object", - "properties": { - "directory": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ] - }, - "workspace": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false - }, - { - "type": "null" - } - ] - }, - "required": false, - "style": "deepObject", - "explode": true - } - ], + "parameters": [], "security": [], "responses": { "200": { @@ -4612,7 +4492,7 @@ } } }, - "description": "Run one stateless model generation at the requested location and return the assistant text. Uses the location's default model when none is specified.", + "description": "Run one stateless model generation using the server's base configuration and return the assistant text. Uses the base configuration's default model when none is specified.", "summary": "Generate text", "requestBody": { "content": { @@ -10727,6 +10607,68 @@ "summary": "Refresh worktrees" } }, + "/api/workspace/{workspaceID}": { + "delete": { + "tags": ["workspace"], + "operationId": "v2.workspace.destroy", + "parameters": [ + { + "name": "workspaceID", + "in": "path", + "schema": { + "type": "string", + "pattern": "^wrk" + }, + "required": true + } + ], + "security": [], + "responses": { + "200": { + "description": "Reports whether this request destroyed an existing workspace.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WorkspaceDestroyResult" + } + } + } + }, + "400": { + "description": "InvalidRequestError", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/InvalidRequestErrorEncoded" + } + } + } + }, + "401": { + "description": "UnauthorizedError", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UnauthorizedErrorEncoded" + } + } + } + }, + "500": { + "description": "UnknownError", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UnknownErrorEncoded" + } + } + } + } + }, + "description": "Make a workspace not exist. This operation is idempotent: an already-missing workspace succeeds with `destroyed: false`, while a workspace removed by this request returns `destroyed: true`.", + "summary": "Destroy workspace" + } + }, "/api/vcs": { "get": { "tags": ["vcs"], @@ -11658,31 +11600,19 @@ "name": { "type": "string" }, - "template": { - "type": "string" - }, "description": { "type": "string" - }, - "agent": { - "type": "string" - }, - "model": { - "$ref": "#/components/schemas/Model.Ref" - }, - "subtask": { - "type": "boolean" } }, - "required": ["name", "template"], + "required": ["name"], "additionalProperties": false }, - "CommandEvaluationErrorEncoded": { + "CommandExecutionErrorEncoded": { "type": "object", "properties": { "_tag": { "type": "string", - "enum": ["CommandEvaluationError"] + "enum": ["CommandExecutionError"] }, "command": { "type": "string" @@ -17166,6 +17096,18 @@ "required": ["url", "time"], "additionalProperties": false }, + "WorkspaceDestroyResult": { + "type": "object", + "properties": { + "destroyed": { + "type": "boolean", + "description": "True when this request transitioned the workspace from existing to destroyed." + } + }, + "required": ["destroyed"], + "additionalProperties": false, + "description": "Reports whether this request destroyed an existing workspace." + }, "Worktree.Directory": { "type": "object", "properties": { @@ -17322,6 +17264,10 @@ "name": "worktree", "description": "Project worktree management routes." }, + { + "name": "workspace", + "description": "Workspace lifecycle routes." + }, { "name": "vcs", "description": "Location-scoped version control routes."