alchemylab-opencode 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build.mjs +31 -2
- package/dist/arktype-aI7TBD0R-HX4BR3RX.js +21 -0
- package/dist/arktype-aI7TBD0R-HX4BR3RX.js.map +7 -0
- package/dist/{chunk-UWZSRZHA.js → chunk-23UYOGZG.js} +817 -315
- package/dist/chunk-23UYOGZG.js.map +7 -0
- package/dist/chunk-3AF5MXLF.js +49 -0
- package/dist/chunk-3AF5MXLF.js.map +7 -0
- package/dist/chunk-FMP3YLWX.js +30 -0
- package/dist/chunk-FMP3YLWX.js.map +7 -0
- package/dist/{chunk-ANDTK76Q.js → chunk-GSE2T5UY.js} +3 -3
- package/dist/{chunk-CYXMV3J3.js → chunk-LU5XVQUD.js} +4 -4
- package/dist/chunk-O5VWOPCL.js +106 -0
- package/dist/chunk-O5VWOPCL.js.map +7 -0
- package/dist/chunk-PWFRMDDF.js +12 -0
- package/dist/{chunk-DSPC5QIG.js → chunk-SM6WZDN6.js} +9 -9
- package/dist/{chunk-MCWTARFP.js → chunk-TASPMBUL.js} +4 -4
- package/dist/chunk-VL3RSEZ2.js +160 -0
- package/dist/chunk-VL3RSEZ2.js.map +7 -0
- package/dist/default-u_dwuiYb-WOFHQQ3K.js +22 -0
- package/dist/effect-QlVUlMFu-UERLUUQW.js +29 -0
- package/dist/effect-QlVUlMFu-UERLUUQW.js.map +7 -0
- package/dist/{mcp-VAU4RMWH.js → mcp-XFGN3FWW.js} +2 -2
- package/dist/{registry-PYMN6L3G.js → registry-W4MBVBYD.js} +3 -3
- package/dist/{run-YFVCQJQM.js → run-73HUV4H3.js} +9 -6
- package/dist/{run-YFVCQJQM.js.map → run-73HUV4H3.js.map} +1 -1
- package/dist/run.js +1 -1
- package/dist/serve.js +1 -1
- package/dist/{server-K3UGWASP.js → server-2CPOG3LS.js} +9 -6
- package/dist/{session-HJFWTM7C.js → session-M6HOZ56B.js} +3 -3
- package/dist/session-M6HOZ56B.js.map +7 -0
- package/dist/{share-next-55VCIMUH.js → share-next-QRBVSD37.js} +4 -4
- package/dist/share-next-QRBVSD37.js.map +7 -0
- package/dist/sury-CWZTCd75-XC3NCMTP.js +29 -0
- package/dist/sury-CWZTCd75-XC3NCMTP.js.map +7 -0
- package/dist/typebox-Dei93FPO-QOBKW4L7.js +21 -0
- package/dist/typebox-Dei93FPO-QOBKW4L7.js.map +7 -0
- package/dist/valibot--1zFm7rT-LHHLSLYY.js +29 -0
- package/dist/valibot--1zFm7rT-LHHLSLYY.js.map +7 -0
- package/dist/valibot-D_HTw1Gn-UR62BIDY.js +60 -0
- package/dist/valibot-D_HTw1Gn-UR62BIDY.js.map +7 -0
- package/dist/{worktree-6GGDLADY.js → worktree-3GUHT2P7.js} +5 -5
- package/dist/zod-Bwrt9trS-J2GOMA2R.js +43 -0
- package/dist/zod-Bwrt9trS-J2GOMA2R.js.map +7 -0
- package/dist/zod-DSgpEGAE-VTXQW6SB.js +56 -0
- package/dist/zod-DSgpEGAE-VTXQW6SB.js.map +7 -0
- package/package.json +2 -8
- package/dist/chunk-UWZSRZHA.js.map +0 -7
- /package/dist/{chunk-ANDTK76Q.js.map → chunk-GSE2T5UY.js.map} +0 -0
- /package/dist/{chunk-CYXMV3J3.js.map → chunk-LU5XVQUD.js.map} +0 -0
- /package/dist/{mcp-VAU4RMWH.js.map → chunk-PWFRMDDF.js.map} +0 -0
- /package/dist/{chunk-DSPC5QIG.js.map → chunk-SM6WZDN6.js.map} +0 -0
- /package/dist/{chunk-MCWTARFP.js.map → chunk-TASPMBUL.js.map} +0 -0
- /package/dist/{registry-PYMN6L3G.js.map → default-u_dwuiYb-WOFHQQ3K.js.map} +0 -0
- /package/dist/{server-K3UGWASP.js.map → mcp-XFGN3FWW.js.map} +0 -0
- /package/dist/{session-HJFWTM7C.js.map → registry-W4MBVBYD.js.map} +0 -0
- /package/dist/{share-next-55VCIMUH.js.map → server-2CPOG3LS.js.map} +0 -0
- /package/dist/{worktree-6GGDLADY.js.map → worktree-3GUHT2P7.js.map} +0 -0
|
@@ -14,7 +14,10 @@ import {
|
|
|
14
14
|
Vcs,
|
|
15
15
|
WorkspaceInfo,
|
|
16
16
|
Worktree
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-TASPMBUL.js";
|
|
18
|
+
import {
|
|
19
|
+
toOpenAPISchema
|
|
20
|
+
} from "./chunk-3AF5MXLF.js";
|
|
18
21
|
import {
|
|
19
22
|
Agent,
|
|
20
23
|
Command,
|
|
@@ -45,7 +48,7 @@ import {
|
|
|
45
48
|
ToolRegistry,
|
|
46
49
|
WorkspaceID,
|
|
47
50
|
fn
|
|
48
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-SM6WZDN6.js";
|
|
49
52
|
import {
|
|
50
53
|
Account,
|
|
51
54
|
AccountID,
|
|
@@ -57,7 +60,7 @@ import {
|
|
|
57
60
|
ModelsDev,
|
|
58
61
|
OrgID,
|
|
59
62
|
TuiEvent
|
|
60
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-LU5XVQUD.js";
|
|
61
64
|
import {
|
|
62
65
|
BusEvent,
|
|
63
66
|
Database,
|
|
@@ -89,13 +92,530 @@ import {
|
|
|
89
92
|
import {
|
|
90
93
|
withStatics
|
|
91
94
|
} from "./chunk-BI5OUHTQ.js";
|
|
95
|
+
import {
|
|
96
|
+
toJsonSchema
|
|
97
|
+
} from "./chunk-VL3RSEZ2.js";
|
|
92
98
|
import {
|
|
93
99
|
__callDispose,
|
|
94
100
|
__using
|
|
95
101
|
} from "./chunk-HORZKFCR.js";
|
|
96
102
|
|
|
103
|
+
// node_modules/@hono/standard-validator/dist/index.js
|
|
104
|
+
import { validator } from "hono/validator";
|
|
105
|
+
var RESTRICTED_DATA_FIELDS = { header: ["cookie"] };
|
|
106
|
+
function sanitizeIssues(issues, vendor, target) {
|
|
107
|
+
if (!(target in RESTRICTED_DATA_FIELDS)) return issues;
|
|
108
|
+
const restrictedFields = RESTRICTED_DATA_FIELDS[target] || [];
|
|
109
|
+
if (vendor === "arktype") return sanitizeArktypeIssues(issues, restrictedFields);
|
|
110
|
+
if (vendor === "valibot") return sanitizeValibotIssues(issues, restrictedFields);
|
|
111
|
+
return issues;
|
|
112
|
+
}
|
|
113
|
+
function sanitizeArktypeIssues(issues, restrictedFields) {
|
|
114
|
+
return issues.map((issue) => {
|
|
115
|
+
if (issue && typeof issue === "object" && "data" in issue && typeof issue.data === "object" && issue.data !== null && !Array.isArray(issue.data)) {
|
|
116
|
+
const dataCopy = { ...issue.data };
|
|
117
|
+
for (const field of restrictedFields) delete dataCopy[field];
|
|
118
|
+
const sanitizedIssue = Object.create(Object.getPrototypeOf(issue));
|
|
119
|
+
Object.assign(sanitizedIssue, issue, { data: dataCopy });
|
|
120
|
+
return sanitizedIssue;
|
|
121
|
+
}
|
|
122
|
+
return issue;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function sanitizeValibotIssues(issues, restrictedFields) {
|
|
126
|
+
return issues.map((issue) => {
|
|
127
|
+
if (issue && typeof issue === "object" && "path" in issue && Array.isArray(issue.path)) {
|
|
128
|
+
for (const path of issue.path) if (typeof path === "object" && "input" in path && typeof path.input === "object" && path.input !== null && !Array.isArray(path.input)) for (const field of restrictedFields) delete path.input[field];
|
|
129
|
+
}
|
|
130
|
+
return issue;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
var sValidator = (target, schema, hook) => validator(target, async (value, c) => {
|
|
134
|
+
const result = await schema["~standard"].validate(value);
|
|
135
|
+
if (hook) {
|
|
136
|
+
const hookResult = await hook(result.issues ? {
|
|
137
|
+
data: value,
|
|
138
|
+
error: result.issues,
|
|
139
|
+
success: false,
|
|
140
|
+
target
|
|
141
|
+
} : {
|
|
142
|
+
data: value,
|
|
143
|
+
success: true,
|
|
144
|
+
target
|
|
145
|
+
}, c);
|
|
146
|
+
if (hookResult) {
|
|
147
|
+
if (hookResult instanceof Response) return hookResult;
|
|
148
|
+
if ("response" in hookResult) return hookResult.response;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (result.issues) {
|
|
152
|
+
const processedIssues = sanitizeIssues(result.issues, schema["~standard"].vendor, target);
|
|
153
|
+
return c.json({
|
|
154
|
+
data: value,
|
|
155
|
+
error: processedIssues,
|
|
156
|
+
success: false
|
|
157
|
+
}, 400);
|
|
158
|
+
}
|
|
159
|
+
return result.value;
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// node_modules/hono-openapi/dist/index.js
|
|
163
|
+
var uniqueSymbol = /* @__PURE__ */ Symbol("openapi");
|
|
164
|
+
var ALLOWED_METHODS = [
|
|
165
|
+
"GET",
|
|
166
|
+
"PUT",
|
|
167
|
+
"POST",
|
|
168
|
+
"DELETE",
|
|
169
|
+
"OPTIONS",
|
|
170
|
+
"HEAD",
|
|
171
|
+
"PATCH",
|
|
172
|
+
"TRACE"
|
|
173
|
+
];
|
|
174
|
+
var toOpenAPIPath = (path) => path.split("/").map((x) => {
|
|
175
|
+
let tmp = x;
|
|
176
|
+
if (tmp.startsWith(":")) {
|
|
177
|
+
const match = tmp.match(/^:([^{?]+)(?:{(.+)})?(\?)?$/);
|
|
178
|
+
if (match) {
|
|
179
|
+
const paramName = match[1];
|
|
180
|
+
tmp = `{${paramName}}`;
|
|
181
|
+
} else {
|
|
182
|
+
tmp = tmp.slice(1, tmp.length);
|
|
183
|
+
if (tmp.endsWith("?")) tmp = tmp.slice(0, -1);
|
|
184
|
+
tmp = `{${tmp}}`;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return tmp;
|
|
188
|
+
}).join("/");
|
|
189
|
+
var capitalize = (word) => word.charAt(0).toUpperCase() + word.slice(1);
|
|
190
|
+
var generateOperationId = (route) => {
|
|
191
|
+
let operationId = route.method.toLowerCase();
|
|
192
|
+
if (route.path === "/") return `${operationId}Index`;
|
|
193
|
+
for (const segment of route.path.split("/")) {
|
|
194
|
+
if (segment.charCodeAt(0) === 123) {
|
|
195
|
+
operationId += `By${capitalize(segment.slice(1, -1))}`;
|
|
196
|
+
} else {
|
|
197
|
+
operationId += capitalize(segment);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return operationId;
|
|
201
|
+
};
|
|
202
|
+
var paramKey = (param) => "$ref" in param ? param.$ref : `${param.in} ${param.name}`;
|
|
203
|
+
function mergeParameters(...params) {
|
|
204
|
+
const merged = params.flatMap((x) => x ?? []).reduce((acc, param) => {
|
|
205
|
+
acc.set(paramKey(param), param);
|
|
206
|
+
return acc;
|
|
207
|
+
}, /* @__PURE__ */ new Map());
|
|
208
|
+
return Array.from(merged.values());
|
|
209
|
+
}
|
|
210
|
+
var specsByPathContext = /* @__PURE__ */ new Map();
|
|
211
|
+
function getPathContext(path) {
|
|
212
|
+
const context = [];
|
|
213
|
+
for (const [key, data] of specsByPathContext) {
|
|
214
|
+
if (data && path.match(key)) {
|
|
215
|
+
context.push(data);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return context;
|
|
219
|
+
}
|
|
220
|
+
function clearSpecsContext() {
|
|
221
|
+
specsByPathContext.clear();
|
|
222
|
+
}
|
|
223
|
+
function mergeSpecs(route, ...specs) {
|
|
224
|
+
return specs.reduce(
|
|
225
|
+
(prev, spec) => {
|
|
226
|
+
if (!spec || !prev) return prev;
|
|
227
|
+
for (const [key, value] of Object.entries(spec)) {
|
|
228
|
+
if (value == null) continue;
|
|
229
|
+
if (key in prev && (typeof value === "object" || typeof value === "function" && key === "operationId")) {
|
|
230
|
+
if (Array.isArray(value)) {
|
|
231
|
+
const values = [...prev[key] ?? [], ...value];
|
|
232
|
+
if (key === "tags") {
|
|
233
|
+
prev[key] = Array.from(new Set(values));
|
|
234
|
+
} else if (key === "parameters") {
|
|
235
|
+
prev[key] = mergeParameters(values);
|
|
236
|
+
} else {
|
|
237
|
+
prev[key] = values;
|
|
238
|
+
}
|
|
239
|
+
} else if (typeof value === "function") {
|
|
240
|
+
prev[key] = value(route);
|
|
241
|
+
} else {
|
|
242
|
+
if (key === "parameters") {
|
|
243
|
+
prev[key] = mergeParameters(prev[key], value);
|
|
244
|
+
} else {
|
|
245
|
+
prev[key] = {
|
|
246
|
+
...prev[key],
|
|
247
|
+
...value
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
} else {
|
|
252
|
+
prev[key] = value;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return prev;
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
operationId: generateOperationId(route)
|
|
259
|
+
}
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
function registerSchemaPath({
|
|
263
|
+
route,
|
|
264
|
+
specs,
|
|
265
|
+
paths
|
|
266
|
+
}) {
|
|
267
|
+
const path = toOpenAPIPath(route.path);
|
|
268
|
+
const method = route.method.toLowerCase();
|
|
269
|
+
if (method === "all") {
|
|
270
|
+
if (!specs) return;
|
|
271
|
+
if (specsByPathContext.has(path)) {
|
|
272
|
+
const prev = specsByPathContext.get(path) ?? {};
|
|
273
|
+
specsByPathContext.set(path, mergeSpecs(route, prev, specs));
|
|
274
|
+
} else {
|
|
275
|
+
specsByPathContext.set(path, specs);
|
|
276
|
+
}
|
|
277
|
+
} else {
|
|
278
|
+
const pathContext = getPathContext(path);
|
|
279
|
+
if (!(path in paths)) {
|
|
280
|
+
paths[path] = {};
|
|
281
|
+
}
|
|
282
|
+
if (paths[path]) {
|
|
283
|
+
paths[path][method] = mergeSpecs(
|
|
284
|
+
route,
|
|
285
|
+
...pathContext,
|
|
286
|
+
paths[path]?.[method],
|
|
287
|
+
specs
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
function removeExcludedPaths(paths, ctx) {
|
|
293
|
+
const { exclude, excludeStaticFile } = ctx.options;
|
|
294
|
+
const newPaths = {};
|
|
295
|
+
const _exclude = Array.isArray(exclude) ? exclude : [exclude];
|
|
296
|
+
for (const [key, value] of Object.entries(paths)) {
|
|
297
|
+
if (value == null) continue;
|
|
298
|
+
const isExplicitlyExcluded = _exclude.some((x) => {
|
|
299
|
+
if (typeof x === "string") return key === x;
|
|
300
|
+
return x.test(key);
|
|
301
|
+
});
|
|
302
|
+
if (isExplicitlyExcluded) continue;
|
|
303
|
+
const isWildcardWithoutParameters = key.includes("*") && !key.includes("{");
|
|
304
|
+
if (isWildcardWithoutParameters) continue;
|
|
305
|
+
if (excludeStaticFile) {
|
|
306
|
+
const hasPathParameters = key.includes("{");
|
|
307
|
+
const lastSegment = key.split("/").pop() || "";
|
|
308
|
+
const looksLikeStaticFile = lastSegment.includes(".");
|
|
309
|
+
const shouldExcludeAsStaticFile = !hasPathParameters && looksLikeStaticFile;
|
|
310
|
+
if (shouldExcludeAsStaticFile) continue;
|
|
311
|
+
}
|
|
312
|
+
for (const method of Object.keys(value)) {
|
|
313
|
+
const schema = value[method];
|
|
314
|
+
if (schema == null) continue;
|
|
315
|
+
if (key.includes("{")) {
|
|
316
|
+
schema.parameters = schema.parameters ? [...schema.parameters] : [];
|
|
317
|
+
const pathParameters = key.split("/").filter(
|
|
318
|
+
(x) => x.startsWith("{") && !schema.parameters.find(
|
|
319
|
+
(params) => params.in === "path" && params.name === x.slice(1, x.length - 1)
|
|
320
|
+
)
|
|
321
|
+
);
|
|
322
|
+
for (const param of pathParameters) {
|
|
323
|
+
const paramName = param.slice(1, param.length - 1);
|
|
324
|
+
const index = schema.parameters.findIndex(
|
|
325
|
+
(x) => {
|
|
326
|
+
if ("$ref" in x) {
|
|
327
|
+
const pos = x.$ref.split("/").pop();
|
|
328
|
+
if (pos) {
|
|
329
|
+
const param2 = ctx.components.parameters?.[pos];
|
|
330
|
+
if (param2 && !("$ref" in param2)) {
|
|
331
|
+
return param2.in === "path" && param2.name === paramName;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
return false;
|
|
335
|
+
}
|
|
336
|
+
return x.in === "path" && x.name === paramName;
|
|
337
|
+
}
|
|
338
|
+
);
|
|
339
|
+
if (index === -1) {
|
|
340
|
+
schema.parameters.push({
|
|
341
|
+
schema: { type: "string" },
|
|
342
|
+
in: "path",
|
|
343
|
+
name: paramName,
|
|
344
|
+
required: true
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
if (!schema.responses) {
|
|
350
|
+
schema.responses = {
|
|
351
|
+
200: {}
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
newPaths[key] = value;
|
|
356
|
+
}
|
|
357
|
+
return newPaths;
|
|
358
|
+
}
|
|
359
|
+
var DEFAULT_OPTIONS = {
|
|
360
|
+
documentation: {},
|
|
361
|
+
excludeStaticFile: true,
|
|
362
|
+
exclude: [],
|
|
363
|
+
excludeMethods: ["OPTIONS"],
|
|
364
|
+
excludeTags: []
|
|
365
|
+
};
|
|
366
|
+
function openAPIRouteHandler(hono, options) {
|
|
367
|
+
let specs;
|
|
368
|
+
return async (c) => {
|
|
369
|
+
if (specs) return c.json(specs);
|
|
370
|
+
specs = await generateSpecs(hono, options, c);
|
|
371
|
+
return c.json(specs);
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
async function generateSpecs(hono, options = DEFAULT_OPTIONS, c) {
|
|
375
|
+
const ctx = {
|
|
376
|
+
components: {},
|
|
377
|
+
// @ts-expect-error
|
|
378
|
+
options: {
|
|
379
|
+
...DEFAULT_OPTIONS,
|
|
380
|
+
...options
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
const _documentation = ctx.options.documentation ?? {};
|
|
384
|
+
clearSpecsContext();
|
|
385
|
+
const paths = await generatePaths(hono, ctx);
|
|
386
|
+
for (const path in paths) {
|
|
387
|
+
for (const method in paths[path]) {
|
|
388
|
+
const isHidden = getHiddenValue({
|
|
389
|
+
valueOrFunc: paths[path][method]?.hide,
|
|
390
|
+
method,
|
|
391
|
+
path,
|
|
392
|
+
c
|
|
393
|
+
});
|
|
394
|
+
if (isHidden) {
|
|
395
|
+
paths[path][method] = void 0;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
const components = mergeComponentsObjects(
|
|
400
|
+
_documentation.components,
|
|
401
|
+
ctx.components
|
|
402
|
+
);
|
|
403
|
+
return {
|
|
404
|
+
openapi: "3.1.0",
|
|
405
|
+
..._documentation,
|
|
406
|
+
tags: _documentation.tags?.filter(
|
|
407
|
+
(tag) => !ctx.options.excludeTags?.includes(tag?.name)
|
|
408
|
+
),
|
|
409
|
+
info: {
|
|
410
|
+
title: "Hono Documentation",
|
|
411
|
+
description: "Development documentation",
|
|
412
|
+
version: "0.0.0",
|
|
413
|
+
..._documentation.info
|
|
414
|
+
},
|
|
415
|
+
paths: {
|
|
416
|
+
...removeExcludedPaths(paths, ctx),
|
|
417
|
+
..._documentation.paths
|
|
418
|
+
},
|
|
419
|
+
components
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
async function generatePaths(hono, ctx) {
|
|
423
|
+
const paths = {};
|
|
424
|
+
for (const route of hono.routes) {
|
|
425
|
+
const middlewareHandler = route.handler[uniqueSymbol];
|
|
426
|
+
if (!middlewareHandler) {
|
|
427
|
+
if (ctx.options.includeEmptyPaths) {
|
|
428
|
+
registerSchemaPath({
|
|
429
|
+
route,
|
|
430
|
+
paths
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
435
|
+
const routeMethod = route.method;
|
|
436
|
+
if (routeMethod !== "ALL") {
|
|
437
|
+
if (ctx.options.excludeMethods?.includes(routeMethod)) {
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
if (!ALLOWED_METHODS.includes(routeMethod)) {
|
|
441
|
+
continue;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
const defaultOptionsForThisMethod = ctx.options.defaultOptions?.[routeMethod];
|
|
445
|
+
const { schema: routeSpecs, components = {} } = await getSpec(
|
|
446
|
+
middlewareHandler,
|
|
447
|
+
defaultOptionsForThisMethod
|
|
448
|
+
);
|
|
449
|
+
ctx.components = mergeComponentsObjects(ctx.components, components);
|
|
450
|
+
registerSchemaPath({
|
|
451
|
+
route,
|
|
452
|
+
specs: routeSpecs,
|
|
453
|
+
paths
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
return paths;
|
|
457
|
+
}
|
|
458
|
+
function getHiddenValue(options) {
|
|
459
|
+
const { valueOrFunc, c, method, path } = options;
|
|
460
|
+
if (valueOrFunc != null) {
|
|
461
|
+
if (typeof valueOrFunc === "boolean") {
|
|
462
|
+
return valueOrFunc;
|
|
463
|
+
}
|
|
464
|
+
if (typeof valueOrFunc === "function") {
|
|
465
|
+
return valueOrFunc({ c, method, path });
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
return false;
|
|
469
|
+
}
|
|
470
|
+
async function getSpec(middlewareHandler, defaultOptions) {
|
|
471
|
+
if ("spec" in middlewareHandler) {
|
|
472
|
+
let components = {};
|
|
473
|
+
const tmp = {
|
|
474
|
+
...defaultOptions,
|
|
475
|
+
...middlewareHandler.spec,
|
|
476
|
+
responses: {
|
|
477
|
+
...defaultOptions?.responses,
|
|
478
|
+
...middlewareHandler.spec.responses
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
if (tmp.responses) {
|
|
482
|
+
for (const key of Object.keys(tmp.responses)) {
|
|
483
|
+
const response2 = tmp.responses[key];
|
|
484
|
+
if (!response2 || !("content" in response2)) continue;
|
|
485
|
+
for (const contentKey of Object.keys(response2.content ?? {})) {
|
|
486
|
+
const raw = response2.content?.[contentKey];
|
|
487
|
+
if (!raw) continue;
|
|
488
|
+
if (raw.schema && "toOpenAPISchema" in raw.schema) {
|
|
489
|
+
const result2 = await raw.schema.toOpenAPISchema();
|
|
490
|
+
raw.schema = result2.schema;
|
|
491
|
+
if (result2.components) {
|
|
492
|
+
components = mergeComponentsObjects(
|
|
493
|
+
components,
|
|
494
|
+
result2.components
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
return { schema: tmp, components };
|
|
502
|
+
}
|
|
503
|
+
const result = await middlewareHandler.toOpenAPISchema();
|
|
504
|
+
const docs = defaultOptions ?? {};
|
|
505
|
+
if (middlewareHandler.target === "form" || middlewareHandler.target === "json") {
|
|
506
|
+
const media = middlewareHandler.options?.media ?? middlewareHandler.target === "json" ? "application/json" : "multipart/form-data";
|
|
507
|
+
if (!docs.requestBody || !("content" in docs.requestBody) || !docs.requestBody.content) {
|
|
508
|
+
docs.requestBody = {
|
|
509
|
+
content: {
|
|
510
|
+
[media]: {
|
|
511
|
+
schema: result.schema
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
} else {
|
|
516
|
+
docs.requestBody.content[media] = {
|
|
517
|
+
schema: result.schema
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
} else {
|
|
521
|
+
let parameters = [];
|
|
522
|
+
if ("$ref" in result.schema) {
|
|
523
|
+
const ref = result.schema.$ref;
|
|
524
|
+
const pos = ref.split("/").pop();
|
|
525
|
+
if (pos && result.components?.schemas?.[pos]) {
|
|
526
|
+
const schema = result.components.schemas[pos];
|
|
527
|
+
const newParameters = generateParameters(
|
|
528
|
+
middlewareHandler.target,
|
|
529
|
+
schema
|
|
530
|
+
)[0];
|
|
531
|
+
if (!result.components.parameters) {
|
|
532
|
+
result.components.parameters = {};
|
|
533
|
+
}
|
|
534
|
+
result.components.parameters[pos] = newParameters;
|
|
535
|
+
delete result.components.schemas[pos];
|
|
536
|
+
parameters.push({
|
|
537
|
+
$ref: `#/components/parameters/${pos}`
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
} else {
|
|
541
|
+
parameters = generateParameters(middlewareHandler.target, result.schema);
|
|
542
|
+
}
|
|
543
|
+
docs.parameters = parameters;
|
|
544
|
+
}
|
|
545
|
+
return { schema: docs, components: result.components };
|
|
546
|
+
}
|
|
547
|
+
function generateParameters(target, schema) {
|
|
548
|
+
const parameters = [];
|
|
549
|
+
for (const [key, value] of Object.entries(schema.properties ?? {})) {
|
|
550
|
+
const def = {
|
|
551
|
+
in: target === "param" ? "path" : target,
|
|
552
|
+
name: key,
|
|
553
|
+
// @ts-expect-error
|
|
554
|
+
schema: value
|
|
555
|
+
};
|
|
556
|
+
const isRequired = schema.required?.includes(key);
|
|
557
|
+
if (isRequired) {
|
|
558
|
+
def.required = true;
|
|
559
|
+
}
|
|
560
|
+
if (def.schema && "description" in def.schema && def.schema.description) {
|
|
561
|
+
def.description = def.schema.description;
|
|
562
|
+
def.schema.description = void 0;
|
|
563
|
+
}
|
|
564
|
+
parameters.push(def);
|
|
565
|
+
}
|
|
566
|
+
return parameters;
|
|
567
|
+
}
|
|
568
|
+
function mergeComponentsObjects(...components) {
|
|
569
|
+
return components.reduce(
|
|
570
|
+
(prev, component, index) => {
|
|
571
|
+
if (component == null || index === 0) return prev;
|
|
572
|
+
if (prev.schemas && Object.keys(prev.schemas).length > 0 || component.schemas && Object.keys(component.schemas).length > 0) {
|
|
573
|
+
prev.schemas = {
|
|
574
|
+
...prev.schemas,
|
|
575
|
+
...component.schemas
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
if (prev.parameters && Object.keys(prev.parameters).length > 0 || component.parameters && Object.keys(component.parameters).length > 0) {
|
|
579
|
+
prev.parameters = {
|
|
580
|
+
...prev.parameters,
|
|
581
|
+
...component.parameters
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
return prev;
|
|
585
|
+
},
|
|
586
|
+
components[0] ?? {}
|
|
587
|
+
);
|
|
588
|
+
}
|
|
589
|
+
function resolver(schema, userDefinedOptions) {
|
|
590
|
+
return {
|
|
591
|
+
vendor: schema["~standard"].vendor,
|
|
592
|
+
validate: schema["~standard"].validate,
|
|
593
|
+
toJSONSchema: (customOptions) => toJsonSchema(schema, { ...userDefinedOptions, ...customOptions }),
|
|
594
|
+
toOpenAPISchema: (customOptions) => toOpenAPISchema(schema, { ...userDefinedOptions, ...customOptions })
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
function validator2(target, schema, hook, options) {
|
|
598
|
+
const middleware = sValidator(target, schema, hook);
|
|
599
|
+
return Object.assign(middleware, {
|
|
600
|
+
[uniqueSymbol]: {
|
|
601
|
+
target,
|
|
602
|
+
...resolver(schema, options),
|
|
603
|
+
options
|
|
604
|
+
}
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
function describeRoute(spec) {
|
|
608
|
+
const middleware = async (_c, next) => {
|
|
609
|
+
await next();
|
|
610
|
+
};
|
|
611
|
+
return Object.assign(middleware, {
|
|
612
|
+
[uniqueSymbol]: {
|
|
613
|
+
spec
|
|
614
|
+
}
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
|
|
97
618
|
// packages/opencode/src/server/server.ts
|
|
98
|
-
import { describeRoute as describeRoute16, generateSpecs, validator as validator15, resolver as resolver17, openAPIRouteHandler } from "hono-openapi";
|
|
99
619
|
import { Hono as Hono17 } from "hono";
|
|
100
620
|
import { compress } from "hono/compress";
|
|
101
621
|
import { cors } from "hono/cors";
|
|
@@ -106,7 +626,7 @@ import { createNodeWebSocket as createNodeWebSocket2 } from "@hono/node-ws";
|
|
|
106
626
|
|
|
107
627
|
// packages/opencode/src/control-plane/adaptors/index.ts
|
|
108
628
|
var ADAPTORS = {
|
|
109
|
-
worktree: lazy(async () => (await import("./worktree-
|
|
629
|
+
worktree: lazy(async () => (await import("./worktree-3GUHT2P7.js")).WorktreeAdaptor)
|
|
110
630
|
};
|
|
111
631
|
function getAdaptor(type) {
|
|
112
632
|
return ADAPTORS[type]();
|
|
@@ -440,7 +960,6 @@ var ServerProxy;
|
|
|
440
960
|
})(ServerProxy || (ServerProxy = {}));
|
|
441
961
|
|
|
442
962
|
// packages/opencode/src/server/instance.ts
|
|
443
|
-
import { describeRoute as describeRoute14, resolver as resolver15, validator as validator13 } from "hono-openapi";
|
|
444
963
|
import { Hono as Hono15 } from "hono";
|
|
445
964
|
import { proxy } from "hono/proxy";
|
|
446
965
|
import z19 from "zod";
|
|
@@ -448,7 +967,6 @@ import { createHash } from "node:crypto";
|
|
|
448
967
|
|
|
449
968
|
// packages/opencode/src/server/routes/tui.ts
|
|
450
969
|
import { Hono as Hono2 } from "hono";
|
|
451
|
-
import { describeRoute, validator, resolver as resolver2 } from "hono-openapi";
|
|
452
970
|
import z3 from "zod";
|
|
453
971
|
|
|
454
972
|
// packages/opencode/src/util/queue.ts
|
|
@@ -470,7 +988,6 @@ var AsyncQueue = class {
|
|
|
470
988
|
};
|
|
471
989
|
|
|
472
990
|
// packages/opencode/src/server/error.ts
|
|
473
|
-
import { resolver } from "hono-openapi";
|
|
474
991
|
import z2 from "zod";
|
|
475
992
|
var ERRORS = {
|
|
476
993
|
400: {
|
|
@@ -520,7 +1037,7 @@ var TuiControlRoutes = new Hono2().get(
|
|
|
520
1037
|
description: "Next TUI request",
|
|
521
1038
|
content: {
|
|
522
1039
|
"application/json": {
|
|
523
|
-
schema:
|
|
1040
|
+
schema: resolver(TuiRequest)
|
|
524
1041
|
}
|
|
525
1042
|
}
|
|
526
1043
|
}
|
|
@@ -541,13 +1058,13 @@ var TuiControlRoutes = new Hono2().get(
|
|
|
541
1058
|
description: "Response submitted successfully",
|
|
542
1059
|
content: {
|
|
543
1060
|
"application/json": {
|
|
544
|
-
schema:
|
|
1061
|
+
schema: resolver(z3.boolean())
|
|
545
1062
|
}
|
|
546
1063
|
}
|
|
547
1064
|
}
|
|
548
1065
|
}
|
|
549
1066
|
}),
|
|
550
|
-
|
|
1067
|
+
validator2("json", z3.any()),
|
|
551
1068
|
async (c) => {
|
|
552
1069
|
const body = c.req.valid("json");
|
|
553
1070
|
response.push(body);
|
|
@@ -566,14 +1083,14 @@ var TuiRoutes = lazy(
|
|
|
566
1083
|
description: "Prompt processed successfully",
|
|
567
1084
|
content: {
|
|
568
1085
|
"application/json": {
|
|
569
|
-
schema:
|
|
1086
|
+
schema: resolver(z3.boolean())
|
|
570
1087
|
}
|
|
571
1088
|
}
|
|
572
1089
|
},
|
|
573
1090
|
...errors(400)
|
|
574
1091
|
}
|
|
575
1092
|
}),
|
|
576
|
-
|
|
1093
|
+
validator2("json", TuiEvent.PromptAppend.properties),
|
|
577
1094
|
async (c) => {
|
|
578
1095
|
await Bus.publish(TuiEvent.PromptAppend, c.req.valid("json"));
|
|
579
1096
|
return c.json(true);
|
|
@@ -589,7 +1106,7 @@ var TuiRoutes = lazy(
|
|
|
589
1106
|
description: "Help dialog opened successfully",
|
|
590
1107
|
content: {
|
|
591
1108
|
"application/json": {
|
|
592
|
-
schema:
|
|
1109
|
+
schema: resolver(z3.boolean())
|
|
593
1110
|
}
|
|
594
1111
|
}
|
|
595
1112
|
}
|
|
@@ -612,7 +1129,7 @@ var TuiRoutes = lazy(
|
|
|
612
1129
|
description: "Session dialog opened successfully",
|
|
613
1130
|
content: {
|
|
614
1131
|
"application/json": {
|
|
615
|
-
schema:
|
|
1132
|
+
schema: resolver(z3.boolean())
|
|
616
1133
|
}
|
|
617
1134
|
}
|
|
618
1135
|
}
|
|
@@ -635,7 +1152,7 @@ var TuiRoutes = lazy(
|
|
|
635
1152
|
description: "Theme dialog opened successfully",
|
|
636
1153
|
content: {
|
|
637
1154
|
"application/json": {
|
|
638
|
-
schema:
|
|
1155
|
+
schema: resolver(z3.boolean())
|
|
639
1156
|
}
|
|
640
1157
|
}
|
|
641
1158
|
}
|
|
@@ -658,7 +1175,7 @@ var TuiRoutes = lazy(
|
|
|
658
1175
|
description: "Model dialog opened successfully",
|
|
659
1176
|
content: {
|
|
660
1177
|
"application/json": {
|
|
661
|
-
schema:
|
|
1178
|
+
schema: resolver(z3.boolean())
|
|
662
1179
|
}
|
|
663
1180
|
}
|
|
664
1181
|
}
|
|
@@ -681,7 +1198,7 @@ var TuiRoutes = lazy(
|
|
|
681
1198
|
description: "Prompt submitted successfully",
|
|
682
1199
|
content: {
|
|
683
1200
|
"application/json": {
|
|
684
|
-
schema:
|
|
1201
|
+
schema: resolver(z3.boolean())
|
|
685
1202
|
}
|
|
686
1203
|
}
|
|
687
1204
|
}
|
|
@@ -704,7 +1221,7 @@ var TuiRoutes = lazy(
|
|
|
704
1221
|
description: "Prompt cleared successfully",
|
|
705
1222
|
content: {
|
|
706
1223
|
"application/json": {
|
|
707
|
-
schema:
|
|
1224
|
+
schema: resolver(z3.boolean())
|
|
708
1225
|
}
|
|
709
1226
|
}
|
|
710
1227
|
}
|
|
@@ -727,14 +1244,14 @@ var TuiRoutes = lazy(
|
|
|
727
1244
|
description: "Command executed successfully",
|
|
728
1245
|
content: {
|
|
729
1246
|
"application/json": {
|
|
730
|
-
schema:
|
|
1247
|
+
schema: resolver(z3.boolean())
|
|
731
1248
|
}
|
|
732
1249
|
}
|
|
733
1250
|
},
|
|
734
1251
|
...errors(400)
|
|
735
1252
|
}
|
|
736
1253
|
}),
|
|
737
|
-
|
|
1254
|
+
validator2("json", z3.object({ command: z3.string() })),
|
|
738
1255
|
async (c) => {
|
|
739
1256
|
const command = c.req.valid("json").command;
|
|
740
1257
|
await Bus.publish(TuiEvent.CommandExecute, {
|
|
@@ -768,13 +1285,13 @@ var TuiRoutes = lazy(
|
|
|
768
1285
|
description: "Toast notification shown successfully",
|
|
769
1286
|
content: {
|
|
770
1287
|
"application/json": {
|
|
771
|
-
schema:
|
|
1288
|
+
schema: resolver(z3.boolean())
|
|
772
1289
|
}
|
|
773
1290
|
}
|
|
774
1291
|
}
|
|
775
1292
|
}
|
|
776
1293
|
}),
|
|
777
|
-
|
|
1294
|
+
validator2("json", TuiEvent.ToastShow.properties),
|
|
778
1295
|
async (c) => {
|
|
779
1296
|
await Bus.publish(TuiEvent.ToastShow, c.req.valid("json"));
|
|
780
1297
|
return c.json(true);
|
|
@@ -790,14 +1307,14 @@ var TuiRoutes = lazy(
|
|
|
790
1307
|
description: "Event published successfully",
|
|
791
1308
|
content: {
|
|
792
1309
|
"application/json": {
|
|
793
|
-
schema:
|
|
1310
|
+
schema: resolver(z3.boolean())
|
|
794
1311
|
}
|
|
795
1312
|
}
|
|
796
1313
|
},
|
|
797
1314
|
...errors(400)
|
|
798
1315
|
}
|
|
799
1316
|
}),
|
|
800
|
-
|
|
1317
|
+
validator2(
|
|
801
1318
|
"json",
|
|
802
1319
|
z3.union(
|
|
803
1320
|
Object.values(TuiEvent).map((def) => {
|
|
@@ -826,14 +1343,14 @@ var TuiRoutes = lazy(
|
|
|
826
1343
|
description: "Session selected successfully",
|
|
827
1344
|
content: {
|
|
828
1345
|
"application/json": {
|
|
829
|
-
schema:
|
|
1346
|
+
schema: resolver(z3.boolean())
|
|
830
1347
|
}
|
|
831
1348
|
}
|
|
832
1349
|
},
|
|
833
1350
|
...errors(400, 404)
|
|
834
1351
|
}
|
|
835
1352
|
}),
|
|
836
|
-
|
|
1353
|
+
validator2("json", TuiEvent.SessionSelect.properties),
|
|
837
1354
|
async (c) => {
|
|
838
1355
|
const { sessionID } = c.req.valid("json");
|
|
839
1356
|
await Session.get(sessionID);
|
|
@@ -845,13 +1362,11 @@ var TuiRoutes = lazy(
|
|
|
845
1362
|
|
|
846
1363
|
// packages/opencode/src/server/routes/question.ts
|
|
847
1364
|
import { Hono as Hono3 } from "hono";
|
|
848
|
-
import { describeRoute as describeRoute2, validator as validator2 } from "hono-openapi";
|
|
849
|
-
import { resolver as resolver3 } from "hono-openapi";
|
|
850
1365
|
import z4 from "zod";
|
|
851
1366
|
var QuestionRoutes = lazy(
|
|
852
1367
|
() => new Hono3().get(
|
|
853
1368
|
"/",
|
|
854
|
-
|
|
1369
|
+
describeRoute({
|
|
855
1370
|
summary: "List pending questions",
|
|
856
1371
|
description: "Get all pending question requests across all sessions.",
|
|
857
1372
|
operationId: "question.list",
|
|
@@ -860,7 +1375,7 @@ var QuestionRoutes = lazy(
|
|
|
860
1375
|
description: "List of pending questions",
|
|
861
1376
|
content: {
|
|
862
1377
|
"application/json": {
|
|
863
|
-
schema:
|
|
1378
|
+
schema: resolver(Question.Request.array())
|
|
864
1379
|
}
|
|
865
1380
|
}
|
|
866
1381
|
}
|
|
@@ -872,7 +1387,7 @@ var QuestionRoutes = lazy(
|
|
|
872
1387
|
}
|
|
873
1388
|
).post(
|
|
874
1389
|
"/:requestID/reply",
|
|
875
|
-
|
|
1390
|
+
describeRoute({
|
|
876
1391
|
summary: "Reply to question request",
|
|
877
1392
|
description: "Provide answers to a question request from the AI assistant.",
|
|
878
1393
|
operationId: "question.reply",
|
|
@@ -881,7 +1396,7 @@ var QuestionRoutes = lazy(
|
|
|
881
1396
|
description: "Question answered successfully",
|
|
882
1397
|
content: {
|
|
883
1398
|
"application/json": {
|
|
884
|
-
schema:
|
|
1399
|
+
schema: resolver(z4.boolean())
|
|
885
1400
|
}
|
|
886
1401
|
}
|
|
887
1402
|
},
|
|
@@ -906,7 +1421,7 @@ var QuestionRoutes = lazy(
|
|
|
906
1421
|
}
|
|
907
1422
|
).post(
|
|
908
1423
|
"/:requestID/reject",
|
|
909
|
-
|
|
1424
|
+
describeRoute({
|
|
910
1425
|
summary: "Reject question request",
|
|
911
1426
|
description: "Reject a question request from the AI assistant.",
|
|
912
1427
|
operationId: "question.reject",
|
|
@@ -915,7 +1430,7 @@ var QuestionRoutes = lazy(
|
|
|
915
1430
|
description: "Question rejected successfully",
|
|
916
1431
|
content: {
|
|
917
1432
|
"application/json": {
|
|
918
|
-
schema:
|
|
1433
|
+
schema: resolver(z4.boolean())
|
|
919
1434
|
}
|
|
920
1435
|
}
|
|
921
1436
|
},
|
|
@@ -938,12 +1453,11 @@ var QuestionRoutes = lazy(
|
|
|
938
1453
|
|
|
939
1454
|
// packages/opencode/src/server/routes/permission.ts
|
|
940
1455
|
import { Hono as Hono4 } from "hono";
|
|
941
|
-
import { describeRoute as describeRoute3, validator as validator3, resolver as resolver4 } from "hono-openapi";
|
|
942
1456
|
import z5 from "zod";
|
|
943
1457
|
var PermissionRoutes = lazy(
|
|
944
1458
|
() => new Hono4().post(
|
|
945
1459
|
"/:requestID/reply",
|
|
946
|
-
|
|
1460
|
+
describeRoute({
|
|
947
1461
|
summary: "Respond to permission request",
|
|
948
1462
|
description: "Approve or deny a permission request from the AI assistant.",
|
|
949
1463
|
operationId: "permission.reply",
|
|
@@ -952,20 +1466,20 @@ var PermissionRoutes = lazy(
|
|
|
952
1466
|
description: "Permission processed successfully",
|
|
953
1467
|
content: {
|
|
954
1468
|
"application/json": {
|
|
955
|
-
schema:
|
|
1469
|
+
schema: resolver(z5.boolean())
|
|
956
1470
|
}
|
|
957
1471
|
}
|
|
958
1472
|
},
|
|
959
1473
|
...errors(400, 404)
|
|
960
1474
|
}
|
|
961
1475
|
}),
|
|
962
|
-
|
|
1476
|
+
validator2(
|
|
963
1477
|
"param",
|
|
964
1478
|
z5.object({
|
|
965
1479
|
requestID: PermissionID.zod
|
|
966
1480
|
})
|
|
967
1481
|
),
|
|
968
|
-
|
|
1482
|
+
validator2("json", z5.object({ reply: Permission.Reply, message: z5.string().optional() })),
|
|
969
1483
|
async (c) => {
|
|
970
1484
|
const params = c.req.valid("param");
|
|
971
1485
|
const json = c.req.valid("json");
|
|
@@ -978,7 +1492,7 @@ var PermissionRoutes = lazy(
|
|
|
978
1492
|
}
|
|
979
1493
|
).get(
|
|
980
1494
|
"/",
|
|
981
|
-
|
|
1495
|
+
describeRoute({
|
|
982
1496
|
summary: "List pending permissions",
|
|
983
1497
|
description: "Get all pending permission requests across all sessions.",
|
|
984
1498
|
operationId: "permission.list",
|
|
@@ -987,7 +1501,7 @@ var PermissionRoutes = lazy(
|
|
|
987
1501
|
description: "List of pending permissions",
|
|
988
1502
|
content: {
|
|
989
1503
|
"application/json": {
|
|
990
|
-
schema:
|
|
1504
|
+
schema: resolver(Permission.Request.array())
|
|
991
1505
|
}
|
|
992
1506
|
}
|
|
993
1507
|
}
|
|
@@ -1002,13 +1516,11 @@ var PermissionRoutes = lazy(
|
|
|
1002
1516
|
|
|
1003
1517
|
// packages/opencode/src/server/routes/project.ts
|
|
1004
1518
|
import { Hono as Hono5 } from "hono";
|
|
1005
|
-
import { describeRoute as describeRoute4, validator as validator4 } from "hono-openapi";
|
|
1006
|
-
import { resolver as resolver5 } from "hono-openapi";
|
|
1007
1519
|
import z6 from "zod";
|
|
1008
1520
|
var ProjectRoutes = lazy(
|
|
1009
1521
|
() => new Hono5().get(
|
|
1010
1522
|
"/",
|
|
1011
|
-
|
|
1523
|
+
describeRoute({
|
|
1012
1524
|
summary: "List all projects",
|
|
1013
1525
|
description: "Get a list of projects that have been opened with OpenCode.",
|
|
1014
1526
|
operationId: "project.list",
|
|
@@ -1017,7 +1529,7 @@ var ProjectRoutes = lazy(
|
|
|
1017
1529
|
description: "List of projects",
|
|
1018
1530
|
content: {
|
|
1019
1531
|
"application/json": {
|
|
1020
|
-
schema:
|
|
1532
|
+
schema: resolver(Project.Info.array())
|
|
1021
1533
|
}
|
|
1022
1534
|
}
|
|
1023
1535
|
}
|
|
@@ -1029,7 +1541,7 @@ var ProjectRoutes = lazy(
|
|
|
1029
1541
|
}
|
|
1030
1542
|
).get(
|
|
1031
1543
|
"/current",
|
|
1032
|
-
|
|
1544
|
+
describeRoute({
|
|
1033
1545
|
summary: "Get current project",
|
|
1034
1546
|
description: "Retrieve the currently active project that OpenCode is working with.",
|
|
1035
1547
|
operationId: "project.current",
|
|
@@ -1038,7 +1550,7 @@ var ProjectRoutes = lazy(
|
|
|
1038
1550
|
description: "Current project information",
|
|
1039
1551
|
content: {
|
|
1040
1552
|
"application/json": {
|
|
1041
|
-
schema:
|
|
1553
|
+
schema: resolver(Project.Info)
|
|
1042
1554
|
}
|
|
1043
1555
|
}
|
|
1044
1556
|
}
|
|
@@ -1049,7 +1561,7 @@ var ProjectRoutes = lazy(
|
|
|
1049
1561
|
}
|
|
1050
1562
|
).post(
|
|
1051
1563
|
"/git/init",
|
|
1052
|
-
|
|
1564
|
+
describeRoute({
|
|
1053
1565
|
summary: "Initialize git repository",
|
|
1054
1566
|
description: "Create a git repository for the current project and return the refreshed project info.",
|
|
1055
1567
|
operationId: "project.initGit",
|
|
@@ -1058,7 +1570,7 @@ var ProjectRoutes = lazy(
|
|
|
1058
1570
|
description: "Project information after git initialization",
|
|
1059
1571
|
content: {
|
|
1060
1572
|
"application/json": {
|
|
1061
|
-
schema:
|
|
1573
|
+
schema: resolver(Project.Info)
|
|
1062
1574
|
}
|
|
1063
1575
|
}
|
|
1064
1576
|
}
|
|
@@ -1082,7 +1594,7 @@ var ProjectRoutes = lazy(
|
|
|
1082
1594
|
}
|
|
1083
1595
|
).patch(
|
|
1084
1596
|
"/:projectID",
|
|
1085
|
-
|
|
1597
|
+
describeRoute({
|
|
1086
1598
|
summary: "Update project",
|
|
1087
1599
|
description: "Update project properties such as name, icon, and commands.",
|
|
1088
1600
|
operationId: "project.update",
|
|
@@ -1091,15 +1603,15 @@ var ProjectRoutes = lazy(
|
|
|
1091
1603
|
description: "Updated project information",
|
|
1092
1604
|
content: {
|
|
1093
1605
|
"application/json": {
|
|
1094
|
-
schema:
|
|
1606
|
+
schema: resolver(Project.Info)
|
|
1095
1607
|
}
|
|
1096
1608
|
}
|
|
1097
1609
|
},
|
|
1098
1610
|
...errors(400, 404)
|
|
1099
1611
|
}
|
|
1100
1612
|
}),
|
|
1101
|
-
|
|
1102
|
-
|
|
1613
|
+
validator2("param", z6.object({ projectID: ProjectID.zod })),
|
|
1614
|
+
validator2("json", Project.UpdateInput.omit({ projectID: true })),
|
|
1103
1615
|
async (c) => {
|
|
1104
1616
|
const projectID = c.req.valid("param").projectID;
|
|
1105
1617
|
const body = c.req.valid("json");
|
|
@@ -1112,13 +1624,12 @@ var ProjectRoutes = lazy(
|
|
|
1112
1624
|
// packages/opencode/src/server/routes/session.ts
|
|
1113
1625
|
import { Hono as Hono6 } from "hono";
|
|
1114
1626
|
import { stream } from "hono/streaming";
|
|
1115
|
-
import { describeRoute as describeRoute5, validator as validator5, resolver as resolver6 } from "hono-openapi";
|
|
1116
1627
|
import z7 from "zod";
|
|
1117
1628
|
var log = Log.create({ service: "server" });
|
|
1118
1629
|
var SessionRoutes = lazy(
|
|
1119
1630
|
() => new Hono6().get(
|
|
1120
1631
|
"/",
|
|
1121
|
-
|
|
1632
|
+
describeRoute({
|
|
1122
1633
|
summary: "List sessions",
|
|
1123
1634
|
description: "Get a list of all OpenCode sessions, sorted by most recently updated.",
|
|
1124
1635
|
operationId: "session.list",
|
|
@@ -1127,13 +1638,13 @@ var SessionRoutes = lazy(
|
|
|
1127
1638
|
description: "List of sessions",
|
|
1128
1639
|
content: {
|
|
1129
1640
|
"application/json": {
|
|
1130
|
-
schema:
|
|
1641
|
+
schema: resolver(Session.Info.array())
|
|
1131
1642
|
}
|
|
1132
1643
|
}
|
|
1133
1644
|
}
|
|
1134
1645
|
}
|
|
1135
1646
|
}),
|
|
1136
|
-
|
|
1647
|
+
validator2(
|
|
1137
1648
|
"query",
|
|
1138
1649
|
z7.object({
|
|
1139
1650
|
directory: z7.string().optional().meta({ description: "Filter sessions by project directory" }),
|
|
@@ -1159,7 +1670,7 @@ var SessionRoutes = lazy(
|
|
|
1159
1670
|
}
|
|
1160
1671
|
).get(
|
|
1161
1672
|
"/status",
|
|
1162
|
-
|
|
1673
|
+
describeRoute({
|
|
1163
1674
|
summary: "Get session status",
|
|
1164
1675
|
description: "Retrieve the current status of all sessions, including active, idle, and completed states.",
|
|
1165
1676
|
operationId: "session.status",
|
|
@@ -1168,7 +1679,7 @@ var SessionRoutes = lazy(
|
|
|
1168
1679
|
description: "Get session status",
|
|
1169
1680
|
content: {
|
|
1170
1681
|
"application/json": {
|
|
1171
|
-
schema:
|
|
1682
|
+
schema: resolver(z7.record(z7.string(), SessionStatus.Info))
|
|
1172
1683
|
}
|
|
1173
1684
|
}
|
|
1174
1685
|
},
|
|
@@ -1181,7 +1692,7 @@ var SessionRoutes = lazy(
|
|
|
1181
1692
|
}
|
|
1182
1693
|
).get(
|
|
1183
1694
|
"/:sessionID",
|
|
1184
|
-
|
|
1695
|
+
describeRoute({
|
|
1185
1696
|
summary: "Get session",
|
|
1186
1697
|
description: "Retrieve detailed information about a specific OpenCode session.",
|
|
1187
1698
|
tags: ["Session"],
|
|
@@ -1191,14 +1702,14 @@ var SessionRoutes = lazy(
|
|
|
1191
1702
|
description: "Get session",
|
|
1192
1703
|
content: {
|
|
1193
1704
|
"application/json": {
|
|
1194
|
-
schema:
|
|
1705
|
+
schema: resolver(Session.Info)
|
|
1195
1706
|
}
|
|
1196
1707
|
}
|
|
1197
1708
|
},
|
|
1198
1709
|
...errors(400, 404)
|
|
1199
1710
|
}
|
|
1200
1711
|
}),
|
|
1201
|
-
|
|
1712
|
+
validator2(
|
|
1202
1713
|
"param",
|
|
1203
1714
|
z7.object({
|
|
1204
1715
|
sessionID: Session.get.schema
|
|
@@ -1212,7 +1723,7 @@ var SessionRoutes = lazy(
|
|
|
1212
1723
|
}
|
|
1213
1724
|
).get(
|
|
1214
1725
|
"/:sessionID/children",
|
|
1215
|
-
|
|
1726
|
+
describeRoute({
|
|
1216
1727
|
summary: "Get session children",
|
|
1217
1728
|
tags: ["Session"],
|
|
1218
1729
|
description: "Retrieve all child sessions that were forked from the specified parent session.",
|
|
@@ -1222,14 +1733,14 @@ var SessionRoutes = lazy(
|
|
|
1222
1733
|
description: "List of children",
|
|
1223
1734
|
content: {
|
|
1224
1735
|
"application/json": {
|
|
1225
|
-
schema:
|
|
1736
|
+
schema: resolver(Session.Info.array())
|
|
1226
1737
|
}
|
|
1227
1738
|
}
|
|
1228
1739
|
},
|
|
1229
1740
|
...errors(400, 404)
|
|
1230
1741
|
}
|
|
1231
1742
|
}),
|
|
1232
|
-
|
|
1743
|
+
validator2(
|
|
1233
1744
|
"param",
|
|
1234
1745
|
z7.object({
|
|
1235
1746
|
sessionID: Session.children.schema
|
|
@@ -1242,7 +1753,7 @@ var SessionRoutes = lazy(
|
|
|
1242
1753
|
}
|
|
1243
1754
|
).get(
|
|
1244
1755
|
"/:sessionID/todo",
|
|
1245
|
-
|
|
1756
|
+
describeRoute({
|
|
1246
1757
|
summary: "Get session todos",
|
|
1247
1758
|
description: "Retrieve the todo list associated with a specific session, showing tasks and action items.",
|
|
1248
1759
|
operationId: "session.todo",
|
|
@@ -1251,14 +1762,14 @@ var SessionRoutes = lazy(
|
|
|
1251
1762
|
description: "Todo list",
|
|
1252
1763
|
content: {
|
|
1253
1764
|
"application/json": {
|
|
1254
|
-
schema:
|
|
1765
|
+
schema: resolver(Todo.Info.array())
|
|
1255
1766
|
}
|
|
1256
1767
|
}
|
|
1257
1768
|
},
|
|
1258
1769
|
...errors(400, 404)
|
|
1259
1770
|
}
|
|
1260
1771
|
}),
|
|
1261
|
-
|
|
1772
|
+
validator2(
|
|
1262
1773
|
"param",
|
|
1263
1774
|
z7.object({
|
|
1264
1775
|
sessionID: SessionID.zod
|
|
@@ -1271,7 +1782,7 @@ var SessionRoutes = lazy(
|
|
|
1271
1782
|
}
|
|
1272
1783
|
).post(
|
|
1273
1784
|
"/",
|
|
1274
|
-
|
|
1785
|
+
describeRoute({
|
|
1275
1786
|
summary: "Create session",
|
|
1276
1787
|
description: "Create a new OpenCode session for interacting with AI assistants and managing conversations.",
|
|
1277
1788
|
operationId: "session.create",
|
|
@@ -1281,13 +1792,13 @@ var SessionRoutes = lazy(
|
|
|
1281
1792
|
description: "Successfully created session",
|
|
1282
1793
|
content: {
|
|
1283
1794
|
"application/json": {
|
|
1284
|
-
schema:
|
|
1795
|
+
schema: resolver(Session.Info)
|
|
1285
1796
|
}
|
|
1286
1797
|
}
|
|
1287
1798
|
}
|
|
1288
1799
|
}
|
|
1289
1800
|
}),
|
|
1290
|
-
|
|
1801
|
+
validator2("json", Session.create.schema.optional()),
|
|
1291
1802
|
async (c) => {
|
|
1292
1803
|
const body = c.req.valid("json") ?? {};
|
|
1293
1804
|
const session = await Session.create(body);
|
|
@@ -1295,7 +1806,7 @@ var SessionRoutes = lazy(
|
|
|
1295
1806
|
}
|
|
1296
1807
|
).delete(
|
|
1297
1808
|
"/:sessionID",
|
|
1298
|
-
|
|
1809
|
+
describeRoute({
|
|
1299
1810
|
summary: "Delete session",
|
|
1300
1811
|
description: "Delete a session and permanently remove all associated data, including messages and history.",
|
|
1301
1812
|
operationId: "session.delete",
|
|
@@ -1304,14 +1815,14 @@ var SessionRoutes = lazy(
|
|
|
1304
1815
|
description: "Successfully deleted session",
|
|
1305
1816
|
content: {
|
|
1306
1817
|
"application/json": {
|
|
1307
|
-
schema:
|
|
1818
|
+
schema: resolver(z7.boolean())
|
|
1308
1819
|
}
|
|
1309
1820
|
}
|
|
1310
1821
|
},
|
|
1311
1822
|
...errors(400, 404)
|
|
1312
1823
|
}
|
|
1313
1824
|
}),
|
|
1314
|
-
|
|
1825
|
+
validator2(
|
|
1315
1826
|
"param",
|
|
1316
1827
|
z7.object({
|
|
1317
1828
|
sessionID: Session.remove.schema
|
|
@@ -1324,7 +1835,7 @@ var SessionRoutes = lazy(
|
|
|
1324
1835
|
}
|
|
1325
1836
|
).patch(
|
|
1326
1837
|
"/:sessionID",
|
|
1327
|
-
|
|
1838
|
+
describeRoute({
|
|
1328
1839
|
summary: "Update session",
|
|
1329
1840
|
description: "Update properties of an existing session, such as title or other metadata.",
|
|
1330
1841
|
operationId: "session.update",
|
|
@@ -1333,20 +1844,20 @@ var SessionRoutes = lazy(
|
|
|
1333
1844
|
description: "Successfully updated session",
|
|
1334
1845
|
content: {
|
|
1335
1846
|
"application/json": {
|
|
1336
|
-
schema:
|
|
1847
|
+
schema: resolver(Session.Info)
|
|
1337
1848
|
}
|
|
1338
1849
|
}
|
|
1339
1850
|
},
|
|
1340
1851
|
...errors(400, 404)
|
|
1341
1852
|
}
|
|
1342
1853
|
}),
|
|
1343
|
-
|
|
1854
|
+
validator2(
|
|
1344
1855
|
"param",
|
|
1345
1856
|
z7.object({
|
|
1346
1857
|
sessionID: SessionID.zod
|
|
1347
1858
|
})
|
|
1348
1859
|
),
|
|
1349
|
-
|
|
1860
|
+
validator2(
|
|
1350
1861
|
"json",
|
|
1351
1862
|
z7.object({
|
|
1352
1863
|
title: z7.string().optional(),
|
|
@@ -1369,7 +1880,7 @@ var SessionRoutes = lazy(
|
|
|
1369
1880
|
}
|
|
1370
1881
|
).post(
|
|
1371
1882
|
"/:sessionID/init",
|
|
1372
|
-
|
|
1883
|
+
describeRoute({
|
|
1373
1884
|
summary: "Initialize session",
|
|
1374
1885
|
description: "Analyze the current application and create an AGENTS.md file with project-specific agent configurations.",
|
|
1375
1886
|
operationId: "session.init",
|
|
@@ -1378,20 +1889,20 @@ var SessionRoutes = lazy(
|
|
|
1378
1889
|
description: "200",
|
|
1379
1890
|
content: {
|
|
1380
1891
|
"application/json": {
|
|
1381
|
-
schema:
|
|
1892
|
+
schema: resolver(z7.boolean())
|
|
1382
1893
|
}
|
|
1383
1894
|
}
|
|
1384
1895
|
},
|
|
1385
1896
|
...errors(400, 404)
|
|
1386
1897
|
}
|
|
1387
1898
|
}),
|
|
1388
|
-
|
|
1899
|
+
validator2(
|
|
1389
1900
|
"param",
|
|
1390
1901
|
z7.object({
|
|
1391
1902
|
sessionID: SessionID.zod
|
|
1392
1903
|
})
|
|
1393
1904
|
),
|
|
1394
|
-
|
|
1905
|
+
validator2("json", Session.initialize.schema.omit({ sessionID: true })),
|
|
1395
1906
|
async (c) => {
|
|
1396
1907
|
const sessionID = c.req.valid("param").sessionID;
|
|
1397
1908
|
const body = c.req.valid("json");
|
|
@@ -1400,7 +1911,7 @@ var SessionRoutes = lazy(
|
|
|
1400
1911
|
}
|
|
1401
1912
|
).post(
|
|
1402
1913
|
"/:sessionID/fork",
|
|
1403
|
-
|
|
1914
|
+
describeRoute({
|
|
1404
1915
|
summary: "Fork session",
|
|
1405
1916
|
description: "Create a new session by forking an existing session at a specific message point.",
|
|
1406
1917
|
operationId: "session.fork",
|
|
@@ -1409,19 +1920,19 @@ var SessionRoutes = lazy(
|
|
|
1409
1920
|
description: "200",
|
|
1410
1921
|
content: {
|
|
1411
1922
|
"application/json": {
|
|
1412
|
-
schema:
|
|
1923
|
+
schema: resolver(Session.Info)
|
|
1413
1924
|
}
|
|
1414
1925
|
}
|
|
1415
1926
|
}
|
|
1416
1927
|
}
|
|
1417
1928
|
}),
|
|
1418
|
-
|
|
1929
|
+
validator2(
|
|
1419
1930
|
"param",
|
|
1420
1931
|
z7.object({
|
|
1421
1932
|
sessionID: Session.fork.schema.shape.sessionID
|
|
1422
1933
|
})
|
|
1423
1934
|
),
|
|
1424
|
-
|
|
1935
|
+
validator2("json", Session.fork.schema.omit({ sessionID: true })),
|
|
1425
1936
|
async (c) => {
|
|
1426
1937
|
const sessionID = c.req.valid("param").sessionID;
|
|
1427
1938
|
const body = c.req.valid("json");
|
|
@@ -1430,7 +1941,7 @@ var SessionRoutes = lazy(
|
|
|
1430
1941
|
}
|
|
1431
1942
|
).post(
|
|
1432
1943
|
"/:sessionID/abort",
|
|
1433
|
-
|
|
1944
|
+
describeRoute({
|
|
1434
1945
|
summary: "Abort session",
|
|
1435
1946
|
description: "Abort an active session and stop any ongoing AI processing or command execution.",
|
|
1436
1947
|
operationId: "session.abort",
|
|
@@ -1439,14 +1950,14 @@ var SessionRoutes = lazy(
|
|
|
1439
1950
|
description: "Aborted session",
|
|
1440
1951
|
content: {
|
|
1441
1952
|
"application/json": {
|
|
1442
|
-
schema:
|
|
1953
|
+
schema: resolver(z7.boolean())
|
|
1443
1954
|
}
|
|
1444
1955
|
}
|
|
1445
1956
|
},
|
|
1446
1957
|
...errors(400, 404)
|
|
1447
1958
|
}
|
|
1448
1959
|
}),
|
|
1449
|
-
|
|
1960
|
+
validator2(
|
|
1450
1961
|
"param",
|
|
1451
1962
|
z7.object({
|
|
1452
1963
|
sessionID: SessionID.zod
|
|
@@ -1458,7 +1969,7 @@ var SessionRoutes = lazy(
|
|
|
1458
1969
|
}
|
|
1459
1970
|
).post(
|
|
1460
1971
|
"/:sessionID/share",
|
|
1461
|
-
|
|
1972
|
+
describeRoute({
|
|
1462
1973
|
summary: "Share session",
|
|
1463
1974
|
description: "Create a shareable link for a session, allowing others to view the conversation.",
|
|
1464
1975
|
operationId: "session.share",
|
|
@@ -1467,14 +1978,14 @@ var SessionRoutes = lazy(
|
|
|
1467
1978
|
description: "Successfully shared session",
|
|
1468
1979
|
content: {
|
|
1469
1980
|
"application/json": {
|
|
1470
|
-
schema:
|
|
1981
|
+
schema: resolver(Session.Info)
|
|
1471
1982
|
}
|
|
1472
1983
|
}
|
|
1473
1984
|
},
|
|
1474
1985
|
...errors(400, 404)
|
|
1475
1986
|
}
|
|
1476
1987
|
}),
|
|
1477
|
-
|
|
1988
|
+
validator2(
|
|
1478
1989
|
"param",
|
|
1479
1990
|
z7.object({
|
|
1480
1991
|
sessionID: SessionID.zod
|
|
@@ -1488,7 +1999,7 @@ var SessionRoutes = lazy(
|
|
|
1488
1999
|
}
|
|
1489
2000
|
).get(
|
|
1490
2001
|
"/:sessionID/diff",
|
|
1491
|
-
|
|
2002
|
+
describeRoute({
|
|
1492
2003
|
summary: "Get message diff",
|
|
1493
2004
|
description: "Get the file changes (diff) that resulted from a specific user message in the session.",
|
|
1494
2005
|
operationId: "session.diff",
|
|
@@ -1497,19 +2008,19 @@ var SessionRoutes = lazy(
|
|
|
1497
2008
|
description: "Successfully retrieved diff",
|
|
1498
2009
|
content: {
|
|
1499
2010
|
"application/json": {
|
|
1500
|
-
schema:
|
|
2011
|
+
schema: resolver(Snapshot.FileDiff.array())
|
|
1501
2012
|
}
|
|
1502
2013
|
}
|
|
1503
2014
|
}
|
|
1504
2015
|
}
|
|
1505
2016
|
}),
|
|
1506
|
-
|
|
2017
|
+
validator2(
|
|
1507
2018
|
"param",
|
|
1508
2019
|
z7.object({
|
|
1509
2020
|
sessionID: SessionSummary.DiffInput.shape.sessionID
|
|
1510
2021
|
})
|
|
1511
2022
|
),
|
|
1512
|
-
|
|
2023
|
+
validator2(
|
|
1513
2024
|
"query",
|
|
1514
2025
|
z7.object({
|
|
1515
2026
|
messageID: SessionSummary.DiffInput.shape.messageID
|
|
@@ -1526,7 +2037,7 @@ var SessionRoutes = lazy(
|
|
|
1526
2037
|
}
|
|
1527
2038
|
).delete(
|
|
1528
2039
|
"/:sessionID/share",
|
|
1529
|
-
|
|
2040
|
+
describeRoute({
|
|
1530
2041
|
summary: "Unshare session",
|
|
1531
2042
|
description: "Remove the shareable link for a session, making it private again.",
|
|
1532
2043
|
operationId: "session.unshare",
|
|
@@ -1535,14 +2046,14 @@ var SessionRoutes = lazy(
|
|
|
1535
2046
|
description: "Successfully unshared session",
|
|
1536
2047
|
content: {
|
|
1537
2048
|
"application/json": {
|
|
1538
|
-
schema:
|
|
2049
|
+
schema: resolver(Session.Info)
|
|
1539
2050
|
}
|
|
1540
2051
|
}
|
|
1541
2052
|
},
|
|
1542
2053
|
...errors(400, 404)
|
|
1543
2054
|
}
|
|
1544
2055
|
}),
|
|
1545
|
-
|
|
2056
|
+
validator2(
|
|
1546
2057
|
"param",
|
|
1547
2058
|
z7.object({
|
|
1548
2059
|
sessionID: Session.unshare.schema
|
|
@@ -1556,7 +2067,7 @@ var SessionRoutes = lazy(
|
|
|
1556
2067
|
}
|
|
1557
2068
|
).post(
|
|
1558
2069
|
"/:sessionID/summarize",
|
|
1559
|
-
|
|
2070
|
+
describeRoute({
|
|
1560
2071
|
summary: "Summarize session",
|
|
1561
2072
|
description: "Generate a concise summary of the session using AI compaction to preserve key information.",
|
|
1562
2073
|
operationId: "session.summarize",
|
|
@@ -1565,20 +2076,20 @@ var SessionRoutes = lazy(
|
|
|
1565
2076
|
description: "Summarized session",
|
|
1566
2077
|
content: {
|
|
1567
2078
|
"application/json": {
|
|
1568
|
-
schema:
|
|
2079
|
+
schema: resolver(z7.boolean())
|
|
1569
2080
|
}
|
|
1570
2081
|
}
|
|
1571
2082
|
},
|
|
1572
2083
|
...errors(400, 404)
|
|
1573
2084
|
}
|
|
1574
2085
|
}),
|
|
1575
|
-
|
|
2086
|
+
validator2(
|
|
1576
2087
|
"param",
|
|
1577
2088
|
z7.object({
|
|
1578
2089
|
sessionID: SessionID.zod
|
|
1579
2090
|
})
|
|
1580
2091
|
),
|
|
1581
|
-
|
|
2092
|
+
validator2(
|
|
1582
2093
|
"json",
|
|
1583
2094
|
z7.object({
|
|
1584
2095
|
providerID: ProviderID.zod,
|
|
@@ -1614,7 +2125,7 @@ var SessionRoutes = lazy(
|
|
|
1614
2125
|
}
|
|
1615
2126
|
).get(
|
|
1616
2127
|
"/:sessionID/message",
|
|
1617
|
-
|
|
2128
|
+
describeRoute({
|
|
1618
2129
|
summary: "Get session messages",
|
|
1619
2130
|
description: "Retrieve all messages in a session, including user prompts and AI responses.",
|
|
1620
2131
|
operationId: "session.messages",
|
|
@@ -1623,20 +2134,20 @@ var SessionRoutes = lazy(
|
|
|
1623
2134
|
description: "List of messages",
|
|
1624
2135
|
content: {
|
|
1625
2136
|
"application/json": {
|
|
1626
|
-
schema:
|
|
2137
|
+
schema: resolver(MessageV2.WithParts.array())
|
|
1627
2138
|
}
|
|
1628
2139
|
}
|
|
1629
2140
|
},
|
|
1630
2141
|
...errors(400, 404)
|
|
1631
2142
|
}
|
|
1632
2143
|
}),
|
|
1633
|
-
|
|
2144
|
+
validator2(
|
|
1634
2145
|
"param",
|
|
1635
2146
|
z7.object({
|
|
1636
2147
|
sessionID: SessionID.zod
|
|
1637
2148
|
})
|
|
1638
2149
|
),
|
|
1639
|
-
|
|
2150
|
+
validator2(
|
|
1640
2151
|
"query",
|
|
1641
2152
|
z7.object({
|
|
1642
2153
|
limit: z7.coerce.number().int().min(0).optional().meta({ description: "Maximum number of messages to return" }),
|
|
@@ -1687,7 +2198,7 @@ var SessionRoutes = lazy(
|
|
|
1687
2198
|
}
|
|
1688
2199
|
).get(
|
|
1689
2200
|
"/:sessionID/message/:messageID",
|
|
1690
|
-
|
|
2201
|
+
describeRoute({
|
|
1691
2202
|
summary: "Get message",
|
|
1692
2203
|
description: "Retrieve a specific message from a session by its message ID.",
|
|
1693
2204
|
operationId: "session.message",
|
|
@@ -1696,7 +2207,7 @@ var SessionRoutes = lazy(
|
|
|
1696
2207
|
description: "Message",
|
|
1697
2208
|
content: {
|
|
1698
2209
|
"application/json": {
|
|
1699
|
-
schema:
|
|
2210
|
+
schema: resolver(
|
|
1700
2211
|
z7.object({
|
|
1701
2212
|
info: MessageV2.Info,
|
|
1702
2213
|
parts: MessageV2.Part.array()
|
|
@@ -1708,7 +2219,7 @@ var SessionRoutes = lazy(
|
|
|
1708
2219
|
...errors(400, 404)
|
|
1709
2220
|
}
|
|
1710
2221
|
}),
|
|
1711
|
-
|
|
2222
|
+
validator2(
|
|
1712
2223
|
"param",
|
|
1713
2224
|
z7.object({
|
|
1714
2225
|
sessionID: SessionID.zod,
|
|
@@ -1725,7 +2236,7 @@ var SessionRoutes = lazy(
|
|
|
1725
2236
|
}
|
|
1726
2237
|
).delete(
|
|
1727
2238
|
"/:sessionID/message/:messageID",
|
|
1728
|
-
|
|
2239
|
+
describeRoute({
|
|
1729
2240
|
summary: "Delete message",
|
|
1730
2241
|
description: "Permanently delete a specific message (and all of its parts) from a session. This does not revert any file changes that may have been made while processing the message.",
|
|
1731
2242
|
operationId: "session.deleteMessage",
|
|
@@ -1734,14 +2245,14 @@ var SessionRoutes = lazy(
|
|
|
1734
2245
|
description: "Successfully deleted message",
|
|
1735
2246
|
content: {
|
|
1736
2247
|
"application/json": {
|
|
1737
|
-
schema:
|
|
2248
|
+
schema: resolver(z7.boolean())
|
|
1738
2249
|
}
|
|
1739
2250
|
}
|
|
1740
2251
|
},
|
|
1741
2252
|
...errors(400, 404)
|
|
1742
2253
|
}
|
|
1743
2254
|
}),
|
|
1744
|
-
|
|
2255
|
+
validator2(
|
|
1745
2256
|
"param",
|
|
1746
2257
|
z7.object({
|
|
1747
2258
|
sessionID: SessionID.zod,
|
|
@@ -1759,7 +2270,7 @@ var SessionRoutes = lazy(
|
|
|
1759
2270
|
}
|
|
1760
2271
|
).delete(
|
|
1761
2272
|
"/:sessionID/message/:messageID/part/:partID",
|
|
1762
|
-
|
|
2273
|
+
describeRoute({
|
|
1763
2274
|
description: "Delete a part from a message",
|
|
1764
2275
|
operationId: "part.delete",
|
|
1765
2276
|
responses: {
|
|
@@ -1767,14 +2278,14 @@ var SessionRoutes = lazy(
|
|
|
1767
2278
|
description: "Successfully deleted part",
|
|
1768
2279
|
content: {
|
|
1769
2280
|
"application/json": {
|
|
1770
|
-
schema:
|
|
2281
|
+
schema: resolver(z7.boolean())
|
|
1771
2282
|
}
|
|
1772
2283
|
}
|
|
1773
2284
|
},
|
|
1774
2285
|
...errors(400, 404)
|
|
1775
2286
|
}
|
|
1776
2287
|
}),
|
|
1777
|
-
|
|
2288
|
+
validator2(
|
|
1778
2289
|
"param",
|
|
1779
2290
|
z7.object({
|
|
1780
2291
|
sessionID: SessionID.zod,
|
|
@@ -1793,7 +2304,7 @@ var SessionRoutes = lazy(
|
|
|
1793
2304
|
}
|
|
1794
2305
|
).patch(
|
|
1795
2306
|
"/:sessionID/message/:messageID/part/:partID",
|
|
1796
|
-
|
|
2307
|
+
describeRoute({
|
|
1797
2308
|
description: "Update a part in a message",
|
|
1798
2309
|
operationId: "part.update",
|
|
1799
2310
|
responses: {
|
|
@@ -1801,14 +2312,14 @@ var SessionRoutes = lazy(
|
|
|
1801
2312
|
description: "Successfully updated part",
|
|
1802
2313
|
content: {
|
|
1803
2314
|
"application/json": {
|
|
1804
|
-
schema:
|
|
2315
|
+
schema: resolver(MessageV2.Part)
|
|
1805
2316
|
}
|
|
1806
2317
|
}
|
|
1807
2318
|
},
|
|
1808
2319
|
...errors(400, 404)
|
|
1809
2320
|
}
|
|
1810
2321
|
}),
|
|
1811
|
-
|
|
2322
|
+
validator2(
|
|
1812
2323
|
"param",
|
|
1813
2324
|
z7.object({
|
|
1814
2325
|
sessionID: SessionID.zod,
|
|
@@ -1816,7 +2327,7 @@ var SessionRoutes = lazy(
|
|
|
1816
2327
|
partID: PartID.zod
|
|
1817
2328
|
})
|
|
1818
2329
|
),
|
|
1819
|
-
|
|
2330
|
+
validator2("json", MessageV2.Part),
|
|
1820
2331
|
async (c) => {
|
|
1821
2332
|
const params = c.req.valid("param");
|
|
1822
2333
|
const body = c.req.valid("json");
|
|
@@ -1830,7 +2341,7 @@ var SessionRoutes = lazy(
|
|
|
1830
2341
|
}
|
|
1831
2342
|
).post(
|
|
1832
2343
|
"/:sessionID/message",
|
|
1833
|
-
|
|
2344
|
+
describeRoute({
|
|
1834
2345
|
summary: "Send message",
|
|
1835
2346
|
description: "Create and send a new message to a session, streaming the AI response.",
|
|
1836
2347
|
operationId: "session.prompt",
|
|
@@ -1839,7 +2350,7 @@ var SessionRoutes = lazy(
|
|
|
1839
2350
|
description: "Created message",
|
|
1840
2351
|
content: {
|
|
1841
2352
|
"application/json": {
|
|
1842
|
-
schema:
|
|
2353
|
+
schema: resolver(
|
|
1843
2354
|
z7.object({
|
|
1844
2355
|
info: MessageV2.Assistant,
|
|
1845
2356
|
parts: MessageV2.Part.array()
|
|
@@ -1851,13 +2362,13 @@ var SessionRoutes = lazy(
|
|
|
1851
2362
|
...errors(400, 404)
|
|
1852
2363
|
}
|
|
1853
2364
|
}),
|
|
1854
|
-
|
|
2365
|
+
validator2(
|
|
1855
2366
|
"param",
|
|
1856
2367
|
z7.object({
|
|
1857
2368
|
sessionID: SessionID.zod
|
|
1858
2369
|
})
|
|
1859
2370
|
),
|
|
1860
|
-
|
|
2371
|
+
validator2("json", SessionPrompt.PromptInput.omit({ sessionID: true })),
|
|
1861
2372
|
async (c) => {
|
|
1862
2373
|
c.status(200);
|
|
1863
2374
|
c.header("Content-Type", "application/json");
|
|
@@ -1870,7 +2381,7 @@ var SessionRoutes = lazy(
|
|
|
1870
2381
|
}
|
|
1871
2382
|
).post(
|
|
1872
2383
|
"/:sessionID/prompt_async",
|
|
1873
|
-
|
|
2384
|
+
describeRoute({
|
|
1874
2385
|
summary: "Send async message",
|
|
1875
2386
|
description: "Create and send a new message to a session asynchronously, starting the session if needed and returning immediately.",
|
|
1876
2387
|
operationId: "session.prompt_async",
|
|
@@ -1881,13 +2392,13 @@ var SessionRoutes = lazy(
|
|
|
1881
2392
|
...errors(400, 404)
|
|
1882
2393
|
}
|
|
1883
2394
|
}),
|
|
1884
|
-
|
|
2395
|
+
validator2(
|
|
1885
2396
|
"param",
|
|
1886
2397
|
z7.object({
|
|
1887
2398
|
sessionID: SessionID.zod
|
|
1888
2399
|
})
|
|
1889
2400
|
),
|
|
1890
|
-
|
|
2401
|
+
validator2("json", SessionPrompt.PromptInput.omit({ sessionID: true })),
|
|
1891
2402
|
async (c) => {
|
|
1892
2403
|
c.status(202);
|
|
1893
2404
|
return stream(c, async () => {
|
|
@@ -1904,7 +2415,7 @@ var SessionRoutes = lazy(
|
|
|
1904
2415
|
}
|
|
1905
2416
|
).post(
|
|
1906
2417
|
"/:sessionID/command",
|
|
1907
|
-
|
|
2418
|
+
describeRoute({
|
|
1908
2419
|
summary: "Send command",
|
|
1909
2420
|
description: "Send a new command to a session for execution by the AI assistant.",
|
|
1910
2421
|
operationId: "session.command",
|
|
@@ -1913,7 +2424,7 @@ var SessionRoutes = lazy(
|
|
|
1913
2424
|
description: "Created message",
|
|
1914
2425
|
content: {
|
|
1915
2426
|
"application/json": {
|
|
1916
|
-
schema:
|
|
2427
|
+
schema: resolver(
|
|
1917
2428
|
z7.object({
|
|
1918
2429
|
info: MessageV2.Assistant,
|
|
1919
2430
|
parts: MessageV2.Part.array()
|
|
@@ -1925,13 +2436,13 @@ var SessionRoutes = lazy(
|
|
|
1925
2436
|
...errors(400, 404)
|
|
1926
2437
|
}
|
|
1927
2438
|
}),
|
|
1928
|
-
|
|
2439
|
+
validator2(
|
|
1929
2440
|
"param",
|
|
1930
2441
|
z7.object({
|
|
1931
2442
|
sessionID: SessionID.zod
|
|
1932
2443
|
})
|
|
1933
2444
|
),
|
|
1934
|
-
|
|
2445
|
+
validator2("json", SessionPrompt.CommandInput.omit({ sessionID: true })),
|
|
1935
2446
|
async (c) => {
|
|
1936
2447
|
const sessionID = c.req.valid("param").sessionID;
|
|
1937
2448
|
const body = c.req.valid("json");
|
|
@@ -1940,7 +2451,7 @@ var SessionRoutes = lazy(
|
|
|
1940
2451
|
}
|
|
1941
2452
|
).post(
|
|
1942
2453
|
"/:sessionID/shell",
|
|
1943
|
-
|
|
2454
|
+
describeRoute({
|
|
1944
2455
|
summary: "Run shell command",
|
|
1945
2456
|
description: "Execute a shell command within the session context and return the AI's response.",
|
|
1946
2457
|
operationId: "session.shell",
|
|
@@ -1949,20 +2460,20 @@ var SessionRoutes = lazy(
|
|
|
1949
2460
|
description: "Created message",
|
|
1950
2461
|
content: {
|
|
1951
2462
|
"application/json": {
|
|
1952
|
-
schema:
|
|
2463
|
+
schema: resolver(MessageV2.Assistant)
|
|
1953
2464
|
}
|
|
1954
2465
|
}
|
|
1955
2466
|
},
|
|
1956
2467
|
...errors(400, 404)
|
|
1957
2468
|
}
|
|
1958
2469
|
}),
|
|
1959
|
-
|
|
2470
|
+
validator2(
|
|
1960
2471
|
"param",
|
|
1961
2472
|
z7.object({
|
|
1962
2473
|
sessionID: SessionID.zod
|
|
1963
2474
|
})
|
|
1964
2475
|
),
|
|
1965
|
-
|
|
2476
|
+
validator2("json", SessionPrompt.ShellInput.omit({ sessionID: true })),
|
|
1966
2477
|
async (c) => {
|
|
1967
2478
|
const sessionID = c.req.valid("param").sessionID;
|
|
1968
2479
|
const body = c.req.valid("json");
|
|
@@ -1971,7 +2482,7 @@ var SessionRoutes = lazy(
|
|
|
1971
2482
|
}
|
|
1972
2483
|
).post(
|
|
1973
2484
|
"/:sessionID/revert",
|
|
1974
|
-
|
|
2485
|
+
describeRoute({
|
|
1975
2486
|
summary: "Revert message",
|
|
1976
2487
|
description: "Revert a specific message in a session, undoing its effects and restoring the previous state.",
|
|
1977
2488
|
operationId: "session.revert",
|
|
@@ -1980,20 +2491,20 @@ var SessionRoutes = lazy(
|
|
|
1980
2491
|
description: "Updated session",
|
|
1981
2492
|
content: {
|
|
1982
2493
|
"application/json": {
|
|
1983
|
-
schema:
|
|
2494
|
+
schema: resolver(Session.Info)
|
|
1984
2495
|
}
|
|
1985
2496
|
}
|
|
1986
2497
|
},
|
|
1987
2498
|
...errors(400, 404)
|
|
1988
2499
|
}
|
|
1989
2500
|
}),
|
|
1990
|
-
|
|
2501
|
+
validator2(
|
|
1991
2502
|
"param",
|
|
1992
2503
|
z7.object({
|
|
1993
2504
|
sessionID: SessionID.zod
|
|
1994
2505
|
})
|
|
1995
2506
|
),
|
|
1996
|
-
|
|
2507
|
+
validator2("json", SessionRevert.RevertInput.omit({ sessionID: true })),
|
|
1997
2508
|
async (c) => {
|
|
1998
2509
|
const sessionID = c.req.valid("param").sessionID;
|
|
1999
2510
|
log.info("revert", c.req.valid("json"));
|
|
@@ -2005,7 +2516,7 @@ var SessionRoutes = lazy(
|
|
|
2005
2516
|
}
|
|
2006
2517
|
).post(
|
|
2007
2518
|
"/:sessionID/unrevert",
|
|
2008
|
-
|
|
2519
|
+
describeRoute({
|
|
2009
2520
|
summary: "Restore reverted messages",
|
|
2010
2521
|
description: "Restore all previously reverted messages in a session.",
|
|
2011
2522
|
operationId: "session.unrevert",
|
|
@@ -2014,14 +2525,14 @@ var SessionRoutes = lazy(
|
|
|
2014
2525
|
description: "Updated session",
|
|
2015
2526
|
content: {
|
|
2016
2527
|
"application/json": {
|
|
2017
|
-
schema:
|
|
2528
|
+
schema: resolver(Session.Info)
|
|
2018
2529
|
}
|
|
2019
2530
|
}
|
|
2020
2531
|
},
|
|
2021
2532
|
...errors(400, 404)
|
|
2022
2533
|
}
|
|
2023
2534
|
}),
|
|
2024
|
-
|
|
2535
|
+
validator2(
|
|
2025
2536
|
"param",
|
|
2026
2537
|
z7.object({
|
|
2027
2538
|
sessionID: SessionID.zod
|
|
@@ -2034,7 +2545,7 @@ var SessionRoutes = lazy(
|
|
|
2034
2545
|
}
|
|
2035
2546
|
).post(
|
|
2036
2547
|
"/:sessionID/permissions/:permissionID",
|
|
2037
|
-
|
|
2548
|
+
describeRoute({
|
|
2038
2549
|
summary: "Respond to permission",
|
|
2039
2550
|
deprecated: true,
|
|
2040
2551
|
description: "Approve or deny a permission request from the AI assistant.",
|
|
@@ -2044,21 +2555,21 @@ var SessionRoutes = lazy(
|
|
|
2044
2555
|
description: "Permission processed successfully",
|
|
2045
2556
|
content: {
|
|
2046
2557
|
"application/json": {
|
|
2047
|
-
schema:
|
|
2558
|
+
schema: resolver(z7.boolean())
|
|
2048
2559
|
}
|
|
2049
2560
|
}
|
|
2050
2561
|
},
|
|
2051
2562
|
...errors(400, 404)
|
|
2052
2563
|
}
|
|
2053
2564
|
}),
|
|
2054
|
-
|
|
2565
|
+
validator2(
|
|
2055
2566
|
"param",
|
|
2056
2567
|
z7.object({
|
|
2057
2568
|
sessionID: SessionID.zod,
|
|
2058
2569
|
permissionID: PermissionID.zod
|
|
2059
2570
|
})
|
|
2060
2571
|
),
|
|
2061
|
-
|
|
2572
|
+
validator2("json", z7.object({ response: Permission.Reply })),
|
|
2062
2573
|
async (c) => {
|
|
2063
2574
|
const params = c.req.valid("param");
|
|
2064
2575
|
Permission.reply({
|
|
@@ -2072,7 +2583,6 @@ var SessionRoutes = lazy(
|
|
|
2072
2583
|
|
|
2073
2584
|
// packages/opencode/src/server/routes/pty.ts
|
|
2074
2585
|
import { Hono as Hono7 } from "hono";
|
|
2075
|
-
import { describeRoute as describeRoute6, validator as validator6, resolver as resolver7 } from "hono-openapi";
|
|
2076
2586
|
import z10 from "zod";
|
|
2077
2587
|
|
|
2078
2588
|
// packages/opencode/src/pty/index.ts
|
|
@@ -2412,7 +2922,7 @@ var Pty;
|
|
|
2412
2922
|
function PtyRoutes(upgradeWebSocket2) {
|
|
2413
2923
|
return new Hono7().get(
|
|
2414
2924
|
"/",
|
|
2415
|
-
|
|
2925
|
+
describeRoute({
|
|
2416
2926
|
summary: "List PTY sessions",
|
|
2417
2927
|
description: "Get a list of all active pseudo-terminal (PTY) sessions managed by OpenCode.",
|
|
2418
2928
|
operationId: "pty.list",
|
|
@@ -2421,7 +2931,7 @@ function PtyRoutes(upgradeWebSocket2) {
|
|
|
2421
2931
|
description: "List of sessions",
|
|
2422
2932
|
content: {
|
|
2423
2933
|
"application/json": {
|
|
2424
|
-
schema:
|
|
2934
|
+
schema: resolver(Pty.Info.array())
|
|
2425
2935
|
}
|
|
2426
2936
|
}
|
|
2427
2937
|
}
|
|
@@ -2432,7 +2942,7 @@ function PtyRoutes(upgradeWebSocket2) {
|
|
|
2432
2942
|
}
|
|
2433
2943
|
).post(
|
|
2434
2944
|
"/",
|
|
2435
|
-
|
|
2945
|
+
describeRoute({
|
|
2436
2946
|
summary: "Create PTY session",
|
|
2437
2947
|
description: "Create a new pseudo-terminal (PTY) session for running shell commands and processes.",
|
|
2438
2948
|
operationId: "pty.create",
|
|
@@ -2441,21 +2951,21 @@ function PtyRoutes(upgradeWebSocket2) {
|
|
|
2441
2951
|
description: "Created session",
|
|
2442
2952
|
content: {
|
|
2443
2953
|
"application/json": {
|
|
2444
|
-
schema:
|
|
2954
|
+
schema: resolver(Pty.Info)
|
|
2445
2955
|
}
|
|
2446
2956
|
}
|
|
2447
2957
|
},
|
|
2448
2958
|
...errors(400)
|
|
2449
2959
|
}
|
|
2450
2960
|
}),
|
|
2451
|
-
|
|
2961
|
+
validator2("json", Pty.CreateInput),
|
|
2452
2962
|
async (c) => {
|
|
2453
2963
|
const info = await Pty.create(c.req.valid("json"));
|
|
2454
2964
|
return c.json(info);
|
|
2455
2965
|
}
|
|
2456
2966
|
).get(
|
|
2457
2967
|
"/:ptyID",
|
|
2458
|
-
|
|
2968
|
+
describeRoute({
|
|
2459
2969
|
summary: "Get PTY session",
|
|
2460
2970
|
description: "Retrieve detailed information about a specific pseudo-terminal (PTY) session.",
|
|
2461
2971
|
operationId: "pty.get",
|
|
@@ -2464,14 +2974,14 @@ function PtyRoutes(upgradeWebSocket2) {
|
|
|
2464
2974
|
description: "Session info",
|
|
2465
2975
|
content: {
|
|
2466
2976
|
"application/json": {
|
|
2467
|
-
schema:
|
|
2977
|
+
schema: resolver(Pty.Info)
|
|
2468
2978
|
}
|
|
2469
2979
|
}
|
|
2470
2980
|
},
|
|
2471
2981
|
...errors(404)
|
|
2472
2982
|
}
|
|
2473
2983
|
}),
|
|
2474
|
-
|
|
2984
|
+
validator2("param", z10.object({ ptyID: PtyID.zod })),
|
|
2475
2985
|
async (c) => {
|
|
2476
2986
|
const info = await Pty.get(c.req.valid("param").ptyID);
|
|
2477
2987
|
if (!info) {
|
|
@@ -2481,7 +2991,7 @@ function PtyRoutes(upgradeWebSocket2) {
|
|
|
2481
2991
|
}
|
|
2482
2992
|
).put(
|
|
2483
2993
|
"/:ptyID",
|
|
2484
|
-
|
|
2994
|
+
describeRoute({
|
|
2485
2995
|
summary: "Update PTY session",
|
|
2486
2996
|
description: "Update properties of an existing pseudo-terminal (PTY) session.",
|
|
2487
2997
|
operationId: "pty.update",
|
|
@@ -2490,22 +3000,22 @@ function PtyRoutes(upgradeWebSocket2) {
|
|
|
2490
3000
|
description: "Updated session",
|
|
2491
3001
|
content: {
|
|
2492
3002
|
"application/json": {
|
|
2493
|
-
schema:
|
|
3003
|
+
schema: resolver(Pty.Info)
|
|
2494
3004
|
}
|
|
2495
3005
|
}
|
|
2496
3006
|
},
|
|
2497
3007
|
...errors(400)
|
|
2498
3008
|
}
|
|
2499
3009
|
}),
|
|
2500
|
-
|
|
2501
|
-
|
|
3010
|
+
validator2("param", z10.object({ ptyID: PtyID.zod })),
|
|
3011
|
+
validator2("json", Pty.UpdateInput),
|
|
2502
3012
|
async (c) => {
|
|
2503
3013
|
const info = await Pty.update(c.req.valid("param").ptyID, c.req.valid("json"));
|
|
2504
3014
|
return c.json(info);
|
|
2505
3015
|
}
|
|
2506
3016
|
).delete(
|
|
2507
3017
|
"/:ptyID",
|
|
2508
|
-
|
|
3018
|
+
describeRoute({
|
|
2509
3019
|
summary: "Remove PTY session",
|
|
2510
3020
|
description: "Remove and terminate a specific pseudo-terminal (PTY) session.",
|
|
2511
3021
|
operationId: "pty.remove",
|
|
@@ -2514,21 +3024,21 @@ function PtyRoutes(upgradeWebSocket2) {
|
|
|
2514
3024
|
description: "Session removed",
|
|
2515
3025
|
content: {
|
|
2516
3026
|
"application/json": {
|
|
2517
|
-
schema:
|
|
3027
|
+
schema: resolver(z10.boolean())
|
|
2518
3028
|
}
|
|
2519
3029
|
}
|
|
2520
3030
|
},
|
|
2521
3031
|
...errors(404)
|
|
2522
3032
|
}
|
|
2523
3033
|
}),
|
|
2524
|
-
|
|
3034
|
+
validator2("param", z10.object({ ptyID: PtyID.zod })),
|
|
2525
3035
|
async (c) => {
|
|
2526
3036
|
await Pty.remove(c.req.valid("param").ptyID);
|
|
2527
3037
|
return c.json(true);
|
|
2528
3038
|
}
|
|
2529
3039
|
).get(
|
|
2530
3040
|
"/:ptyID/connect",
|
|
2531
|
-
|
|
3041
|
+
describeRoute({
|
|
2532
3042
|
summary: "Connect to PTY session",
|
|
2533
3043
|
description: "Establish a WebSocket connection to interact with a pseudo-terminal (PTY) session in real-time.",
|
|
2534
3044
|
operationId: "pty.connect",
|
|
@@ -2537,14 +3047,14 @@ function PtyRoutes(upgradeWebSocket2) {
|
|
|
2537
3047
|
description: "Connected session",
|
|
2538
3048
|
content: {
|
|
2539
3049
|
"application/json": {
|
|
2540
|
-
schema:
|
|
3050
|
+
schema: resolver(z10.boolean())
|
|
2541
3051
|
}
|
|
2542
3052
|
}
|
|
2543
3053
|
},
|
|
2544
3054
|
...errors(404)
|
|
2545
3055
|
}
|
|
2546
3056
|
}),
|
|
2547
|
-
|
|
3057
|
+
validator2("param", z10.object({ ptyID: PtyID.zod })),
|
|
2548
3058
|
upgradeWebSocket2(async (c) => {
|
|
2549
3059
|
const id = PtyID.zod.parse(c.req.param("ptyID"));
|
|
2550
3060
|
const cursor = (() => {
|
|
@@ -2598,12 +3108,11 @@ function PtyRoutes(upgradeWebSocket2) {
|
|
|
2598
3108
|
|
|
2599
3109
|
// packages/opencode/src/server/routes/mcp.ts
|
|
2600
3110
|
import { Hono as Hono8 } from "hono";
|
|
2601
|
-
import { describeRoute as describeRoute7, validator as validator7, resolver as resolver8 } from "hono-openapi";
|
|
2602
3111
|
import z11 from "zod";
|
|
2603
3112
|
var McpRoutes = lazy(
|
|
2604
3113
|
() => new Hono8().get(
|
|
2605
3114
|
"/",
|
|
2606
|
-
|
|
3115
|
+
describeRoute({
|
|
2607
3116
|
summary: "Get MCP status",
|
|
2608
3117
|
description: "Get the status of all Model Context Protocol (MCP) servers.",
|
|
2609
3118
|
operationId: "mcp.status",
|
|
@@ -2612,7 +3121,7 @@ var McpRoutes = lazy(
|
|
|
2612
3121
|
description: "MCP server status",
|
|
2613
3122
|
content: {
|
|
2614
3123
|
"application/json": {
|
|
2615
|
-
schema:
|
|
3124
|
+
schema: resolver(z11.record(z11.string(), MCP.Status))
|
|
2616
3125
|
}
|
|
2617
3126
|
}
|
|
2618
3127
|
}
|
|
@@ -2623,7 +3132,7 @@ var McpRoutes = lazy(
|
|
|
2623
3132
|
}
|
|
2624
3133
|
).post(
|
|
2625
3134
|
"/",
|
|
2626
|
-
|
|
3135
|
+
describeRoute({
|
|
2627
3136
|
summary: "Add MCP server",
|
|
2628
3137
|
description: "Dynamically add a new Model Context Protocol (MCP) server to the system.",
|
|
2629
3138
|
operationId: "mcp.add",
|
|
@@ -2632,14 +3141,14 @@ var McpRoutes = lazy(
|
|
|
2632
3141
|
description: "MCP server added successfully",
|
|
2633
3142
|
content: {
|
|
2634
3143
|
"application/json": {
|
|
2635
|
-
schema:
|
|
3144
|
+
schema: resolver(z11.record(z11.string(), MCP.Status))
|
|
2636
3145
|
}
|
|
2637
3146
|
}
|
|
2638
3147
|
},
|
|
2639
3148
|
...errors(400)
|
|
2640
3149
|
}
|
|
2641
3150
|
}),
|
|
2642
|
-
|
|
3151
|
+
validator2(
|
|
2643
3152
|
"json",
|
|
2644
3153
|
z11.object({
|
|
2645
3154
|
name: z11.string(),
|
|
@@ -2653,7 +3162,7 @@ var McpRoutes = lazy(
|
|
|
2653
3162
|
}
|
|
2654
3163
|
).post(
|
|
2655
3164
|
"/:name/auth",
|
|
2656
|
-
|
|
3165
|
+
describeRoute({
|
|
2657
3166
|
summary: "Start MCP OAuth",
|
|
2658
3167
|
description: "Start OAuth authentication flow for a Model Context Protocol (MCP) server.",
|
|
2659
3168
|
operationId: "mcp.auth.start",
|
|
@@ -2662,7 +3171,7 @@ var McpRoutes = lazy(
|
|
|
2662
3171
|
description: "OAuth flow started",
|
|
2663
3172
|
content: {
|
|
2664
3173
|
"application/json": {
|
|
2665
|
-
schema:
|
|
3174
|
+
schema: resolver(
|
|
2666
3175
|
z11.object({
|
|
2667
3176
|
authorizationUrl: z11.string().describe("URL to open in browser for authorization")
|
|
2668
3177
|
})
|
|
@@ -2684,7 +3193,7 @@ var McpRoutes = lazy(
|
|
|
2684
3193
|
}
|
|
2685
3194
|
).post(
|
|
2686
3195
|
"/:name/auth/callback",
|
|
2687
|
-
|
|
3196
|
+
describeRoute({
|
|
2688
3197
|
summary: "Complete MCP OAuth",
|
|
2689
3198
|
description: "Complete OAuth authentication for a Model Context Protocol (MCP) server using the authorization code.",
|
|
2690
3199
|
operationId: "mcp.auth.callback",
|
|
@@ -2693,14 +3202,14 @@ var McpRoutes = lazy(
|
|
|
2693
3202
|
description: "OAuth authentication completed",
|
|
2694
3203
|
content: {
|
|
2695
3204
|
"application/json": {
|
|
2696
|
-
schema:
|
|
3205
|
+
schema: resolver(MCP.Status)
|
|
2697
3206
|
}
|
|
2698
3207
|
}
|
|
2699
3208
|
},
|
|
2700
3209
|
...errors(400, 404)
|
|
2701
3210
|
}
|
|
2702
3211
|
}),
|
|
2703
|
-
|
|
3212
|
+
validator2(
|
|
2704
3213
|
"json",
|
|
2705
3214
|
z11.object({
|
|
2706
3215
|
code: z11.string().describe("Authorization code from OAuth callback")
|
|
@@ -2714,7 +3223,7 @@ var McpRoutes = lazy(
|
|
|
2714
3223
|
}
|
|
2715
3224
|
).post(
|
|
2716
3225
|
"/:name/auth/authenticate",
|
|
2717
|
-
|
|
3226
|
+
describeRoute({
|
|
2718
3227
|
summary: "Authenticate MCP OAuth",
|
|
2719
3228
|
description: "Start OAuth flow and wait for callback (opens browser)",
|
|
2720
3229
|
operationId: "mcp.auth.authenticate",
|
|
@@ -2723,7 +3232,7 @@ var McpRoutes = lazy(
|
|
|
2723
3232
|
description: "OAuth authentication completed",
|
|
2724
3233
|
content: {
|
|
2725
3234
|
"application/json": {
|
|
2726
|
-
schema:
|
|
3235
|
+
schema: resolver(MCP.Status)
|
|
2727
3236
|
}
|
|
2728
3237
|
}
|
|
2729
3238
|
},
|
|
@@ -2741,7 +3250,7 @@ var McpRoutes = lazy(
|
|
|
2741
3250
|
}
|
|
2742
3251
|
).delete(
|
|
2743
3252
|
"/:name/auth",
|
|
2744
|
-
|
|
3253
|
+
describeRoute({
|
|
2745
3254
|
summary: "Remove MCP OAuth",
|
|
2746
3255
|
description: "Remove OAuth credentials for an MCP server",
|
|
2747
3256
|
operationId: "mcp.auth.remove",
|
|
@@ -2750,7 +3259,7 @@ var McpRoutes = lazy(
|
|
|
2750
3259
|
description: "OAuth credentials removed",
|
|
2751
3260
|
content: {
|
|
2752
3261
|
"application/json": {
|
|
2753
|
-
schema:
|
|
3262
|
+
schema: resolver(z11.object({ success: z11.literal(true) }))
|
|
2754
3263
|
}
|
|
2755
3264
|
}
|
|
2756
3265
|
},
|
|
@@ -2764,7 +3273,7 @@ var McpRoutes = lazy(
|
|
|
2764
3273
|
}
|
|
2765
3274
|
).post(
|
|
2766
3275
|
"/:name/connect",
|
|
2767
|
-
|
|
3276
|
+
describeRoute({
|
|
2768
3277
|
description: "Connect an MCP server",
|
|
2769
3278
|
operationId: "mcp.connect",
|
|
2770
3279
|
responses: {
|
|
@@ -2772,13 +3281,13 @@ var McpRoutes = lazy(
|
|
|
2772
3281
|
description: "MCP server connected successfully",
|
|
2773
3282
|
content: {
|
|
2774
3283
|
"application/json": {
|
|
2775
|
-
schema:
|
|
3284
|
+
schema: resolver(z11.boolean())
|
|
2776
3285
|
}
|
|
2777
3286
|
}
|
|
2778
3287
|
}
|
|
2779
3288
|
}
|
|
2780
3289
|
}),
|
|
2781
|
-
|
|
3290
|
+
validator2("param", z11.object({ name: z11.string() })),
|
|
2782
3291
|
async (c) => {
|
|
2783
3292
|
const { name } = c.req.valid("param");
|
|
2784
3293
|
await MCP.connect(name);
|
|
@@ -2786,7 +3295,7 @@ var McpRoutes = lazy(
|
|
|
2786
3295
|
}
|
|
2787
3296
|
).post(
|
|
2788
3297
|
"/:name/disconnect",
|
|
2789
|
-
|
|
3298
|
+
describeRoute({
|
|
2790
3299
|
description: "Disconnect an MCP server",
|
|
2791
3300
|
operationId: "mcp.disconnect",
|
|
2792
3301
|
responses: {
|
|
@@ -2794,13 +3303,13 @@ var McpRoutes = lazy(
|
|
|
2794
3303
|
description: "MCP server disconnected successfully",
|
|
2795
3304
|
content: {
|
|
2796
3305
|
"application/json": {
|
|
2797
|
-
schema:
|
|
3306
|
+
schema: resolver(z11.boolean())
|
|
2798
3307
|
}
|
|
2799
3308
|
}
|
|
2800
3309
|
}
|
|
2801
3310
|
}
|
|
2802
3311
|
}),
|
|
2803
|
-
|
|
3312
|
+
validator2("param", z11.object({ name: z11.string() })),
|
|
2804
3313
|
async (c) => {
|
|
2805
3314
|
const { name } = c.req.valid("param");
|
|
2806
3315
|
await MCP.disconnect(name);
|
|
@@ -2811,12 +3320,11 @@ var McpRoutes = lazy(
|
|
|
2811
3320
|
|
|
2812
3321
|
// packages/opencode/src/server/routes/file.ts
|
|
2813
3322
|
import { Hono as Hono9 } from "hono";
|
|
2814
|
-
import { describeRoute as describeRoute8, validator as validator8, resolver as resolver9 } from "hono-openapi";
|
|
2815
3323
|
import z12 from "zod";
|
|
2816
3324
|
var FileRoutes = lazy(
|
|
2817
3325
|
() => new Hono9().get(
|
|
2818
3326
|
"/find",
|
|
2819
|
-
|
|
3327
|
+
describeRoute({
|
|
2820
3328
|
summary: "Find text",
|
|
2821
3329
|
description: "Search for text patterns across files in the project using ripgrep.",
|
|
2822
3330
|
operationId: "find.text",
|
|
@@ -2825,13 +3333,13 @@ var FileRoutes = lazy(
|
|
|
2825
3333
|
description: "Matches",
|
|
2826
3334
|
content: {
|
|
2827
3335
|
"application/json": {
|
|
2828
|
-
schema:
|
|
3336
|
+
schema: resolver(Ripgrep.Match.shape.data.array())
|
|
2829
3337
|
}
|
|
2830
3338
|
}
|
|
2831
3339
|
}
|
|
2832
3340
|
}
|
|
2833
3341
|
}),
|
|
2834
|
-
|
|
3342
|
+
validator2(
|
|
2835
3343
|
"query",
|
|
2836
3344
|
z12.object({
|
|
2837
3345
|
pattern: z12.string()
|
|
@@ -2848,7 +3356,7 @@ var FileRoutes = lazy(
|
|
|
2848
3356
|
}
|
|
2849
3357
|
).get(
|
|
2850
3358
|
"/find/file",
|
|
2851
|
-
|
|
3359
|
+
describeRoute({
|
|
2852
3360
|
summary: "Find files",
|
|
2853
3361
|
description: "Search for files or directories by name or pattern in the project directory.",
|
|
2854
3362
|
operationId: "find.files",
|
|
@@ -2857,13 +3365,13 @@ var FileRoutes = lazy(
|
|
|
2857
3365
|
description: "File paths",
|
|
2858
3366
|
content: {
|
|
2859
3367
|
"application/json": {
|
|
2860
|
-
schema:
|
|
3368
|
+
schema: resolver(z12.string().array())
|
|
2861
3369
|
}
|
|
2862
3370
|
}
|
|
2863
3371
|
}
|
|
2864
3372
|
}
|
|
2865
3373
|
}),
|
|
2866
|
-
|
|
3374
|
+
validator2(
|
|
2867
3375
|
"query",
|
|
2868
3376
|
z12.object({
|
|
2869
3377
|
query: z12.string(),
|
|
@@ -2887,7 +3395,7 @@ var FileRoutes = lazy(
|
|
|
2887
3395
|
}
|
|
2888
3396
|
).get(
|
|
2889
3397
|
"/find/symbol",
|
|
2890
|
-
|
|
3398
|
+
describeRoute({
|
|
2891
3399
|
summary: "Find symbols",
|
|
2892
3400
|
description: "Search for workspace symbols like functions, classes, and variables using LSP.",
|
|
2893
3401
|
operationId: "find.symbols",
|
|
@@ -2896,13 +3404,13 @@ var FileRoutes = lazy(
|
|
|
2896
3404
|
description: "Symbols",
|
|
2897
3405
|
content: {
|
|
2898
3406
|
"application/json": {
|
|
2899
|
-
schema:
|
|
3407
|
+
schema: resolver(LSP.Symbol.array())
|
|
2900
3408
|
}
|
|
2901
3409
|
}
|
|
2902
3410
|
}
|
|
2903
3411
|
}
|
|
2904
3412
|
}),
|
|
2905
|
-
|
|
3413
|
+
validator2(
|
|
2906
3414
|
"query",
|
|
2907
3415
|
z12.object({
|
|
2908
3416
|
query: z12.string()
|
|
@@ -2913,7 +3421,7 @@ var FileRoutes = lazy(
|
|
|
2913
3421
|
}
|
|
2914
3422
|
).get(
|
|
2915
3423
|
"/file",
|
|
2916
|
-
|
|
3424
|
+
describeRoute({
|
|
2917
3425
|
summary: "List files",
|
|
2918
3426
|
description: "List files and directories in a specified path.",
|
|
2919
3427
|
operationId: "file.list",
|
|
@@ -2922,13 +3430,13 @@ var FileRoutes = lazy(
|
|
|
2922
3430
|
description: "Files and directories",
|
|
2923
3431
|
content: {
|
|
2924
3432
|
"application/json": {
|
|
2925
|
-
schema:
|
|
3433
|
+
schema: resolver(File.Node.array())
|
|
2926
3434
|
}
|
|
2927
3435
|
}
|
|
2928
3436
|
}
|
|
2929
3437
|
}
|
|
2930
3438
|
}),
|
|
2931
|
-
|
|
3439
|
+
validator2(
|
|
2932
3440
|
"query",
|
|
2933
3441
|
z12.object({
|
|
2934
3442
|
path: z12.string()
|
|
@@ -2941,7 +3449,7 @@ var FileRoutes = lazy(
|
|
|
2941
3449
|
}
|
|
2942
3450
|
).get(
|
|
2943
3451
|
"/file/content",
|
|
2944
|
-
|
|
3452
|
+
describeRoute({
|
|
2945
3453
|
summary: "Read file",
|
|
2946
3454
|
description: "Read the content of a specified file.",
|
|
2947
3455
|
operationId: "file.read",
|
|
@@ -2950,13 +3458,13 @@ var FileRoutes = lazy(
|
|
|
2950
3458
|
description: "File content",
|
|
2951
3459
|
content: {
|
|
2952
3460
|
"application/json": {
|
|
2953
|
-
schema:
|
|
3461
|
+
schema: resolver(File.Content)
|
|
2954
3462
|
}
|
|
2955
3463
|
}
|
|
2956
3464
|
}
|
|
2957
3465
|
}
|
|
2958
3466
|
}),
|
|
2959
|
-
|
|
3467
|
+
validator2(
|
|
2960
3468
|
"query",
|
|
2961
3469
|
z12.object({
|
|
2962
3470
|
path: z12.string()
|
|
@@ -2969,7 +3477,7 @@ var FileRoutes = lazy(
|
|
|
2969
3477
|
}
|
|
2970
3478
|
).get(
|
|
2971
3479
|
"/file/status",
|
|
2972
|
-
|
|
3480
|
+
describeRoute({
|
|
2973
3481
|
summary: "Get file status",
|
|
2974
3482
|
description: "Get the git status of all files in the project.",
|
|
2975
3483
|
operationId: "file.status",
|
|
@@ -2978,7 +3486,7 @@ var FileRoutes = lazy(
|
|
|
2978
3486
|
description: "File status",
|
|
2979
3487
|
content: {
|
|
2980
3488
|
"application/json": {
|
|
2981
|
-
schema:
|
|
3489
|
+
schema: resolver(File.Info.array())
|
|
2982
3490
|
}
|
|
2983
3491
|
}
|
|
2984
3492
|
}
|
|
@@ -2993,14 +3501,13 @@ var FileRoutes = lazy(
|
|
|
2993
3501
|
|
|
2994
3502
|
// packages/opencode/src/server/routes/config.ts
|
|
2995
3503
|
import { Hono as Hono10 } from "hono";
|
|
2996
|
-
import { describeRoute as describeRoute9, validator as validator9, resolver as resolver10 } from "hono-openapi";
|
|
2997
3504
|
import z13 from "zod";
|
|
2998
3505
|
import { mapValues } from "remeda";
|
|
2999
3506
|
var log2 = Log.create({ service: "server" });
|
|
3000
3507
|
var ConfigRoutes = lazy(
|
|
3001
3508
|
() => new Hono10().get(
|
|
3002
3509
|
"/",
|
|
3003
|
-
|
|
3510
|
+
describeRoute({
|
|
3004
3511
|
summary: "Get configuration",
|
|
3005
3512
|
description: "Retrieve the current OpenCode configuration settings and preferences.",
|
|
3006
3513
|
operationId: "config.get",
|
|
@@ -3009,7 +3516,7 @@ var ConfigRoutes = lazy(
|
|
|
3009
3516
|
description: "Get config info",
|
|
3010
3517
|
content: {
|
|
3011
3518
|
"application/json": {
|
|
3012
|
-
schema:
|
|
3519
|
+
schema: resolver(Config.Info)
|
|
3013
3520
|
}
|
|
3014
3521
|
}
|
|
3015
3522
|
}
|
|
@@ -3020,7 +3527,7 @@ var ConfigRoutes = lazy(
|
|
|
3020
3527
|
}
|
|
3021
3528
|
).patch(
|
|
3022
3529
|
"/",
|
|
3023
|
-
|
|
3530
|
+
describeRoute({
|
|
3024
3531
|
summary: "Update configuration",
|
|
3025
3532
|
description: "Update OpenCode configuration settings and preferences.",
|
|
3026
3533
|
operationId: "config.update",
|
|
@@ -3029,14 +3536,14 @@ var ConfigRoutes = lazy(
|
|
|
3029
3536
|
description: "Successfully updated config",
|
|
3030
3537
|
content: {
|
|
3031
3538
|
"application/json": {
|
|
3032
|
-
schema:
|
|
3539
|
+
schema: resolver(Config.Info)
|
|
3033
3540
|
}
|
|
3034
3541
|
}
|
|
3035
3542
|
},
|
|
3036
3543
|
...errors(400)
|
|
3037
3544
|
}
|
|
3038
3545
|
}),
|
|
3039
|
-
|
|
3546
|
+
validator2("json", Config.Info),
|
|
3040
3547
|
async (c) => {
|
|
3041
3548
|
const config = c.req.valid("json");
|
|
3042
3549
|
await Config.update(config);
|
|
@@ -3044,7 +3551,7 @@ var ConfigRoutes = lazy(
|
|
|
3044
3551
|
}
|
|
3045
3552
|
).get(
|
|
3046
3553
|
"/providers",
|
|
3047
|
-
|
|
3554
|
+
describeRoute({
|
|
3048
3555
|
summary: "List config providers",
|
|
3049
3556
|
description: "Get a list of all configured AI providers and their default models.",
|
|
3050
3557
|
operationId: "config.providers",
|
|
@@ -3053,7 +3560,7 @@ var ConfigRoutes = lazy(
|
|
|
3053
3560
|
description: "List of providers",
|
|
3054
3561
|
content: {
|
|
3055
3562
|
"application/json": {
|
|
3056
|
-
schema:
|
|
3563
|
+
schema: resolver(
|
|
3057
3564
|
z13.object({
|
|
3058
3565
|
providers: Provider.Info.array(),
|
|
3059
3566
|
default: z13.record(z13.string(), z13.string())
|
|
@@ -3084,7 +3591,6 @@ var ConfigRoutes = lazy(
|
|
|
3084
3591
|
|
|
3085
3592
|
// packages/opencode/src/server/routes/experimental.ts
|
|
3086
3593
|
import { Hono as Hono12 } from "hono";
|
|
3087
|
-
import { describeRoute as describeRoute11, validator as validator11, resolver as resolver12 } from "hono-openapi";
|
|
3088
3594
|
import z16 from "zod";
|
|
3089
3595
|
|
|
3090
3596
|
// packages/opencode/src/config/console-state.ts
|
|
@@ -3100,12 +3606,11 @@ import { zodToJsonSchema } from "zod-to-json-schema";
|
|
|
3100
3606
|
|
|
3101
3607
|
// packages/opencode/src/server/routes/workspace.ts
|
|
3102
3608
|
import { Hono as Hono11 } from "hono";
|
|
3103
|
-
import { describeRoute as describeRoute10, resolver as resolver11, validator as validator10 } from "hono-openapi";
|
|
3104
3609
|
import z15 from "zod";
|
|
3105
3610
|
var WorkspaceRoutes = lazy(
|
|
3106
3611
|
() => new Hono11().post(
|
|
3107
3612
|
"/",
|
|
3108
|
-
|
|
3613
|
+
describeRoute({
|
|
3109
3614
|
summary: "Create workspace",
|
|
3110
3615
|
description: "Create a workspace for the current project.",
|
|
3111
3616
|
operationId: "experimental.workspace.create",
|
|
@@ -3114,14 +3619,14 @@ var WorkspaceRoutes = lazy(
|
|
|
3114
3619
|
description: "Workspace created",
|
|
3115
3620
|
content: {
|
|
3116
3621
|
"application/json": {
|
|
3117
|
-
schema:
|
|
3622
|
+
schema: resolver(Workspace.Info)
|
|
3118
3623
|
}
|
|
3119
3624
|
}
|
|
3120
3625
|
},
|
|
3121
3626
|
...errors(400)
|
|
3122
3627
|
}
|
|
3123
3628
|
}),
|
|
3124
|
-
|
|
3629
|
+
validator2(
|
|
3125
3630
|
"json",
|
|
3126
3631
|
Workspace.create.schema.omit({
|
|
3127
3632
|
projectID: true
|
|
@@ -3137,7 +3642,7 @@ var WorkspaceRoutes = lazy(
|
|
|
3137
3642
|
}
|
|
3138
3643
|
).get(
|
|
3139
3644
|
"/",
|
|
3140
|
-
|
|
3645
|
+
describeRoute({
|
|
3141
3646
|
summary: "List workspaces",
|
|
3142
3647
|
description: "List all workspaces.",
|
|
3143
3648
|
operationId: "experimental.workspace.list",
|
|
@@ -3146,7 +3651,7 @@ var WorkspaceRoutes = lazy(
|
|
|
3146
3651
|
description: "Workspaces",
|
|
3147
3652
|
content: {
|
|
3148
3653
|
"application/json": {
|
|
3149
|
-
schema:
|
|
3654
|
+
schema: resolver(z15.array(Workspace.Info))
|
|
3150
3655
|
}
|
|
3151
3656
|
}
|
|
3152
3657
|
}
|
|
@@ -3157,7 +3662,7 @@ var WorkspaceRoutes = lazy(
|
|
|
3157
3662
|
}
|
|
3158
3663
|
).delete(
|
|
3159
3664
|
"/:id",
|
|
3160
|
-
|
|
3665
|
+
describeRoute({
|
|
3161
3666
|
summary: "Remove workspace",
|
|
3162
3667
|
description: "Remove an existing workspace.",
|
|
3163
3668
|
operationId: "experimental.workspace.remove",
|
|
@@ -3166,14 +3671,14 @@ var WorkspaceRoutes = lazy(
|
|
|
3166
3671
|
description: "Workspace removed",
|
|
3167
3672
|
content: {
|
|
3168
3673
|
"application/json": {
|
|
3169
|
-
schema:
|
|
3674
|
+
schema: resolver(Workspace.Info.optional())
|
|
3170
3675
|
}
|
|
3171
3676
|
}
|
|
3172
3677
|
},
|
|
3173
3678
|
...errors(400)
|
|
3174
3679
|
}
|
|
3175
3680
|
}),
|
|
3176
|
-
|
|
3681
|
+
validator2(
|
|
3177
3682
|
"param",
|
|
3178
3683
|
z15.object({
|
|
3179
3684
|
id: Workspace.Info.shape.id
|
|
@@ -3205,7 +3710,7 @@ var ConsoleSwitchBody = z16.object({
|
|
|
3205
3710
|
var ExperimentalRoutes = lazy(
|
|
3206
3711
|
() => new Hono12().get(
|
|
3207
3712
|
"/console",
|
|
3208
|
-
|
|
3713
|
+
describeRoute({
|
|
3209
3714
|
summary: "Get active Console provider metadata",
|
|
3210
3715
|
description: "Get the active Console org name and the set of provider IDs managed by that Console org.",
|
|
3211
3716
|
operationId: "experimental.console.get",
|
|
@@ -3214,7 +3719,7 @@ var ExperimentalRoutes = lazy(
|
|
|
3214
3719
|
description: "Active Console provider metadata",
|
|
3215
3720
|
content: {
|
|
3216
3721
|
"application/json": {
|
|
3217
|
-
schema:
|
|
3722
|
+
schema: resolver(ConsoleState)
|
|
3218
3723
|
}
|
|
3219
3724
|
}
|
|
3220
3725
|
}
|
|
@@ -3229,7 +3734,7 @@ var ExperimentalRoutes = lazy(
|
|
|
3229
3734
|
}
|
|
3230
3735
|
).get(
|
|
3231
3736
|
"/console/orgs",
|
|
3232
|
-
|
|
3737
|
+
describeRoute({
|
|
3233
3738
|
summary: "List switchable Console orgs",
|
|
3234
3739
|
description: "Get the available Console orgs across logged-in accounts, including the current active org.",
|
|
3235
3740
|
operationId: "experimental.console.listOrgs",
|
|
@@ -3238,7 +3743,7 @@ var ExperimentalRoutes = lazy(
|
|
|
3238
3743
|
description: "Switchable Console orgs",
|
|
3239
3744
|
content: {
|
|
3240
3745
|
"application/json": {
|
|
3241
|
-
schema:
|
|
3746
|
+
schema: resolver(ConsoleOrgList)
|
|
3242
3747
|
}
|
|
3243
3748
|
}
|
|
3244
3749
|
}
|
|
@@ -3260,7 +3765,7 @@ var ExperimentalRoutes = lazy(
|
|
|
3260
3765
|
}
|
|
3261
3766
|
).post(
|
|
3262
3767
|
"/console/switch",
|
|
3263
|
-
|
|
3768
|
+
describeRoute({
|
|
3264
3769
|
summary: "Switch active Console org",
|
|
3265
3770
|
description: "Persist a new active Console account/org selection for the current local OpenCode state.",
|
|
3266
3771
|
operationId: "experimental.console.switchOrg",
|
|
@@ -3269,13 +3774,13 @@ var ExperimentalRoutes = lazy(
|
|
|
3269
3774
|
description: "Switch success",
|
|
3270
3775
|
content: {
|
|
3271
3776
|
"application/json": {
|
|
3272
|
-
schema:
|
|
3777
|
+
schema: resolver(z16.boolean())
|
|
3273
3778
|
}
|
|
3274
3779
|
}
|
|
3275
3780
|
}
|
|
3276
3781
|
}
|
|
3277
3782
|
}),
|
|
3278
|
-
|
|
3783
|
+
validator2("json", ConsoleSwitchBody),
|
|
3279
3784
|
async (c) => {
|
|
3280
3785
|
const body = c.req.valid("json");
|
|
3281
3786
|
await Account.switchOrg(AccountID.make(body.accountID), OrgID.make(body.orgID));
|
|
@@ -3283,7 +3788,7 @@ var ExperimentalRoutes = lazy(
|
|
|
3283
3788
|
}
|
|
3284
3789
|
).get(
|
|
3285
3790
|
"/tool/ids",
|
|
3286
|
-
|
|
3791
|
+
describeRoute({
|
|
3287
3792
|
summary: "List tool IDs",
|
|
3288
3793
|
description: "Get a list of all available tool IDs, including both built-in tools and dynamically registered tools.",
|
|
3289
3794
|
operationId: "tool.ids",
|
|
@@ -3292,7 +3797,7 @@ var ExperimentalRoutes = lazy(
|
|
|
3292
3797
|
description: "Tool IDs",
|
|
3293
3798
|
content: {
|
|
3294
3799
|
"application/json": {
|
|
3295
|
-
schema:
|
|
3800
|
+
schema: resolver(z16.array(z16.string()).meta({ ref: "ToolIDs" }))
|
|
3296
3801
|
}
|
|
3297
3802
|
}
|
|
3298
3803
|
},
|
|
@@ -3304,7 +3809,7 @@ var ExperimentalRoutes = lazy(
|
|
|
3304
3809
|
}
|
|
3305
3810
|
).get(
|
|
3306
3811
|
"/tool",
|
|
3307
|
-
|
|
3812
|
+
describeRoute({
|
|
3308
3813
|
summary: "List tools",
|
|
3309
3814
|
description: "Get a list of available tools with their JSON schema parameters for a specific provider and model combination.",
|
|
3310
3815
|
operationId: "tool.list",
|
|
@@ -3313,7 +3818,7 @@ var ExperimentalRoutes = lazy(
|
|
|
3313
3818
|
description: "Tools",
|
|
3314
3819
|
content: {
|
|
3315
3820
|
"application/json": {
|
|
3316
|
-
schema:
|
|
3821
|
+
schema: resolver(
|
|
3317
3822
|
z16.array(
|
|
3318
3823
|
z16.object({
|
|
3319
3824
|
id: z16.string(),
|
|
@@ -3328,7 +3833,7 @@ var ExperimentalRoutes = lazy(
|
|
|
3328
3833
|
...errors(400)
|
|
3329
3834
|
}
|
|
3330
3835
|
}),
|
|
3331
|
-
|
|
3836
|
+
validator2(
|
|
3332
3837
|
"query",
|
|
3333
3838
|
z16.object({
|
|
3334
3839
|
provider: z16.string(),
|
|
@@ -3349,7 +3854,7 @@ var ExperimentalRoutes = lazy(
|
|
|
3349
3854
|
}
|
|
3350
3855
|
).route("/workspace", WorkspaceRoutes()).post(
|
|
3351
3856
|
"/worktree",
|
|
3352
|
-
|
|
3857
|
+
describeRoute({
|
|
3353
3858
|
summary: "Create worktree",
|
|
3354
3859
|
description: "Create a new git worktree for the current project and run any configured startup scripts.",
|
|
3355
3860
|
operationId: "worktree.create",
|
|
@@ -3358,14 +3863,14 @@ var ExperimentalRoutes = lazy(
|
|
|
3358
3863
|
description: "Worktree created",
|
|
3359
3864
|
content: {
|
|
3360
3865
|
"application/json": {
|
|
3361
|
-
schema:
|
|
3866
|
+
schema: resolver(Worktree.Info)
|
|
3362
3867
|
}
|
|
3363
3868
|
}
|
|
3364
3869
|
},
|
|
3365
3870
|
...errors(400)
|
|
3366
3871
|
}
|
|
3367
3872
|
}),
|
|
3368
|
-
|
|
3873
|
+
validator2("json", Worktree.CreateInput.optional()),
|
|
3369
3874
|
async (c) => {
|
|
3370
3875
|
const body = c.req.valid("json");
|
|
3371
3876
|
const worktree = await Worktree.create(body);
|
|
@@ -3373,7 +3878,7 @@ var ExperimentalRoutes = lazy(
|
|
|
3373
3878
|
}
|
|
3374
3879
|
).get(
|
|
3375
3880
|
"/worktree",
|
|
3376
|
-
|
|
3881
|
+
describeRoute({
|
|
3377
3882
|
summary: "List worktrees",
|
|
3378
3883
|
description: "List all sandbox worktrees for the current project.",
|
|
3379
3884
|
operationId: "worktree.list",
|
|
@@ -3382,7 +3887,7 @@ var ExperimentalRoutes = lazy(
|
|
|
3382
3887
|
description: "List of worktree directories",
|
|
3383
3888
|
content: {
|
|
3384
3889
|
"application/json": {
|
|
3385
|
-
schema:
|
|
3890
|
+
schema: resolver(z16.array(z16.string()))
|
|
3386
3891
|
}
|
|
3387
3892
|
}
|
|
3388
3893
|
}
|
|
@@ -3394,7 +3899,7 @@ var ExperimentalRoutes = lazy(
|
|
|
3394
3899
|
}
|
|
3395
3900
|
).delete(
|
|
3396
3901
|
"/worktree",
|
|
3397
|
-
|
|
3902
|
+
describeRoute({
|
|
3398
3903
|
summary: "Remove worktree",
|
|
3399
3904
|
description: "Remove a git worktree and delete its branch.",
|
|
3400
3905
|
operationId: "worktree.remove",
|
|
@@ -3403,14 +3908,14 @@ var ExperimentalRoutes = lazy(
|
|
|
3403
3908
|
description: "Worktree removed",
|
|
3404
3909
|
content: {
|
|
3405
3910
|
"application/json": {
|
|
3406
|
-
schema:
|
|
3911
|
+
schema: resolver(z16.boolean())
|
|
3407
3912
|
}
|
|
3408
3913
|
}
|
|
3409
3914
|
},
|
|
3410
3915
|
...errors(400)
|
|
3411
3916
|
}
|
|
3412
3917
|
}),
|
|
3413
|
-
|
|
3918
|
+
validator2("json", Worktree.RemoveInput),
|
|
3414
3919
|
async (c) => {
|
|
3415
3920
|
const body = c.req.valid("json");
|
|
3416
3921
|
await Worktree.remove(body);
|
|
@@ -3419,7 +3924,7 @@ var ExperimentalRoutes = lazy(
|
|
|
3419
3924
|
}
|
|
3420
3925
|
).post(
|
|
3421
3926
|
"/worktree/reset",
|
|
3422
|
-
|
|
3927
|
+
describeRoute({
|
|
3423
3928
|
summary: "Reset worktree",
|
|
3424
3929
|
description: "Reset a worktree branch to the primary default branch.",
|
|
3425
3930
|
operationId: "worktree.reset",
|
|
@@ -3428,14 +3933,14 @@ var ExperimentalRoutes = lazy(
|
|
|
3428
3933
|
description: "Worktree reset",
|
|
3429
3934
|
content: {
|
|
3430
3935
|
"application/json": {
|
|
3431
|
-
schema:
|
|
3936
|
+
schema: resolver(z16.boolean())
|
|
3432
3937
|
}
|
|
3433
3938
|
}
|
|
3434
3939
|
},
|
|
3435
3940
|
...errors(400)
|
|
3436
3941
|
}
|
|
3437
3942
|
}),
|
|
3438
|
-
|
|
3943
|
+
validator2("json", Worktree.ResetInput),
|
|
3439
3944
|
async (c) => {
|
|
3440
3945
|
const body = c.req.valid("json");
|
|
3441
3946
|
await Worktree.reset(body);
|
|
@@ -3443,7 +3948,7 @@ var ExperimentalRoutes = lazy(
|
|
|
3443
3948
|
}
|
|
3444
3949
|
).get(
|
|
3445
3950
|
"/session",
|
|
3446
|
-
|
|
3951
|
+
describeRoute({
|
|
3447
3952
|
summary: "List sessions",
|
|
3448
3953
|
description: "Get a list of all OpenCode sessions across projects, sorted by most recently updated. Archived sessions are excluded by default.",
|
|
3449
3954
|
operationId: "experimental.session.list",
|
|
@@ -3452,13 +3957,13 @@ var ExperimentalRoutes = lazy(
|
|
|
3452
3957
|
description: "List of sessions",
|
|
3453
3958
|
content: {
|
|
3454
3959
|
"application/json": {
|
|
3455
|
-
schema:
|
|
3960
|
+
schema: resolver(Session.GlobalInfo.array())
|
|
3456
3961
|
}
|
|
3457
3962
|
}
|
|
3458
3963
|
}
|
|
3459
3964
|
}
|
|
3460
3965
|
}),
|
|
3461
|
-
|
|
3966
|
+
validator2(
|
|
3462
3967
|
"query",
|
|
3463
3968
|
z16.object({
|
|
3464
3969
|
directory: z16.string().optional().meta({ description: "Filter sessions by project directory" }),
|
|
@@ -3494,7 +3999,7 @@ var ExperimentalRoutes = lazy(
|
|
|
3494
3999
|
}
|
|
3495
4000
|
).get(
|
|
3496
4001
|
"/resource",
|
|
3497
|
-
|
|
4002
|
+
describeRoute({
|
|
3498
4003
|
summary: "Get MCP resources",
|
|
3499
4004
|
description: "Get all available MCP resources from connected servers. Optionally filter by name.",
|
|
3500
4005
|
operationId: "experimental.resource.list",
|
|
@@ -3503,7 +4008,7 @@ var ExperimentalRoutes = lazy(
|
|
|
3503
4008
|
description: "MCP resources",
|
|
3504
4009
|
content: {
|
|
3505
4010
|
"application/json": {
|
|
3506
|
-
schema:
|
|
4011
|
+
schema: resolver(z16.record(z16.string(), MCP.Resource))
|
|
3507
4012
|
}
|
|
3508
4013
|
}
|
|
3509
4014
|
}
|
|
@@ -3517,7 +4022,6 @@ var ExperimentalRoutes = lazy(
|
|
|
3517
4022
|
|
|
3518
4023
|
// packages/opencode/src/server/routes/provider.ts
|
|
3519
4024
|
import { Hono as Hono13 } from "hono";
|
|
3520
|
-
import { describeRoute as describeRoute12, validator as validator12, resolver as resolver13 } from "hono-openapi";
|
|
3521
4025
|
import z18 from "zod";
|
|
3522
4026
|
|
|
3523
4027
|
// packages/opencode/src/provider/auth.ts
|
|
@@ -3710,7 +4214,7 @@ var log3 = Log.create({ service: "server" });
|
|
|
3710
4214
|
var ProviderRoutes = lazy(
|
|
3711
4215
|
() => new Hono13().get(
|
|
3712
4216
|
"/",
|
|
3713
|
-
|
|
4217
|
+
describeRoute({
|
|
3714
4218
|
summary: "List providers",
|
|
3715
4219
|
description: "Get a list of all available AI providers, including both available and connected ones.",
|
|
3716
4220
|
operationId: "provider.list",
|
|
@@ -3719,7 +4223,7 @@ var ProviderRoutes = lazy(
|
|
|
3719
4223
|
description: "List of providers",
|
|
3720
4224
|
content: {
|
|
3721
4225
|
"application/json": {
|
|
3722
|
-
schema:
|
|
4226
|
+
schema: resolver(
|
|
3723
4227
|
z18.object({
|
|
3724
4228
|
all: ModelsDev.Provider.array(),
|
|
3725
4229
|
default: z18.record(z18.string(), z18.string()),
|
|
@@ -3755,7 +4259,7 @@ var ProviderRoutes = lazy(
|
|
|
3755
4259
|
}
|
|
3756
4260
|
).get(
|
|
3757
4261
|
"/auth",
|
|
3758
|
-
|
|
4262
|
+
describeRoute({
|
|
3759
4263
|
summary: "Get provider auth methods",
|
|
3760
4264
|
description: "Retrieve available authentication methods for all AI providers.",
|
|
3761
4265
|
operationId: "provider.auth",
|
|
@@ -3764,7 +4268,7 @@ var ProviderRoutes = lazy(
|
|
|
3764
4268
|
description: "Provider auth methods",
|
|
3765
4269
|
content: {
|
|
3766
4270
|
"application/json": {
|
|
3767
|
-
schema:
|
|
4271
|
+
schema: resolver(z18.record(z18.string(), z18.array(ProviderAuth.Method)))
|
|
3768
4272
|
}
|
|
3769
4273
|
}
|
|
3770
4274
|
}
|
|
@@ -3775,7 +4279,7 @@ var ProviderRoutes = lazy(
|
|
|
3775
4279
|
}
|
|
3776
4280
|
).post(
|
|
3777
4281
|
"/:providerID/oauth/authorize",
|
|
3778
|
-
|
|
4282
|
+
describeRoute({
|
|
3779
4283
|
summary: "OAuth authorize",
|
|
3780
4284
|
description: "Initiate OAuth authorization for a specific AI provider to get an authorization URL.",
|
|
3781
4285
|
operationId: "provider.oauth.authorize",
|
|
@@ -3784,20 +4288,20 @@ var ProviderRoutes = lazy(
|
|
|
3784
4288
|
description: "Authorization URL and method",
|
|
3785
4289
|
content: {
|
|
3786
4290
|
"application/json": {
|
|
3787
|
-
schema:
|
|
4291
|
+
schema: resolver(ProviderAuth.Authorization.optional())
|
|
3788
4292
|
}
|
|
3789
4293
|
}
|
|
3790
4294
|
},
|
|
3791
4295
|
...errors(400)
|
|
3792
4296
|
}
|
|
3793
4297
|
}),
|
|
3794
|
-
|
|
4298
|
+
validator2(
|
|
3795
4299
|
"param",
|
|
3796
4300
|
z18.object({
|
|
3797
4301
|
providerID: ProviderID.zod.meta({ description: "Provider ID" })
|
|
3798
4302
|
})
|
|
3799
4303
|
),
|
|
3800
|
-
|
|
4304
|
+
validator2(
|
|
3801
4305
|
"json",
|
|
3802
4306
|
z18.object({
|
|
3803
4307
|
method: z18.number().meta({ description: "Auth method index" }),
|
|
@@ -3816,7 +4320,7 @@ var ProviderRoutes = lazy(
|
|
|
3816
4320
|
}
|
|
3817
4321
|
).post(
|
|
3818
4322
|
"/:providerID/oauth/callback",
|
|
3819
|
-
|
|
4323
|
+
describeRoute({
|
|
3820
4324
|
summary: "OAuth callback",
|
|
3821
4325
|
description: "Handle the OAuth callback from a provider after user authorization.",
|
|
3822
4326
|
operationId: "provider.oauth.callback",
|
|
@@ -3825,20 +4329,20 @@ var ProviderRoutes = lazy(
|
|
|
3825
4329
|
description: "OAuth callback processed successfully",
|
|
3826
4330
|
content: {
|
|
3827
4331
|
"application/json": {
|
|
3828
|
-
schema:
|
|
4332
|
+
schema: resolver(z18.boolean())
|
|
3829
4333
|
}
|
|
3830
4334
|
}
|
|
3831
4335
|
},
|
|
3832
4336
|
...errors(400)
|
|
3833
4337
|
}
|
|
3834
4338
|
}),
|
|
3835
|
-
|
|
4339
|
+
validator2(
|
|
3836
4340
|
"param",
|
|
3837
4341
|
z18.object({
|
|
3838
4342
|
providerID: ProviderID.zod.meta({ description: "Provider ID" })
|
|
3839
4343
|
})
|
|
3840
4344
|
),
|
|
3841
|
-
|
|
4345
|
+
validator2(
|
|
3842
4346
|
"json",
|
|
3843
4347
|
z18.object({
|
|
3844
4348
|
method: z18.number().meta({ description: "Auth method index" }),
|
|
@@ -3860,12 +4364,11 @@ var ProviderRoutes = lazy(
|
|
|
3860
4364
|
|
|
3861
4365
|
// packages/opencode/src/server/routes/event.ts
|
|
3862
4366
|
import { Hono as Hono14 } from "hono";
|
|
3863
|
-
import { describeRoute as describeRoute13, resolver as resolver14 } from "hono-openapi";
|
|
3864
4367
|
import { streamSSE } from "hono/streaming";
|
|
3865
4368
|
var log4 = Log.create({ service: "server" });
|
|
3866
4369
|
var EventRoutes = () => new Hono14().get(
|
|
3867
4370
|
"/event",
|
|
3868
|
-
|
|
4371
|
+
describeRoute({
|
|
3869
4372
|
summary: "Subscribe to events",
|
|
3870
4373
|
description: "Get events",
|
|
3871
4374
|
operationId: "event.subscribe",
|
|
@@ -3874,7 +4377,7 @@ var EventRoutes = () => new Hono14().get(
|
|
|
3874
4377
|
description: "Event stream",
|
|
3875
4378
|
content: {
|
|
3876
4379
|
"text/event-stream": {
|
|
3877
|
-
schema:
|
|
4380
|
+
schema: resolver(BusEvent.payloads())
|
|
3878
4381
|
}
|
|
3879
4382
|
}
|
|
3880
4383
|
}
|
|
@@ -3966,7 +4469,7 @@ var DEFAULT_CSP = "default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; sty
|
|
|
3966
4469
|
var csp = (hash = "") => `default-src 'self'; script-src 'self' 'wasm-unsafe-eval'${hash ? ` 'sha256-${hash}'` : ""}; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; media-src 'self' data:; connect-src 'self' data:`;
|
|
3967
4470
|
var InstanceRoutes = (upgrade, app2 = new Hono15()) => app2.onError(errorHandler(log5)).route("/project", ProjectRoutes()).route("/pty", PtyRoutes(upgrade)).route("/config", ConfigRoutes()).route("/experimental", ExperimentalRoutes()).route("/session", SessionRoutes()).route("/permission", PermissionRoutes()).route("/question", QuestionRoutes()).route("/provider", ProviderRoutes()).route("/", FileRoutes()).route("/", EventRoutes()).route("/mcp", McpRoutes()).route("/tui", TuiRoutes()).post(
|
|
3968
4471
|
"/instance/dispose",
|
|
3969
|
-
|
|
4472
|
+
describeRoute({
|
|
3970
4473
|
summary: "Dispose instance",
|
|
3971
4474
|
description: "Clean up and dispose the current OpenCode instance, releasing all resources.",
|
|
3972
4475
|
operationId: "instance.dispose",
|
|
@@ -3975,7 +4478,7 @@ var InstanceRoutes = (upgrade, app2 = new Hono15()) => app2.onError(errorHandler
|
|
|
3975
4478
|
description: "Instance disposed",
|
|
3976
4479
|
content: {
|
|
3977
4480
|
"application/json": {
|
|
3978
|
-
schema:
|
|
4481
|
+
schema: resolver(z19.boolean())
|
|
3979
4482
|
}
|
|
3980
4483
|
}
|
|
3981
4484
|
}
|
|
@@ -3987,7 +4490,7 @@ var InstanceRoutes = (upgrade, app2 = new Hono15()) => app2.onError(errorHandler
|
|
|
3987
4490
|
}
|
|
3988
4491
|
).get(
|
|
3989
4492
|
"/path",
|
|
3990
|
-
|
|
4493
|
+
describeRoute({
|
|
3991
4494
|
summary: "Get paths",
|
|
3992
4495
|
description: "Retrieve the current working directory and related path information for the OpenCode instance.",
|
|
3993
4496
|
operationId: "path.get",
|
|
@@ -3996,7 +4499,7 @@ var InstanceRoutes = (upgrade, app2 = new Hono15()) => app2.onError(errorHandler
|
|
|
3996
4499
|
description: "Path",
|
|
3997
4500
|
content: {
|
|
3998
4501
|
"application/json": {
|
|
3999
|
-
schema:
|
|
4502
|
+
schema: resolver(
|
|
4000
4503
|
z19.object({
|
|
4001
4504
|
home: z19.string(),
|
|
4002
4505
|
state: z19.string(),
|
|
@@ -4023,7 +4526,7 @@ var InstanceRoutes = (upgrade, app2 = new Hono15()) => app2.onError(errorHandler
|
|
|
4023
4526
|
}
|
|
4024
4527
|
).get(
|
|
4025
4528
|
"/vcs",
|
|
4026
|
-
|
|
4529
|
+
describeRoute({
|
|
4027
4530
|
summary: "Get VCS info",
|
|
4028
4531
|
description: "Retrieve version control system (VCS) information for the current project, such as git branch.",
|
|
4029
4532
|
operationId: "vcs.get",
|
|
@@ -4032,7 +4535,7 @@ var InstanceRoutes = (upgrade, app2 = new Hono15()) => app2.onError(errorHandler
|
|
|
4032
4535
|
description: "VCS info",
|
|
4033
4536
|
content: {
|
|
4034
4537
|
"application/json": {
|
|
4035
|
-
schema:
|
|
4538
|
+
schema: resolver(Vcs.Info)
|
|
4036
4539
|
}
|
|
4037
4540
|
}
|
|
4038
4541
|
}
|
|
@@ -4047,7 +4550,7 @@ var InstanceRoutes = (upgrade, app2 = new Hono15()) => app2.onError(errorHandler
|
|
|
4047
4550
|
}
|
|
4048
4551
|
).get(
|
|
4049
4552
|
"/vcs/diff",
|
|
4050
|
-
|
|
4553
|
+
describeRoute({
|
|
4051
4554
|
summary: "Get VCS diff",
|
|
4052
4555
|
description: "Retrieve the current git diff for the working tree or against the default branch.",
|
|
4053
4556
|
operationId: "vcs.diff",
|
|
@@ -4056,13 +4559,13 @@ var InstanceRoutes = (upgrade, app2 = new Hono15()) => app2.onError(errorHandler
|
|
|
4056
4559
|
description: "VCS diff",
|
|
4057
4560
|
content: {
|
|
4058
4561
|
"application/json": {
|
|
4059
|
-
schema:
|
|
4562
|
+
schema: resolver(Snapshot.FileDiff.array())
|
|
4060
4563
|
}
|
|
4061
4564
|
}
|
|
4062
4565
|
}
|
|
4063
4566
|
}
|
|
4064
4567
|
}),
|
|
4065
|
-
|
|
4568
|
+
validator2(
|
|
4066
4569
|
"query",
|
|
4067
4570
|
z19.object({
|
|
4068
4571
|
mode: Vcs.Mode
|
|
@@ -4073,7 +4576,7 @@ var InstanceRoutes = (upgrade, app2 = new Hono15()) => app2.onError(errorHandler
|
|
|
4073
4576
|
}
|
|
4074
4577
|
).get(
|
|
4075
4578
|
"/command",
|
|
4076
|
-
|
|
4579
|
+
describeRoute({
|
|
4077
4580
|
summary: "List commands",
|
|
4078
4581
|
description: "Get a list of all available commands in the OpenCode system.",
|
|
4079
4582
|
operationId: "command.list",
|
|
@@ -4082,7 +4585,7 @@ var InstanceRoutes = (upgrade, app2 = new Hono15()) => app2.onError(errorHandler
|
|
|
4082
4585
|
description: "List of commands",
|
|
4083
4586
|
content: {
|
|
4084
4587
|
"application/json": {
|
|
4085
|
-
schema:
|
|
4588
|
+
schema: resolver(Command.Info.array())
|
|
4086
4589
|
}
|
|
4087
4590
|
}
|
|
4088
4591
|
}
|
|
@@ -4094,7 +4597,7 @@ var InstanceRoutes = (upgrade, app2 = new Hono15()) => app2.onError(errorHandler
|
|
|
4094
4597
|
}
|
|
4095
4598
|
).get(
|
|
4096
4599
|
"/agent",
|
|
4097
|
-
|
|
4600
|
+
describeRoute({
|
|
4098
4601
|
summary: "List agents",
|
|
4099
4602
|
description: "Get a list of all available AI agents in the OpenCode system.",
|
|
4100
4603
|
operationId: "app.agents",
|
|
@@ -4103,7 +4606,7 @@ var InstanceRoutes = (upgrade, app2 = new Hono15()) => app2.onError(errorHandler
|
|
|
4103
4606
|
description: "List of agents",
|
|
4104
4607
|
content: {
|
|
4105
4608
|
"application/json": {
|
|
4106
|
-
schema:
|
|
4609
|
+
schema: resolver(Agent.Info.array())
|
|
4107
4610
|
}
|
|
4108
4611
|
}
|
|
4109
4612
|
}
|
|
@@ -4115,7 +4618,7 @@ var InstanceRoutes = (upgrade, app2 = new Hono15()) => app2.onError(errorHandler
|
|
|
4115
4618
|
}
|
|
4116
4619
|
).get(
|
|
4117
4620
|
"/skill",
|
|
4118
|
-
|
|
4621
|
+
describeRoute({
|
|
4119
4622
|
summary: "List skills",
|
|
4120
4623
|
description: "Get a list of all available skills in the OpenCode system.",
|
|
4121
4624
|
operationId: "app.skills",
|
|
@@ -4124,7 +4627,7 @@ var InstanceRoutes = (upgrade, app2 = new Hono15()) => app2.onError(errorHandler
|
|
|
4124
4627
|
description: "List of skills",
|
|
4125
4628
|
content: {
|
|
4126
4629
|
"application/json": {
|
|
4127
|
-
schema:
|
|
4630
|
+
schema: resolver(Skill.Info.array())
|
|
4128
4631
|
}
|
|
4129
4632
|
}
|
|
4130
4633
|
}
|
|
@@ -4136,7 +4639,7 @@ var InstanceRoutes = (upgrade, app2 = new Hono15()) => app2.onError(errorHandler
|
|
|
4136
4639
|
}
|
|
4137
4640
|
).get(
|
|
4138
4641
|
"/lsp",
|
|
4139
|
-
|
|
4642
|
+
describeRoute({
|
|
4140
4643
|
summary: "Get LSP status",
|
|
4141
4644
|
description: "Get LSP server status",
|
|
4142
4645
|
operationId: "lsp.status",
|
|
@@ -4145,7 +4648,7 @@ var InstanceRoutes = (upgrade, app2 = new Hono15()) => app2.onError(errorHandler
|
|
|
4145
4648
|
description: "LSP server status",
|
|
4146
4649
|
content: {
|
|
4147
4650
|
"application/json": {
|
|
4148
|
-
schema:
|
|
4651
|
+
schema: resolver(LSP.Status.array())
|
|
4149
4652
|
}
|
|
4150
4653
|
}
|
|
4151
4654
|
}
|
|
@@ -4156,7 +4659,7 @@ var InstanceRoutes = (upgrade, app2 = new Hono15()) => app2.onError(errorHandler
|
|
|
4156
4659
|
}
|
|
4157
4660
|
).get(
|
|
4158
4661
|
"/formatter",
|
|
4159
|
-
|
|
4662
|
+
describeRoute({
|
|
4160
4663
|
summary: "Get formatter status",
|
|
4161
4664
|
description: "Get formatter status",
|
|
4162
4665
|
operationId: "formatter.status",
|
|
@@ -4165,7 +4668,7 @@ var InstanceRoutes = (upgrade, app2 = new Hono15()) => app2.onError(errorHandler
|
|
|
4165
4668
|
description: "Formatter status",
|
|
4166
4669
|
content: {
|
|
4167
4670
|
"application/json": {
|
|
4168
|
-
schema:
|
|
4671
|
+
schema: resolver(Format.Status.array())
|
|
4169
4672
|
}
|
|
4170
4673
|
}
|
|
4171
4674
|
}
|
|
@@ -4299,7 +4802,6 @@ function WorkspaceRouterMiddleware(upgrade) {
|
|
|
4299
4802
|
|
|
4300
4803
|
// packages/opencode/src/server/routes/global.ts
|
|
4301
4804
|
import { Hono as Hono16 } from "hono";
|
|
4302
|
-
import { describeRoute as describeRoute15, resolver as resolver16, validator as validator14 } from "hono-openapi";
|
|
4303
4805
|
import { streamSSE as streamSSE2 } from "hono/streaming";
|
|
4304
4806
|
import z20 from "zod";
|
|
4305
4807
|
var log6 = Log.create({ service: "server" });
|
|
@@ -4349,7 +4851,7 @@ async function streamEvents(c, subscribe) {
|
|
|
4349
4851
|
var GlobalRoutes = lazy(
|
|
4350
4852
|
() => new Hono16().get(
|
|
4351
4853
|
"/health",
|
|
4352
|
-
|
|
4854
|
+
describeRoute({
|
|
4353
4855
|
summary: "Get health",
|
|
4354
4856
|
description: "Get health information about the OpenCode server.",
|
|
4355
4857
|
operationId: "global.health",
|
|
@@ -4358,7 +4860,7 @@ var GlobalRoutes = lazy(
|
|
|
4358
4860
|
description: "Health information",
|
|
4359
4861
|
content: {
|
|
4360
4862
|
"application/json": {
|
|
4361
|
-
schema:
|
|
4863
|
+
schema: resolver(z20.object({ healthy: z20.literal(true), version: z20.string() }))
|
|
4362
4864
|
}
|
|
4363
4865
|
}
|
|
4364
4866
|
}
|
|
@@ -4369,7 +4871,7 @@ var GlobalRoutes = lazy(
|
|
|
4369
4871
|
}
|
|
4370
4872
|
).get(
|
|
4371
4873
|
"/event",
|
|
4372
|
-
|
|
4874
|
+
describeRoute({
|
|
4373
4875
|
summary: "Get global events",
|
|
4374
4876
|
description: "Subscribe to global events from the OpenCode system using server-sent events.",
|
|
4375
4877
|
operationId: "global.event",
|
|
@@ -4378,7 +4880,7 @@ var GlobalRoutes = lazy(
|
|
|
4378
4880
|
description: "Event stream",
|
|
4379
4881
|
content: {
|
|
4380
4882
|
"text/event-stream": {
|
|
4381
|
-
schema:
|
|
4883
|
+
schema: resolver(
|
|
4382
4884
|
z20.object({
|
|
4383
4885
|
directory: z20.string(),
|
|
4384
4886
|
payload: BusEvent.payloads()
|
|
@@ -4406,7 +4908,7 @@ var GlobalRoutes = lazy(
|
|
|
4406
4908
|
}
|
|
4407
4909
|
).get(
|
|
4408
4910
|
"/sync-event",
|
|
4409
|
-
|
|
4911
|
+
describeRoute({
|
|
4410
4912
|
summary: "Subscribe to global sync events",
|
|
4411
4913
|
description: "Get global sync events",
|
|
4412
4914
|
operationId: "global.sync-event.subscribe",
|
|
@@ -4415,7 +4917,7 @@ var GlobalRoutes = lazy(
|
|
|
4415
4917
|
description: "Event stream",
|
|
4416
4918
|
content: {
|
|
4417
4919
|
"text/event-stream": {
|
|
4418
|
-
schema:
|
|
4920
|
+
schema: resolver(
|
|
4419
4921
|
z20.object({
|
|
4420
4922
|
payload: SyncEvent.payloads()
|
|
4421
4923
|
}).meta({
|
|
@@ -4447,7 +4949,7 @@ var GlobalRoutes = lazy(
|
|
|
4447
4949
|
}
|
|
4448
4950
|
).get(
|
|
4449
4951
|
"/config",
|
|
4450
|
-
|
|
4952
|
+
describeRoute({
|
|
4451
4953
|
summary: "Get global configuration",
|
|
4452
4954
|
description: "Retrieve the current global OpenCode configuration settings and preferences.",
|
|
4453
4955
|
operationId: "global.config.get",
|
|
@@ -4456,7 +4958,7 @@ var GlobalRoutes = lazy(
|
|
|
4456
4958
|
description: "Get global config info",
|
|
4457
4959
|
content: {
|
|
4458
4960
|
"application/json": {
|
|
4459
|
-
schema:
|
|
4961
|
+
schema: resolver(Config.Info)
|
|
4460
4962
|
}
|
|
4461
4963
|
}
|
|
4462
4964
|
}
|
|
@@ -4467,7 +4969,7 @@ var GlobalRoutes = lazy(
|
|
|
4467
4969
|
}
|
|
4468
4970
|
).patch(
|
|
4469
4971
|
"/config",
|
|
4470
|
-
|
|
4972
|
+
describeRoute({
|
|
4471
4973
|
summary: "Update global configuration",
|
|
4472
4974
|
description: "Update global OpenCode configuration settings and preferences.",
|
|
4473
4975
|
operationId: "global.config.update",
|
|
@@ -4476,14 +4978,14 @@ var GlobalRoutes = lazy(
|
|
|
4476
4978
|
description: "Successfully updated global config",
|
|
4477
4979
|
content: {
|
|
4478
4980
|
"application/json": {
|
|
4479
|
-
schema:
|
|
4981
|
+
schema: resolver(Config.Info)
|
|
4480
4982
|
}
|
|
4481
4983
|
}
|
|
4482
4984
|
},
|
|
4483
4985
|
...errors(400)
|
|
4484
4986
|
}
|
|
4485
4987
|
}),
|
|
4486
|
-
|
|
4988
|
+
validator2("json", Config.Info),
|
|
4487
4989
|
async (c) => {
|
|
4488
4990
|
const config = c.req.valid("json");
|
|
4489
4991
|
const next = await Config.updateGlobal(config);
|
|
@@ -4491,7 +4993,7 @@ var GlobalRoutes = lazy(
|
|
|
4491
4993
|
}
|
|
4492
4994
|
).post(
|
|
4493
4995
|
"/dispose",
|
|
4494
|
-
|
|
4996
|
+
describeRoute({
|
|
4495
4997
|
summary: "Dispose instance",
|
|
4496
4998
|
description: "Clean up and dispose all OpenCode instances, releasing all resources.",
|
|
4497
4999
|
operationId: "global.dispose",
|
|
@@ -4500,7 +5002,7 @@ var GlobalRoutes = lazy(
|
|
|
4500
5002
|
description: "Global disposed",
|
|
4501
5003
|
content: {
|
|
4502
5004
|
"application/json": {
|
|
4503
|
-
schema:
|
|
5005
|
+
schema: resolver(z20.boolean())
|
|
4504
5006
|
}
|
|
4505
5007
|
}
|
|
4506
5008
|
}
|
|
@@ -4519,7 +5021,7 @@ var GlobalRoutes = lazy(
|
|
|
4519
5021
|
}
|
|
4520
5022
|
).post(
|
|
4521
5023
|
"/upgrade",
|
|
4522
|
-
|
|
5024
|
+
describeRoute({
|
|
4523
5025
|
summary: "Upgrade opencode",
|
|
4524
5026
|
description: "Upgrade opencode to the specified version or latest if not specified.",
|
|
4525
5027
|
operationId: "global.upgrade",
|
|
@@ -4528,7 +5030,7 @@ var GlobalRoutes = lazy(
|
|
|
4528
5030
|
description: "Upgrade result",
|
|
4529
5031
|
content: {
|
|
4530
5032
|
"application/json": {
|
|
4531
|
-
schema:
|
|
5033
|
+
schema: resolver(
|
|
4532
5034
|
z20.union([
|
|
4533
5035
|
z20.object({
|
|
4534
5036
|
success: z20.literal(true),
|
|
@@ -4546,7 +5048,7 @@ var GlobalRoutes = lazy(
|
|
|
4546
5048
|
...errors(400)
|
|
4547
5049
|
}
|
|
4548
5050
|
}),
|
|
4549
|
-
|
|
5051
|
+
validator2(
|
|
4550
5052
|
"json",
|
|
4551
5053
|
z20.object({
|
|
4552
5054
|
target: z20.string().optional()
|
|
@@ -4797,7 +5299,7 @@ var Server;
|
|
|
4797
5299
|
return zipped(c, next);
|
|
4798
5300
|
}).route("/global", GlobalRoutes()).put(
|
|
4799
5301
|
"/auth/:providerID",
|
|
4800
|
-
|
|
5302
|
+
describeRoute({
|
|
4801
5303
|
summary: "Set auth credentials",
|
|
4802
5304
|
description: "Set authentication credentials",
|
|
4803
5305
|
operationId: "auth.set",
|
|
@@ -4806,20 +5308,20 @@ var Server;
|
|
|
4806
5308
|
description: "Successfully set authentication credentials",
|
|
4807
5309
|
content: {
|
|
4808
5310
|
"application/json": {
|
|
4809
|
-
schema:
|
|
5311
|
+
schema: resolver(z21.boolean())
|
|
4810
5312
|
}
|
|
4811
5313
|
}
|
|
4812
5314
|
},
|
|
4813
5315
|
...errors(400)
|
|
4814
5316
|
}
|
|
4815
5317
|
}),
|
|
4816
|
-
|
|
5318
|
+
validator2(
|
|
4817
5319
|
"param",
|
|
4818
5320
|
z21.object({
|
|
4819
5321
|
providerID: ProviderID.zod
|
|
4820
5322
|
})
|
|
4821
5323
|
),
|
|
4822
|
-
|
|
5324
|
+
validator2("json", Auth.Info.zod),
|
|
4823
5325
|
async (c) => {
|
|
4824
5326
|
const providerID = c.req.valid("param").providerID;
|
|
4825
5327
|
const info = c.req.valid("json");
|
|
@@ -4828,7 +5330,7 @@ var Server;
|
|
|
4828
5330
|
}
|
|
4829
5331
|
).delete(
|
|
4830
5332
|
"/auth/:providerID",
|
|
4831
|
-
|
|
5333
|
+
describeRoute({
|
|
4832
5334
|
summary: "Remove auth credentials",
|
|
4833
5335
|
description: "Remove authentication credentials",
|
|
4834
5336
|
operationId: "auth.remove",
|
|
@@ -4837,14 +5339,14 @@ var Server;
|
|
|
4837
5339
|
description: "Successfully removed authentication credentials",
|
|
4838
5340
|
content: {
|
|
4839
5341
|
"application/json": {
|
|
4840
|
-
schema:
|
|
5342
|
+
schema: resolver(z21.boolean())
|
|
4841
5343
|
}
|
|
4842
5344
|
}
|
|
4843
5345
|
},
|
|
4844
5346
|
...errors(400)
|
|
4845
5347
|
}
|
|
4846
5348
|
}),
|
|
4847
|
-
|
|
5349
|
+
validator2(
|
|
4848
5350
|
"param",
|
|
4849
5351
|
z21.object({
|
|
4850
5352
|
providerID: ProviderID.zod
|
|
@@ -4868,7 +5370,7 @@ var Server;
|
|
|
4868
5370
|
}
|
|
4869
5371
|
})
|
|
4870
5372
|
).use(
|
|
4871
|
-
|
|
5373
|
+
validator2(
|
|
4872
5374
|
"query",
|
|
4873
5375
|
z21.object({
|
|
4874
5376
|
directory: z21.string().optional(),
|
|
@@ -4877,7 +5379,7 @@ var Server;
|
|
|
4877
5379
|
)
|
|
4878
5380
|
).post(
|
|
4879
5381
|
"/log",
|
|
4880
|
-
|
|
5382
|
+
describeRoute({
|
|
4881
5383
|
summary: "Write log",
|
|
4882
5384
|
description: "Write a log entry to the server logs with specified level and metadata.",
|
|
4883
5385
|
operationId: "app.log",
|
|
@@ -4886,14 +5388,14 @@ var Server;
|
|
|
4886
5388
|
description: "Log entry written successfully",
|
|
4887
5389
|
content: {
|
|
4888
5390
|
"application/json": {
|
|
4889
|
-
schema:
|
|
5391
|
+
schema: resolver(z21.boolean())
|
|
4890
5392
|
}
|
|
4891
5393
|
}
|
|
4892
5394
|
},
|
|
4893
5395
|
...errors(400)
|
|
4894
5396
|
}
|
|
4895
5397
|
}),
|
|
4896
|
-
|
|
5398
|
+
validator2(
|
|
4897
5399
|
"json",
|
|
4898
5400
|
z21.object({
|
|
4899
5401
|
service: z21.string().meta({ description: "Service name for the log entry" }),
|
|
@@ -5022,4 +5524,4 @@ var Server;
|
|
|
5022
5524
|
export {
|
|
5023
5525
|
Server
|
|
5024
5526
|
};
|
|
5025
|
-
//# sourceMappingURL=chunk-
|
|
5527
|
+
//# sourceMappingURL=chunk-23UYOGZG.js.map
|