Files
cnb/agent/routes/workspace/index.ts
2026-01-12 03:18:09 +08:00

24 lines
521 B
TypeScript

import { app, cnb } from '@/agent/app.ts';
app.route({
path: 'cnb',
key: 'start-workspace',
description: '启动开发工作空间, 参数 repo',
middleware: ['auth'],
metadata: {
tags: ['opencode']
}
}).define(async (ctx) => {
const repo = ctx.query?.repo;
const branch = ctx.query?.branch;
const ref = ctx.query?.ref;
if (!repo) {
ctx.throw(400, '缺少参数 repo');
}
const res = await cnb.workspace.startWorkspace(repo, {
branch,
ref
});
ctx.forward(res);
}).addTo(app);