chore: 更新身份验证中间件为 'auth-admin',并简化身份验证路由定义
This commit is contained in:
@@ -1,14 +1,20 @@
|
|||||||
import { app } from '../app.ts'
|
import { app } from '../app.ts'
|
||||||
import './route-create.ts'
|
import './route-create.ts'
|
||||||
|
|
||||||
if (!app.hasRoute('auth', '')) {
|
app.route({
|
||||||
app.route({
|
|
||||||
path: 'auth',
|
path: 'auth',
|
||||||
key: '',
|
key: '',
|
||||||
id: 'auth',
|
id: 'auth',
|
||||||
description: '身份验证路由',
|
description: '身份验证路由',
|
||||||
}).define(async (ctx) => {
|
}).define(async (ctx) => {
|
||||||
//
|
//
|
||||||
}).addTo(app);
|
}).addTo(app, { overwrite: false });
|
||||||
}
|
|
||||||
|
|
||||||
|
app.route({
|
||||||
|
path: 'auth-admin',
|
||||||
|
key: '',
|
||||||
|
id: 'auth-admin',
|
||||||
|
description: '管理员身份验证路由',
|
||||||
|
}).define(async (ctx) => {
|
||||||
|
//
|
||||||
|
}).addTo(app, { overwrite: false });
|
||||||
@@ -6,7 +6,7 @@ app.route({
|
|||||||
path: 'router-skill',
|
path: 'router-skill',
|
||||||
key: 'create-route',
|
key: 'create-route',
|
||||||
description: '创建路由技能',
|
description: '创建路由技能',
|
||||||
middleware: ['auth'],
|
middleware: ['auth-admin'],
|
||||||
metadata: {
|
metadata: {
|
||||||
tags: ['opencode'],
|
tags: ['opencode'],
|
||||||
...createSkill({
|
...createSkill({
|
||||||
@@ -38,7 +38,7 @@ app.route({
|
|||||||
path: 'router-skill',
|
path: 'router-skill',
|
||||||
key: 'version',
|
key: 'version',
|
||||||
description: '获取最新router版本号',
|
description: '获取最新router版本号',
|
||||||
middleware: ['auth'],
|
middleware: ['auth-admin'],
|
||||||
metadata: {
|
metadata: {
|
||||||
tags: ['opencode'],
|
tags: ['opencode'],
|
||||||
...createSkill({
|
...createSkill({
|
||||||
@@ -59,7 +59,7 @@ app.route({
|
|||||||
path: 'route-skill',
|
path: 'route-skill',
|
||||||
key: 'test',
|
key: 'test',
|
||||||
description: '测试路由技能',
|
description: '测试路由技能',
|
||||||
middleware: ['auth'],
|
middleware: ['auth-admin'],
|
||||||
metadata: {
|
metadata: {
|
||||||
tags: ['opencode'],
|
tags: ['opencode'],
|
||||||
...createSkill({
|
...createSkill({
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export const addCallFn = (app: App) => {
|
|||||||
path: 'call',
|
path: 'call',
|
||||||
key: '',
|
key: '',
|
||||||
description: '调用',
|
description: '调用',
|
||||||
middleware: ['auth'],
|
middleware: ['auth-admin'],
|
||||||
metadata: {
|
metadata: {
|
||||||
tags: ['opencode'],
|
tags: ['opencode'],
|
||||||
...createSkill({
|
...createSkill({
|
||||||
@@ -24,7 +24,7 @@ export const addCallFn = (app: App) => {
|
|||||||
args: {
|
args: {
|
||||||
path: tool.schema.string().describe('应用路径,例如 cnb'),
|
path: tool.schema.string().describe('应用路径,例如 cnb'),
|
||||||
key: tool.schema.string().optional().describe('应用key,例如 list-repos'),
|
key: tool.schema.string().optional().describe('应用key,例如 list-repos'),
|
||||||
payload: tool.schema.object({}).optional().describe('调用参数'),
|
payload: tool.schema.object({}).optional().describe('调用参数, 为对象, 例如 { "query": "javascript" }'),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -75,7 +75,7 @@ export const createRouterAgentPluginFn = (opts?: {
|
|||||||
});
|
});
|
||||||
// opencode run "使用技能查看系统信息"
|
// opencode run "使用技能查看系统信息"
|
||||||
const AgentPlugin: Plugin = async (pluginInput) => {
|
const AgentPlugin: Plugin = async (pluginInput) => {
|
||||||
useContextKey<PluginInput>('plugin-input', () => pluginInput, true)
|
useContextKey<PluginInput>('plugin-input', () => pluginInput, { isNew: true })
|
||||||
const hooks = opts?.hooks ? await opts.hooks(pluginInput) : {}
|
const hooks = opts?.hooks ? await opts.hooks(pluginInput) : {}
|
||||||
return {
|
return {
|
||||||
...hooks,
|
...hooks,
|
||||||
|
|||||||
Reference in New Issue
Block a user