From 5c24e197e68f042a1f1fcf4787729a4fb9ea2767 Mon Sep 17 00:00:00 2001 From: abearxiong Date: Sat, 21 Feb 2026 01:04:35 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0=E8=BA=AB=E4=BB=BD?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E4=B8=AD=E9=97=B4=E4=BB=B6=E4=B8=BA=20'auth-?= =?UTF-8?q?admin'=EF=BC=8C=E5=B9=B6=E7=AE=80=E5=8C=96=E8=BA=AB=E4=BB=BD?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E8=B7=AF=E7=94=B1=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- agent/routes/index.ts | 26 ++++++++++++++++---------- agent/routes/route-create.ts | 6 +++--- src/opencode.ts | 6 +++--- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/agent/routes/index.ts b/agent/routes/index.ts index 9644a65..ff74257 100644 --- a/agent/routes/index.ts +++ b/agent/routes/index.ts @@ -1,14 +1,20 @@ import { app } from '../app.ts' import './route-create.ts' -if (!app.hasRoute('auth', '')) { - app.route({ - path: 'auth', - key: '', - id: 'auth', - description: '身份验证路由', - }).define(async (ctx) => { - // - }).addTo(app); -} +app.route({ + path: 'auth', + key: '', + id: 'auth', + description: '身份验证路由', +}).define(async (ctx) => { + // +}).addTo(app, { overwrite: false }); +app.route({ + path: 'auth-admin', + key: '', + id: 'auth-admin', + description: '管理员身份验证路由', +}).define(async (ctx) => { + // +}).addTo(app, { overwrite: false }); \ No newline at end of file diff --git a/agent/routes/route-create.ts b/agent/routes/route-create.ts index 1fe72e2..c74662f 100644 --- a/agent/routes/route-create.ts +++ b/agent/routes/route-create.ts @@ -6,7 +6,7 @@ app.route({ path: 'router-skill', key: 'create-route', description: '创建路由技能', - middleware: ['auth'], + middleware: ['auth-admin'], metadata: { tags: ['opencode'], ...createSkill({ @@ -38,7 +38,7 @@ app.route({ path: 'router-skill', key: 'version', description: '获取最新router版本号', - middleware: ['auth'], + middleware: ['auth-admin'], metadata: { tags: ['opencode'], ...createSkill({ @@ -59,7 +59,7 @@ app.route({ path: 'route-skill', key: 'test', description: '测试路由技能', - middleware: ['auth'], + middleware: ['auth-admin'], metadata: { tags: ['opencode'], ...createSkill({ diff --git a/src/opencode.ts b/src/opencode.ts index 609d6ea..ddc8a1c 100644 --- a/src/opencode.ts +++ b/src/opencode.ts @@ -10,7 +10,7 @@ export const addCallFn = (app: App) => { path: 'call', key: '', description: '调用', - middleware: ['auth'], + middleware: ['auth-admin'], metadata: { tags: ['opencode'], ...createSkill({ @@ -24,7 +24,7 @@ export const addCallFn = (app: App) => { args: { path: tool.schema.string().describe('应用路径,例如 cnb'), 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 "使用技能查看系统信息" const AgentPlugin: Plugin = async (pluginInput) => { - useContextKey('plugin-input', () => pluginInput, true) + useContextKey('plugin-input', () => pluginInput, { isNew: true }) const hooks = opts?.hooks ? await opts.hooks(pluginInput) : {} return { ...hooks,