mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
fix(server): report blocked location folders as 403
This commit is contained in:
parent
a6212cb1b5
commit
8c8e340c70
15 changed files with 1190 additions and 162 deletions
178
packages/client/src/promise/generated/client.ts
generated
178
packages/client/src/promise/generated/client.ts
generated
|
|
@ -488,7 +488,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/location`,
|
||||
query: { location: input?.["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -513,7 +513,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/agent`,
|
||||
query: { location: input?.["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404, 503],
|
||||
declaredStatuses: [400, 401, 403, 404, 503],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -525,7 +525,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/agent/${encodeURIComponent(input.agentID)}`,
|
||||
query: { location: input["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -539,7 +539,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/plugin`,
|
||||
query: { location: input?.["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -551,7 +551,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/plugin/gui`,
|
||||
query: { location: input["location"], id: input["id"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -564,7 +564,7 @@ export function make(options: ClientOptions) {
|
|||
query: { location: input?.["location"] },
|
||||
body: { target: input?.["target"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -577,7 +577,7 @@ export function make(options: ClientOptions) {
|
|||
query: { location: input["location"] },
|
||||
body: { targets: input["targets"] },
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404, 503],
|
||||
declaredStatuses: [400, 401, 403, 404, 503],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -708,7 +708,7 @@ export function make(options: ClientOptions) {
|
|||
archived: input["archived"],
|
||||
},
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -741,7 +741,7 @@ export function make(options: ClientOptions) {
|
|||
resume: input["resume"],
|
||||
},
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404, 409],
|
||||
declaredStatuses: [400, 401, 403, 404, 409],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -760,7 +760,7 @@ export function make(options: ClientOptions) {
|
|||
delivery: input["delivery"],
|
||||
},
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404, 500],
|
||||
declaredStatuses: [400, 401, 403, 404, 500],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -779,7 +779,7 @@ export function make(options: ClientOptions) {
|
|||
resume: input["resume"],
|
||||
},
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404, 409],
|
||||
declaredStatuses: [400, 401, 403, 404, 409],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -791,7 +791,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/session/${encodeURIComponent(input.sessionID)}/shell`,
|
||||
body: { id: input["id"], command: input["command"] },
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -803,7 +803,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/session/${encodeURIComponent(input.sessionID)}/compact`,
|
||||
body: { id: input["id"], delivery: input["delivery"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404, 409],
|
||||
declaredStatuses: [400, 401, 403, 404, 409],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -816,7 +816,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/session/${encodeURIComponent(input.sessionID)}/revert/stage`,
|
||||
body: { messageID: input["messageID"], files: input["files"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404, 409, 500],
|
||||
declaredStatuses: [400, 401, 403, 404, 409, 500],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -827,7 +827,7 @@ export function make(options: ClientOptions) {
|
|||
method: "DELETE",
|
||||
path: `/api/session/${encodeURIComponent(input.sessionID)}/revert`,
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404, 409, 500],
|
||||
declaredStatuses: [400, 401, 403, 404, 409, 500],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -862,7 +862,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/session/${encodeURIComponent(input.sessionID)}/diff`,
|
||||
query: { from: input["from"], to: input["to"], context: input["context"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404, 500],
|
||||
declaredStatuses: [400, 401, 403, 404, 500],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -910,7 +910,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/session/${encodeURIComponent(input.sessionID)}/generate`,
|
||||
body: { prompt: input["prompt"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404, 503],
|
||||
declaredStatuses: [400, 401, 403, 404, 503],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -958,7 +958,7 @@ export function make(options: ClientOptions) {
|
|||
method: "GET",
|
||||
path: `/api/session/${encodeURIComponent(input.sessionID)}/form`,
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -970,7 +970,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/session/${encodeURIComponent(input.sessionID)}/form`,
|
||||
body: { id: input["id"], title: input["title"], metadata: input["metadata"], fields: input["fields"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404, 409],
|
||||
declaredStatuses: [400, 401, 403, 404, 409],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -981,7 +981,7 @@ export function make(options: ClientOptions) {
|
|||
method: "GET",
|
||||
path: `/api/session/${encodeURIComponent(input.sessionID)}/form/${encodeURIComponent(input.formID)}`,
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -993,7 +993,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/session/${encodeURIComponent(input.sessionID)}/form/${encodeURIComponent(input.formID)}/reply`,
|
||||
body: { answer: input["answer"] },
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404, 409],
|
||||
declaredStatuses: [400, 401, 403, 404, 409],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1005,7 +1005,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/session/${encodeURIComponent(input.sessionID)}/form/${encodeURIComponent(input.formID)}`,
|
||||
query: { message: input["message"] },
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404, 409],
|
||||
declaredStatuses: [400, 401, 403, 404, 409],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1087,7 +1087,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/experimental/session/${encodeURIComponent(input.sessionID)}/skill`,
|
||||
body: { id: input["id"], resume: input["resume"] },
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1165,7 +1165,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/experimental/generate/text`,
|
||||
body: { prompt: input["prompt"], model: input["model"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404, 422, 502, 503],
|
||||
declaredStatuses: [400, 401, 403, 404, 422, 502, 503],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1184,7 +1184,7 @@ export function make(options: ClientOptions) {
|
|||
resolution: input["resolution"],
|
||||
},
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404, 422, 502, 503],
|
||||
declaredStatuses: [400, 401, 403, 404, 422, 502, 503],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1196,7 +1196,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/experimental/generate/decisions`,
|
||||
body: { model: input["model"], input: input["input"], questions: input["questions"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404, 422, 502, 503],
|
||||
declaredStatuses: [400, 401, 403, 404, 422, 502, 503],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1209,7 +1209,7 @@ export function make(options: ClientOptions) {
|
|||
method: "GET",
|
||||
path: `/api/experimental/voice/models`,
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404, 503],
|
||||
declaredStatuses: [400, 401, 403, 404, 503],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1221,7 +1221,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/experimental/voice/session`,
|
||||
body: { model: input["model"], session: input["session"], transport: input["transport"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404, 503],
|
||||
declaredStatuses: [400, 401, 403, 404, 503],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1237,7 +1237,7 @@ export function make(options: ClientOptions) {
|
|||
query: { location: input["location"] },
|
||||
body: { url: input["url"] },
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1253,7 +1253,7 @@ export function make(options: ClientOptions) {
|
|||
query: { location: input["location"] },
|
||||
body: { config: input["config"] },
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1265,7 +1265,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/experimental/mcp/${encodeURIComponent(input.server)}`,
|
||||
query: { location: input["location"] },
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1277,7 +1277,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/experimental/mcp/${encodeURIComponent(input.server)}/connect`,
|
||||
query: { location: input["location"] },
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1289,7 +1289,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/experimental/mcp/${encodeURIComponent(input.server)}/disconnect`,
|
||||
query: { location: input["location"] },
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1319,7 +1319,7 @@ export function make(options: ClientOptions) {
|
|||
query: { location: input["location"], path: input["path"] },
|
||||
body: input["payload"],
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
binaryBody: true,
|
||||
},
|
||||
|
|
@ -1333,7 +1333,7 @@ export function make(options: ClientOptions) {
|
|||
query: { location: input["location"] },
|
||||
body: { path: input["path"] },
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404, 503],
|
||||
declaredStatuses: [400, 401, 403, 404, 503],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1346,7 +1346,7 @@ export function make(options: ClientOptions) {
|
|||
query: { location: input["location"] },
|
||||
body: { path: input["path"] },
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1590,7 +1590,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/experimental/usage/limits`,
|
||||
query: { location: input?.["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404, 503],
|
||||
declaredStatuses: [400, 401, 403, 404, 503],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1604,7 +1604,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/experimental/config`,
|
||||
body: { shell: input["shell"] },
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1633,7 +1633,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/model`,
|
||||
query: { location: input?.["location"], types: input?.["types"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404, 503],
|
||||
declaredStatuses: [400, 401, 403, 404, 503],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1645,7 +1645,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/model/default`,
|
||||
query: { location: input?.["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404, 503],
|
||||
declaredStatuses: [400, 401, 403, 404, 503],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1659,7 +1659,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/provider`,
|
||||
query: { location: input?.["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404, 503],
|
||||
declaredStatuses: [400, 401, 403, 404, 503],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1671,7 +1671,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/provider/${encodeURIComponent(input.providerID)}`,
|
||||
query: { location: input["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404, 503],
|
||||
declaredStatuses: [400, 401, 403, 404, 503],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1685,7 +1685,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/integration`,
|
||||
query: { location: input?.["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1697,7 +1697,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/integration/${encodeURIComponent(input.integrationID)}`,
|
||||
query: { location: input["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1711,7 +1711,7 @@ export function make(options: ClientOptions) {
|
|||
query: { location: input["location"] },
|
||||
body: { key: input["key"], answer: input["answer"], label: input["label"] },
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1724,7 +1724,7 @@ export function make(options: ClientOptions) {
|
|||
query: { location: input["location"] },
|
||||
body: { methodID: input["methodID"], answer: input["answer"], label: input["label"] },
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1739,7 +1739,7 @@ export function make(options: ClientOptions) {
|
|||
query: { location: input["location"] },
|
||||
body: { methodID: input["methodID"], answer: input["answer"], label: input["label"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1751,7 +1751,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/oauth/${encodeURIComponent(input.attemptID)}`,
|
||||
query: { location: input["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1764,7 +1764,7 @@ export function make(options: ClientOptions) {
|
|||
query: { location: input["location"] },
|
||||
body: { code: input["code"] },
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1776,7 +1776,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/oauth/${encodeURIComponent(input.attemptID)}`,
|
||||
query: { location: input["location"] },
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1791,7 +1791,7 @@ export function make(options: ClientOptions) {
|
|||
query: { location: input["location"] },
|
||||
body: { methodID: input["methodID"], label: input["label"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1803,7 +1803,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/command/${encodeURIComponent(input.attemptID)}`,
|
||||
query: { location: input["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1815,7 +1815,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/command/${encodeURIComponent(input.attemptID)}`,
|
||||
query: { location: input["location"] },
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1830,7 +1830,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/mcp`,
|
||||
query: { location: input?.["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1843,7 +1843,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/mcp/resource`,
|
||||
query: { location: input?.["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1948,7 +1948,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/form`,
|
||||
query: { location: input?.["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1963,7 +1963,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/permission/request`,
|
||||
query: { location: input?.["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -1977,7 +1977,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/permission/saved`,
|
||||
query: { projectID: input?.["projectID"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2021,7 +2021,7 @@ export function make(options: ClientOptions) {
|
|||
agent: input["agent"],
|
||||
},
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2032,7 +2032,7 @@ export function make(options: ClientOptions) {
|
|||
method: "GET",
|
||||
path: `/api/session/${encodeURIComponent(input.sessionID)}/permission`,
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2043,7 +2043,7 @@ export function make(options: ClientOptions) {
|
|||
method: "GET",
|
||||
path: `/api/session/${encodeURIComponent(input.sessionID)}/permission/${encodeURIComponent(input.requestID)}`,
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2055,7 +2055,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/session/${encodeURIComponent(input.sessionID)}/permission/${encodeURIComponent(input.requestID)}/reply`,
|
||||
body: { decision: input["decision"], message: input["message"] },
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2069,7 +2069,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/fs/read/${encodePath(input.path)}`,
|
||||
query: { location: input["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
binary: true,
|
||||
},
|
||||
|
|
@ -2082,7 +2082,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/fs/list`,
|
||||
query: { location: input?.["location"], path: input?.["path"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2094,7 +2094,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/fs/find`,
|
||||
query: { location: input["location"], query: input["query"], type: input["type"], limit: input["limit"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2108,7 +2108,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/command`,
|
||||
query: { location: input?.["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2122,7 +2122,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/skill`,
|
||||
query: { location: input?.["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2137,7 +2137,7 @@ export function make(options: ClientOptions) {
|
|||
query: { location: input["location"] },
|
||||
body: { input: input["input"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404, 500],
|
||||
declaredStatuses: [400, 401, 403, 404, 500],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2165,7 +2165,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/pty`,
|
||||
query: { location: input?.["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2184,7 +2184,7 @@ export function make(options: ClientOptions) {
|
|||
env: input?.["env"],
|
||||
},
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2196,7 +2196,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/pty/${encodeURIComponent(input.ptyID)}`,
|
||||
query: { location: input["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2209,7 +2209,7 @@ export function make(options: ClientOptions) {
|
|||
query: { location: input["location"] },
|
||||
body: { title: input["title"], size: input["size"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2221,7 +2221,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/pty/${encodeURIComponent(input.ptyID)}`,
|
||||
query: { location: input["location"] },
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2250,7 +2250,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/shell`,
|
||||
query: { location: input?.["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2268,7 +2268,7 @@ export function make(options: ClientOptions) {
|
|||
metadata: input["metadata"],
|
||||
},
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2280,7 +2280,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/shell/${encodeURIComponent(input.id)}`,
|
||||
query: { location: input["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2292,7 +2292,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/shell/${encodeURIComponent(input.id)}/output`,
|
||||
query: { location: input["location"], cursor: input["cursor"], limit: input["limit"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2304,7 +2304,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/shell/${encodeURIComponent(input.id)}`,
|
||||
query: { location: input["location"] },
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2318,7 +2318,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/reference`,
|
||||
query: { location: input?.["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2388,7 +2388,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/vcs/init`,
|
||||
query: { location: input?.["location"], provider: input?.["provider"] },
|
||||
successStatus: 204,
|
||||
declaredStatuses: [400, 401, 404, 409, 501, 503],
|
||||
declaredStatuses: [400, 401, 403, 404, 409, 501, 503],
|
||||
empty: true,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2400,7 +2400,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/vcs`,
|
||||
query: { location: input?.["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2412,7 +2412,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/vcs/base`,
|
||||
query: { location: input?.["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404, 503],
|
||||
declaredStatuses: [400, 401, 403, 404, 503],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2424,7 +2424,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/vcs/status`,
|
||||
query: { location: input?.["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2437,7 +2437,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/vcs/branch`,
|
||||
query: { location: input?.["location"], search: input?.["search"], limit: input?.["limit"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2456,7 +2456,7 @@ export function make(options: ClientOptions) {
|
|||
untracked: input["untracked"],
|
||||
},
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404, 503],
|
||||
declaredStatuses: [400, 401, 403, 404, 503],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2509,7 +2509,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/websearch/provider`,
|
||||
query: { location: input?.["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404, 503],
|
||||
declaredStatuses: [400, 401, 403, 404, 503],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2522,7 +2522,7 @@ export function make(options: ClientOptions) {
|
|||
query: { location: input["location"] },
|
||||
body: { query: input["query"], providerID: input["providerID"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404, 503],
|
||||
declaredStatuses: [400, 401, 403, 404, 503],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2536,7 +2536,7 @@ export function make(options: ClientOptions) {
|
|||
path: `/api/config`,
|
||||
query: { location: input?.["location"] },
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
@ -2547,7 +2547,7 @@ export function make(options: ClientOptions) {
|
|||
method: "GET",
|
||||
path: `/api/config/shell`,
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 401, 404],
|
||||
declaredStatuses: [400, 401, 403, 404],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
|
|
|
|||
8
packages/client/src/promise/generated/types.ts
generated
8
packages/client/src/promise/generated/types.ts
generated
|
|
@ -2863,6 +2863,14 @@ export type UnauthorizedError = { readonly _tag: "UnauthorizedError"; readonly m
|
|||
export const isUnauthorizedError = (value: unknown): value is UnauthorizedError =>
|
||||
typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "UnauthorizedError"
|
||||
|
||||
export type LocationAccessDeniedError = {
|
||||
readonly _tag: "LocationAccessDeniedError"
|
||||
readonly location: { readonly directory: string }
|
||||
readonly message: string
|
||||
}
|
||||
export const isLocationAccessDeniedError = (value: unknown): value is LocationAccessDeniedError =>
|
||||
typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "LocationAccessDeniedError"
|
||||
|
||||
export type LocationNotFoundError = {
|
||||
readonly _tag: "LocationNotFoundError"
|
||||
readonly location: { readonly directory: string }
|
||||
|
|
|
|||
961
packages/protocol/openapi.json
generated
961
packages/protocol/openapi.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,4 +1,4 @@
|
|||
import { LocationNotFoundError, InvalidRequestError, SessionNotFoundError } from "./errors.js"
|
||||
import { LocationAccessDeniedError, LocationNotFoundError, InvalidRequestError, SessionNotFoundError } from "./errors.js"
|
||||
import { makeDefaultApi } from "./api.js"
|
||||
import type { Api } from "./api.js"
|
||||
import type { Context } from "effect"
|
||||
|
|
@ -7,12 +7,12 @@ import type { EventGroup } from "./groups/event.js"
|
|||
|
||||
class LocationMiddleware extends HttpApiMiddleware.Service<LocationMiddleware>()(
|
||||
"@opencode/client/LocationMiddleware",
|
||||
{ error: [LocationNotFoundError] },
|
||||
{ error: [LocationNotFoundError, LocationAccessDeniedError] },
|
||||
) {}
|
||||
|
||||
class SessionLocationMiddleware extends HttpApiMiddleware.Service<SessionLocationMiddleware>()(
|
||||
"@opencode/client/SessionLocationMiddleware",
|
||||
{ error: [InvalidRequestError, SessionNotFoundError, LocationNotFoundError] },
|
||||
{ error: [InvalidRequestError, SessionNotFoundError, LocationNotFoundError, LocationAccessDeniedError] },
|
||||
) {}
|
||||
|
||||
type ClientApiShape = Api<
|
||||
|
|
|
|||
|
|
@ -8,6 +8,12 @@ export class LocationNotFoundError extends Schema.TaggedError<LocationNotFoundEr
|
|||
{ httpApiStatus: 404 },
|
||||
) {}
|
||||
|
||||
export class LocationAccessDeniedError extends Schema.TaggedError<LocationAccessDeniedError>()(
|
||||
"LocationAccessDeniedError",
|
||||
{ location: Location.PublicRef, message: Schema.String },
|
||||
{ httpApiStatus: 403 },
|
||||
) {}
|
||||
|
||||
export class InvalidRequestError extends Schema.TaggedError<InvalidRequestError>()(
|
||||
"InvalidRequestError",
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { Schema } from "effect"
|
|||
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/http-api"
|
||||
import {
|
||||
InvalidRequestError,
|
||||
LocationAccessDeniedError,
|
||||
LocationNotFoundError,
|
||||
ModelNotFoundError,
|
||||
ProviderNotFoundError,
|
||||
|
|
@ -20,6 +21,7 @@ const errors = [
|
|||
ProviderRequestError,
|
||||
ServiceUnavailableError,
|
||||
LocationNotFoundError,
|
||||
LocationAccessDeniedError,
|
||||
]
|
||||
|
||||
const textContract = {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { Location } from "@opencode/schema/location"
|
|||
import { PtyTicket } from "@opencode/schema/pty-ticket"
|
||||
import { Context, Schema } from "effect"
|
||||
import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, OpenApi } from "effect/http-api"
|
||||
import { ForbiddenError, LocationNotFoundError, McpServerNotFoundError } from "../errors.js"
|
||||
import { ForbiddenError, LocationAccessDeniedError, LocationNotFoundError, McpServerNotFoundError } from "../errors.js"
|
||||
import { LocationQuery, locationQueryOpenApi } from "./location.js"
|
||||
import { PTY_CONNECT_TICKET_QUERY, PTY_CONNECT_TOKEN_HEADER } from "./pty.js"
|
||||
|
||||
|
|
@ -139,7 +139,7 @@ export const makeMcpGroup = <LocationId extends HttpApiMiddleware.AnyId, Locatio
|
|||
HttpApiEndpoint.get("mcp.client", MCP_CLIENT_PATH, {
|
||||
query: Schema.Struct({ ...McpClientQuery.fields, [PTY_CONNECT_TICKET_QUERY]: Schema.optional(Schema.String) }),
|
||||
success: Schema.Boolean,
|
||||
error: [ForbiddenError, LocationNotFoundError],
|
||||
error: [ForbiddenError, LocationNotFoundError, LocationAccessDeniedError],
|
||||
})
|
||||
.annotateMerge(locationQueryOpenApi)
|
||||
.annotateMerge(
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import { Context, Schema } from "effect"
|
|||
import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, OpenApi } from "effect/http-api"
|
||||
import {
|
||||
ConflictError,
|
||||
LocationAccessDeniedError,
|
||||
LocationNotFoundError,
|
||||
PermissionNotFoundError,
|
||||
PermissionSavedNotFoundError,
|
||||
|
|
@ -114,7 +115,7 @@ export const makePermissionGroup = <
|
|||
HttpApiEndpoint.get("session.permission.list", "/api/session/:sessionID/permission", {
|
||||
params: { sessionID: Session.ID },
|
||||
success: Schema.Struct({ data: Schema.Array(Permission.Request) }),
|
||||
error: [SessionNotFoundError, LocationNotFoundError],
|
||||
error: [SessionNotFoundError, LocationNotFoundError, LocationAccessDeniedError],
|
||||
}).annotateMerge(
|
||||
OpenApi.annotations({
|
||||
identifier: "session.permission.list",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { PtyTicket } from "@opencode/schema/pty-ticket"
|
|||
import { Location } from "@opencode/schema/location"
|
||||
import { Context, Schema } from "effect"
|
||||
import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, OpenApi } from "effect/http-api"
|
||||
import { ForbiddenError, LocationNotFoundError, PtyNotFoundError } from "../errors.js"
|
||||
import { ForbiddenError, LocationAccessDeniedError, LocationNotFoundError, PtyNotFoundError } from "../errors.js"
|
||||
import { LocationQuery, locationQueryOpenApi } from "./location.js"
|
||||
|
||||
export const PTY_CONNECT_TICKET_QUERY = "ticket"
|
||||
|
|
@ -122,7 +122,7 @@ export const makePtyGroup = <LocationId extends HttpApiMiddleware.AnyId, Locatio
|
|||
HttpApiEndpoint.get("pty.connect", PTY_CONNECT_PATH, {
|
||||
params: { ptyID: Pty.ID },
|
||||
success: Schema.Boolean,
|
||||
error: [ForbiddenError, PtyNotFoundError, LocationNotFoundError],
|
||||
error: [ForbiddenError, PtyNotFoundError, LocationNotFoundError, LocationAccessDeniedError],
|
||||
}).annotateMerge(
|
||||
OpenApi.annotations({
|
||||
identifier: "pty.connect",
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import { Context, Schema, SchemaGetter, Struct } from "effect"
|
|||
import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, OpenApi } from "effect/http-api"
|
||||
import {
|
||||
ConflictError,
|
||||
LocationAccessDeniedError,
|
||||
LocationNotFoundError,
|
||||
CommandExecutionError,
|
||||
CommandNotFoundError,
|
||||
|
|
@ -310,7 +311,7 @@ export const makeSessionGroup = <I extends HttpApiMiddleware.AnyId, S, FormI ext
|
|||
}),
|
||||
}),
|
||||
success: HttpApiSchema.NoContent,
|
||||
error: [SessionNotFoundError, LocationNotFoundError],
|
||||
error: [SessionNotFoundError, LocationNotFoundError, LocationAccessDeniedError],
|
||||
}).annotateMerge(
|
||||
OpenApi.annotations({
|
||||
identifier: "session.update",
|
||||
|
|
@ -530,7 +531,14 @@ export const makeSessionGroup = <I extends HttpApiMiddleware.AnyId, S, FormI ext
|
|||
}),
|
||||
}),
|
||||
success: Schema.Struct({ data: Schema.Array(FileDiff.Info) }),
|
||||
error: [InvalidRequestError, MessageNotFoundError, SessionNotFoundError, UnknownError, LocationNotFoundError],
|
||||
error: [
|
||||
InvalidRequestError,
|
||||
MessageNotFoundError,
|
||||
SessionNotFoundError,
|
||||
UnknownError,
|
||||
LocationNotFoundError,
|
||||
LocationAccessDeniedError,
|
||||
],
|
||||
}).annotateMerge(
|
||||
OpenApi.annotations({
|
||||
identifier: "session.diff",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
import { Schema } from "effect"
|
||||
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/http-api"
|
||||
import { InvalidRequestError, LocationNotFoundError, ServiceUnavailableError } from "../errors.js"
|
||||
import {
|
||||
InvalidRequestError,
|
||||
LocationAccessDeniedError,
|
||||
LocationNotFoundError,
|
||||
ServiceUnavailableError,
|
||||
} from "../errors.js"
|
||||
|
||||
export const VoiceTransportType = Schema.Literals(["webrtc", "websocket"]).annotate({
|
||||
identifier: "VoiceTransportType",
|
||||
|
|
@ -54,7 +59,7 @@ export const VoiceGroup = HttpApiGroup.make("server.voice")
|
|||
default: Schema.optional(Schema.String),
|
||||
}),
|
||||
}).annotate({ identifier: "VoiceModelsResponse" }),
|
||||
error: [ServiceUnavailableError, LocationNotFoundError],
|
||||
error: [ServiceUnavailableError, LocationNotFoundError, LocationAccessDeniedError],
|
||||
}).annotateMerge(
|
||||
OpenApi.annotations({
|
||||
identifier: "experimental.voice.models",
|
||||
|
|
@ -76,7 +81,7 @@ export const VoiceGroup = HttpApiGroup.make("server.voice")
|
|||
transport: VoiceTransport,
|
||||
}),
|
||||
}).annotate({ identifier: "VoiceSessionResponse" }),
|
||||
error: [InvalidRequestError, ServiceUnavailableError, LocationNotFoundError],
|
||||
error: [InvalidRequestError, ServiceUnavailableError, LocationNotFoundError, LocationAccessDeniedError],
|
||||
}).annotateMerge(
|
||||
OpenApi.annotations({
|
||||
identifier: "experimental.voice.session",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,12 @@ import { Plugin } from "@opencode/core/plugin"
|
|||
import { LocationServiceMap } from "@opencode/core/location-services"
|
||||
import { AbsolutePath } from "@opencode/core/schema"
|
||||
import { Session } from "@opencode/core/session"
|
||||
import { LocationNotFoundError, InvalidRequestError, ServiceUnavailableError } from "@opencode/protocol/errors"
|
||||
import {
|
||||
LocationAccessDeniedError,
|
||||
LocationNotFoundError,
|
||||
InvalidRequestError,
|
||||
ServiceUnavailableError,
|
||||
} from "@opencode/protocol/errors"
|
||||
import { Effect, Layer, Schema } from "effect"
|
||||
import { HttpServerRequest } from "effect/http"
|
||||
import { HttpApiMiddleware } from "effect/http-api"
|
||||
|
|
@ -14,7 +19,7 @@ export type LocationServices = Layer.Success<ReturnType<(typeof LocationServiceM
|
|||
|
||||
export class LocationMiddleware extends HttpApiMiddleware.Service<LocationMiddleware, { provides: LocationServices }>()(
|
||||
"@opencode/HttpApiLocation",
|
||||
{ error: [LocationNotFoundError] },
|
||||
{ error: [LocationNotFoundError, LocationAccessDeniedError] },
|
||||
) {}
|
||||
|
||||
export function locationErrors<A, E, R>(effect: Effect.Effect<A, E, R>) {
|
||||
|
|
@ -30,6 +35,20 @@ export function locationErrors<A, E, R>(effect: Effect.Effect<A, E, R>) {
|
|||
}),
|
||||
),
|
||||
),
|
||||
// Location boot keeps an unreadable folder a defect, so clients would only see an empty 500.
|
||||
Effect.catchDefect((defect) =>
|
||||
defect instanceof FileSystem.DirectoryAccessDeniedError
|
||||
? Effect.fail(
|
||||
new LocationAccessDeniedError({
|
||||
location: { directory: defect.directory },
|
||||
message:
|
||||
process.platform === "darwin"
|
||||
? `Location access denied: ${defect.directory}. If macOS privacy settings block it, allow access in System Settings > Privacy & Security > Files & Folders.`
|
||||
: `Location access denied: ${defect.directory}`,
|
||||
}),
|
||||
)
|
||||
: Effect.die(defect),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,12 @@
|
|||
import { Instance } from "@opencode/core/instance/service"
|
||||
import { LocationServiceMap } from "@opencode/core/location-services"
|
||||
import { Session } from "@opencode/core/session"
|
||||
import { LocationNotFoundError, InvalidRequestError, SessionNotFoundError } from "@opencode/protocol/errors"
|
||||
import {
|
||||
LocationAccessDeniedError,
|
||||
LocationNotFoundError,
|
||||
InvalidRequestError,
|
||||
SessionNotFoundError,
|
||||
} from "@opencode/protocol/errors"
|
||||
import { Effect, Layer } from "effect"
|
||||
import { HttpRouter, HttpServerRequest, HttpServerResponse } from "effect/http"
|
||||
import { HttpApiMiddleware } from "effect/http-api"
|
||||
|
|
@ -11,7 +16,7 @@ export class FormLocationMiddleware extends HttpApiMiddleware.Service<
|
|||
FormLocationMiddleware,
|
||||
{ provides: LocationServices }
|
||||
>()("@opencode/HttpApiFormLocation", {
|
||||
error: [InvalidRequestError, SessionNotFoundError, LocationNotFoundError],
|
||||
error: [InvalidRequestError, SessionNotFoundError, LocationNotFoundError, LocationAccessDeniedError],
|
||||
}) {}
|
||||
|
||||
export const formLocationLayer = Layer.effect(
|
||||
|
|
|
|||
|
|
@ -3,14 +3,19 @@ import { Session } from "@opencode/core/session"
|
|||
import { Effect, Layer } from "effect"
|
||||
import { HttpRouter } from "effect/http"
|
||||
import { HttpApiMiddleware } from "effect/http-api"
|
||||
import { LocationNotFoundError, InvalidRequestError, SessionNotFoundError } from "@opencode/protocol/errors"
|
||||
import {
|
||||
LocationAccessDeniedError,
|
||||
LocationNotFoundError,
|
||||
InvalidRequestError,
|
||||
SessionNotFoundError,
|
||||
} from "@opencode/protocol/errors"
|
||||
import { locationErrors, sessionInfo, type LocationServices } from "../location"
|
||||
|
||||
export class SessionLocationMiddleware extends HttpApiMiddleware.Service<
|
||||
SessionLocationMiddleware,
|
||||
{ provides: LocationServices }
|
||||
>()("@opencode/HttpApiSessionLocation", {
|
||||
error: [InvalidRequestError, SessionNotFoundError, LocationNotFoundError],
|
||||
error: [InvalidRequestError, SessionNotFoundError, LocationNotFoundError, LocationAccessDeniedError],
|
||||
}) {}
|
||||
|
||||
export const sessionLocationLayer = Layer.effect(
|
||||
|
|
|
|||
|
|
@ -19,57 +19,81 @@ const options = {
|
|||
fs: { filewatcher: false },
|
||||
} as const
|
||||
|
||||
it.live("returns LocationNotFoundError for a missing folder and recovers once it exists", () =>
|
||||
Effect.gen(function* () {
|
||||
const config = yield* Effect.acquireDisposable(Effect.promise(() => tmpdir("opencode-directory-errors-")))
|
||||
const directory = path.join(config.path, "project")
|
||||
const handler = yield* ServerFetch.make({ ...options, config: { directory: config.path } })
|
||||
// Session creation only resolves its placement; it does not boot the Location graph.
|
||||
const created = yield* Effect.promise(() =>
|
||||
handler(
|
||||
new Request("http://opencode.local/api/session", {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json", "x-opencode-directory": encodeURIComponent(directory) },
|
||||
body: JSON.stringify({ location: { directory } }),
|
||||
}),
|
||||
),
|
||||
)
|
||||
expect(created.status).toBe(200)
|
||||
const session = Schema.decodeUnknownSync(Schema.Struct({ data: Session.Info }))(
|
||||
yield* Effect.promise(() => created.json()),
|
||||
).data
|
||||
const endpoints = [
|
||||
"/api/model",
|
||||
"/api/integration",
|
||||
`/api/session/${session.id}/permission`,
|
||||
"/api/session/global/form",
|
||||
]
|
||||
for (const endpoint of endpoints) {
|
||||
const response = yield* Effect.promise(() =>
|
||||
for (const input of [
|
||||
{
|
||||
failure: "missing",
|
||||
status: 404,
|
||||
body: (directory: string) => ({
|
||||
_tag: "LocationNotFoundError",
|
||||
location: { directory },
|
||||
message: `Location not found: ${directory}`,
|
||||
}),
|
||||
},
|
||||
{
|
||||
failure: "unreadable",
|
||||
status: 403,
|
||||
body: (directory: string) => ({
|
||||
_tag: "LocationAccessDeniedError",
|
||||
location: { directory },
|
||||
message: expect.stringContaining(`Location access denied: ${directory}`),
|
||||
}),
|
||||
},
|
||||
] as const) {
|
||||
// Windows does not enforce POSIX directory modes, and root bypasses them.
|
||||
const test =
|
||||
input.failure === "unreadable" && (process.platform === "win32" || process.getuid?.() === 0) ? it.live.skip : it.live
|
||||
test(`returns a typed error for a ${input.failure} folder and recovers once it is fixed`, () =>
|
||||
Effect.gen(function* () {
|
||||
const config = yield* Effect.acquireDisposable(Effect.promise(() => tmpdir("opencode-directory-errors-")))
|
||||
const directory = path.join(config.path, "project")
|
||||
if (input.failure === "unreadable") {
|
||||
yield* Effect.promise(() => fs.mkdir(directory, { mode: 0o000 }))
|
||||
yield* Effect.addFinalizer(() => Effect.promise(() => fs.chmod(directory, 0o755)))
|
||||
}
|
||||
const handler = yield* ServerFetch.make({ ...options, config: { directory: config.path } })
|
||||
// Session creation only resolves its placement; it does not boot the Location graph.
|
||||
const created = yield* Effect.promise(() =>
|
||||
handler(
|
||||
new Request(`http://opencode.local${endpoint}`, {
|
||||
new Request("http://opencode.local/api/session", {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json", "x-opencode-directory": encodeURIComponent(directory) },
|
||||
body: JSON.stringify({ location: { directory } }),
|
||||
}),
|
||||
),
|
||||
)
|
||||
expect(created.status).toBe(200)
|
||||
const session = Schema.decodeUnknownSync(Schema.Struct({ data: Session.Info }))(
|
||||
yield* Effect.promise(() => created.json()),
|
||||
).data
|
||||
const endpoints = [
|
||||
"/api/model",
|
||||
"/api/integration",
|
||||
`/api/session/${session.id}/permission`,
|
||||
"/api/session/global/form",
|
||||
]
|
||||
for (const endpoint of endpoints) {
|
||||
const response = yield* Effect.promise(() =>
|
||||
handler(
|
||||
new Request(`http://opencode.local${endpoint}`, {
|
||||
headers: { "x-opencode-directory": encodeURIComponent(directory) },
|
||||
}),
|
||||
),
|
||||
)
|
||||
expect({ endpoint, status: response.status }).toEqual({ endpoint, status: input.status })
|
||||
expect(yield* Effect.promise(() => response.json())).toEqual(input.body(directory))
|
||||
}
|
||||
yield* Effect.promise(() => (input.failure === "missing" ? fs.mkdir(directory) : fs.chmod(directory, 0o755)))
|
||||
const recovered = yield* Effect.promise(() =>
|
||||
handler(
|
||||
new Request("http://opencode.local/api/model", {
|
||||
headers: { "x-opencode-directory": encodeURIComponent(directory) },
|
||||
}),
|
||||
),
|
||||
)
|
||||
expect({ endpoint, status: response.status }).toEqual({ endpoint, status: 404 })
|
||||
expect(yield* Effect.promise(() => response.json())).toEqual({
|
||||
_tag: "LocationNotFoundError",
|
||||
location: { directory },
|
||||
message: `Location not found: ${directory}`,
|
||||
})
|
||||
}
|
||||
yield* Effect.promise(() => fs.mkdir(directory))
|
||||
const recovered = yield* Effect.promise(() =>
|
||||
handler(
|
||||
new Request("http://opencode.local/api/model", {
|
||||
headers: { "x-opencode-directory": encodeURIComponent(directory) },
|
||||
}),
|
||||
),
|
||||
)
|
||||
expect(recovered.status).toBe(200)
|
||||
}),
|
||||
)
|
||||
expect(recovered.status).toBe(200)
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
it.live("manages a session whose directory was deleted", () =>
|
||||
Effect.gen(function* () {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue