@kevisual/cnb 0.0.34 → 0.0.35

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.
@@ -6,7 +6,7 @@ app.route({
6
6
  path: 'call',
7
7
  key: '',
8
8
  description: '调用',
9
- middleware: ['admin-auth'],
9
+ middleware: ['auth-admin'],
10
10
  metadata: {
11
11
  tags: ['opencode'],
12
12
  ...createSkill({
@@ -7,7 +7,7 @@ app.route({
7
7
  path: 'cnb',
8
8
  key: 'user-check',
9
9
  description: '检查用户登录状态,参数checkToken,default true; checkCookie, default false',
10
- middleware: ['admin-auth'],
10
+ middleware: ['auth-admin'],
11
11
  metadata: {
12
12
  tags: ['opencode'],
13
13
  ...createSkill({
@@ -6,7 +6,7 @@ app.route({
6
6
  path: 'cnb',
7
7
  key: 'set-cnb-cookie',
8
8
  description: '设置当前cnb工作空间的cookie环境变量',
9
- middleware: ['admin-auth'],
9
+ middleware: ['auth-admin'],
10
10
  metadata: {
11
11
  tags: ['opencode'],
12
12
  ...createSkill({
@@ -33,7 +33,7 @@ app.route({
33
33
  path: 'cnb',
34
34
  key: 'get-cnb-cookie',
35
35
  description: '获取当前cnb工作空间的cookie环境变量',
36
- middleware: ['admin-auth'],
36
+ middleware: ['auth-admin'],
37
37
  metadata: {
38
38
  tags: ['opencode'],
39
39
  ...createSkill({
@@ -11,7 +11,7 @@ app.route({
11
11
  path: 'cnb',
12
12
  key: 'get-cnb-port-uri',
13
13
  description: '获取当前cnb工作空间的port代理uri',
14
- middleware: ['admin-auth'],
14
+ middleware: ['auth-admin'],
15
15
  metadata: {
16
16
  tags: ['opencode'],
17
17
  ...createSkill({
@@ -19,12 +19,12 @@ app.route({
19
19
  title: '获取当前cnb工作空间的port代理uri',
20
20
  summary: '获取当前cnb工作空间的port代理uri,用于端口转发',
21
21
  args: {
22
- port: tool.schema.number().optional().describe('端口号,默认为4096'),
22
+ port: tool.schema.number().optional().describe('端口号,默认为51515'),
23
23
  }
24
24
  })
25
25
  }
26
26
  }).define(async (ctx) => {
27
- const port = ctx.query?.port || 4096;
27
+ const port = ctx.query?.port || 51515;
28
28
  const uri = CNB_ENV?.CNB_VSCODE_PROXY_URI as string || '';
29
29
  const finalUri = uri.replace('{{port}}', port.toString());
30
30
  let content = `
@@ -40,7 +40,7 @@ app.route({
40
40
  path: 'cnb',
41
41
  key: 'get-cnb-vscode-uri',
42
42
  description: '获取当前cnb工作空间的vscode代理uri, 包括多种访问方式, 如web、vscode、codebuddy、cursor、ssh',
43
- middleware: ['admin-auth'],
43
+ middleware: ['auth-admin'],
44
44
  metadata: {
45
45
  tags: ['opencode'],
46
46
  ...createSkill({
@@ -37,8 +37,8 @@ app.route({
37
37
  }).addTo(app, { overwrite: false });
38
38
 
39
39
  app.route({
40
- id: 'admin-auth',
41
- path: 'admin-auth',
40
+ id: 'auth-admin',
41
+ path: 'auth-admin',
42
42
  middleware: ['auth'],
43
43
  }).define(async (ctx) => {
44
44
  // ctx.body = 'Admin Auth Route';
@@ -7,7 +7,7 @@ app.route({
7
7
  path: 'cnb',
8
8
  key: 'create-issue',
9
9
  description: '创建 Issue, 参数 repo, title, body, assignees, labels, priority',
10
- middleware: ['admin-auth'],
10
+ middleware: ['auth-admin'],
11
11
  metadata: {
12
12
  tags: ['opencode'],
13
13
  ...createSkill({
@@ -51,7 +51,7 @@ app.route({
51
51
  path: 'cnb',
52
52
  key: 'complete-issue',
53
53
  description: '完成 Issue, 参数 repo, issueNumber',
54
- middleware: ['admin-auth'],
54
+ middleware: ['auth-admin'],
55
55
  metadata: {
56
56
  tags: ['opencode'],
57
57
  ...createSkill({
@@ -1,12 +1,13 @@
1
1
  import { createSkill, tool } from '@kevisual/router';
2
2
  import { app, cnb } from '../../app.ts';
3
+ import { useKey } from '@kevisual/context';
3
4
 
4
5
  // 查询 Issue 列表 repo是 kevisual/kevisual
5
6
  app.route({
6
7
  path: 'cnb',
7
8
  key: 'list-issues',
8
9
  description: '查询 Issue 列表, 参数 repo, state, keyword, labels, page, page_size 等',
9
- middleware: ['admin-auth'],
10
+ middleware: ['auth-admin'],
10
11
  metadata: {
11
12
  tags: ['opencode'],
12
13
  ...createSkill({
@@ -25,7 +26,7 @@ app.route({
25
26
  })
26
27
  }
27
28
  }).define(async (ctx) => {
28
- const repo = ctx.query?.repo;
29
+ const repo = ctx.query?.repo || useKey('CNB_REPO_SLUG_LOWERCASE');
29
30
  const state = ctx.query?.state;
30
31
  const keyword = ctx.query?.keyword;
31
32
  const labels = ctx.query?.labels;
@@ -1,6 +1,7 @@
1
1
  import { createSkill, tool } from '@kevisual/router';
2
2
  import { app, cnb } from '../../app.ts';
3
3
  import { CNBChat } from '@kevisual/ai/browser'
4
+ import { useKey } from '@kevisual/context';
4
5
 
5
6
  /**
6
7
 
@@ -12,7 +13,7 @@ app.route({
12
13
  path: 'cnb',
13
14
  key: 'cnb-ai-chat',
14
15
  description: '调用cnb的知识库ai对话功能进行聊天',
15
- middleware: ['admin-auth'],
16
+ middleware: ['auth-admin'],
16
17
  metadata: {
17
18
  tags: ['opencode'],
18
19
  ...createSkill({
@@ -88,7 +89,7 @@ app.route({
88
89
  path: 'cnb',
89
90
  key: 'cnb-rag-query',
90
91
  description: '调用cnb的知识库RAG查询功能进行问答',
91
- middleware: ['admin-auth'],
92
+ middleware: ['auth-admin'],
92
93
  metadata: {
93
94
  tags: ['opencode'],
94
95
  ...createSkill({
@@ -107,7 +108,7 @@ app.route({
107
108
  ctx.body = { content: '请提供有效的消息内容' };
108
109
  return;
109
110
  }
110
- let repo = ctx.query?.repo;
111
+ let repo = ctx.query?.repo || useKey('CNB_REPO_SLUG_LOWERCASE');
111
112
  if (!repo) {
112
113
  // 如果未指定知识库仓库ID,则使用默认知识库
113
114
  const res = await cnb.repo.getRepoList({ flags: 'KnowledgeBase' });
@@ -7,7 +7,7 @@ app.route({
7
7
  path: 'cnb',
8
8
  key: 'list-repos',
9
9
  description: '列出我的代码仓库',
10
- middleware: ['admin-auth'],
10
+ middleware: ['auth-admin'],
11
11
  metadata: {
12
12
  tags: ['opencode'],
13
13
  ...createSkill({
@@ -6,7 +6,7 @@ app.route({
6
6
  path: 'cnb',
7
7
  key: 'create-repo',
8
8
  description: '创建代码仓库, 参数name, visibility, description',
9
- middleware: ['admin-auth'],
9
+ middleware: ['auth-admin'],
10
10
  metadata: {
11
11
  tags: ['opencode'],
12
12
  ...createSkill({
@@ -45,8 +45,8 @@ app.route({
45
45
  app.route({
46
46
  path: 'cnb',
47
47
  key: 'create-repo-file',
48
- description: '在代码仓库中创建文件, repoName, filePath, content, encoding',
49
- middleware: ['admin-auth'],
48
+ description: '在代码仓库中创建文件, repoName, filePath, content, encoding。使用CNB_COOKIE进行鉴权',
49
+ middleware: ['auth-admin'],
50
50
  metadata: {
51
51
  tags: ['opencode'],
52
52
  ...createSkill({
@@ -85,7 +85,7 @@ app.route({
85
85
  path: 'cnb',
86
86
  key: 'delete-repo',
87
87
  description: '删除代码仓库, 参数name',
88
- middleware: ['admin-auth'],
88
+ middleware: ['auth-admin'],
89
89
  metadata: {
90
90
  tags: ['opencode'],
91
91
  ...createSkill({
@@ -9,7 +9,7 @@ app.route({
9
9
  path: 'cnb',
10
10
  key: 'start-workspace',
11
11
  description: '启动开发工作空间, 参数 repo',
12
- middleware: ['admin-auth'],
12
+ middleware: ['auth-admin'],
13
13
  metadata: {
14
14
  tags: ['opencode'],
15
15
  ...createSkill({
@@ -42,7 +42,7 @@ app.route({
42
42
  path: 'cnb',
43
43
  key: 'list-workspace',
44
44
  description: '获取cnb开发工作空间列表,可选参数 status=running 获取运行中的环境',
45
- middleware: ['admin-auth'],
45
+ middleware: ['auth-admin'],
46
46
  metadata: {
47
47
  tags: ['opencode'],
48
48
  ...createSkill({
@@ -73,7 +73,7 @@ app.route({
73
73
  path: 'cnb',
74
74
  key: 'get-workspace',
75
75
  description: '获取工作空间详情,通过 repo 和 sn 获取',
76
- middleware: ['admin-auth'],
76
+ middleware: ['auth-admin'],
77
77
  metadata: {
78
78
  tags: ['opencode'],
79
79
  ...createSkill({
@@ -104,7 +104,7 @@ app.route({
104
104
  path: 'cnb',
105
105
  key: 'delete-workspace',
106
106
  description: '删除工作空间,通过 pipelineId 或 sn',
107
- middleware: ['admin-auth'],
107
+ middleware: ['auth-admin'],
108
108
  metadata: {
109
109
  tags: ['opencode'],
110
110
  ...createSkill({
@@ -143,7 +143,7 @@ app.route({
143
143
  path: 'cnb',
144
144
  key: 'stop-workspace',
145
145
  description: '停止工作空间,通过 pipelineId 或 sn',
146
- middleware: ['admin-auth'],
146
+ middleware: ['auth-admin'],
147
147
  metadata: {
148
148
  tags: ['opencode'],
149
149
  ...createSkill({
@@ -8,7 +8,7 @@ app.route({
8
8
  path: 'cnb',
9
9
  key: 'keep-workspace-alive',
10
10
  description: '保持工作空间存活技能,参数repo:代码仓库路径,例如 user/repo,pipelineId:流水线ID,例如 cnb-708-1ji9sog7o-001',
11
- middleware: ['admin-auth'],
11
+ middleware: ['auth-admin'],
12
12
  metadata: {
13
13
  tags: [],
14
14
  ...({
@@ -52,7 +52,7 @@ app.route({
52
52
  path: 'cnb',
53
53
  key: 'stop-keep-workspace-alive',
54
54
  description: '停止保持工作空间存活技能, 参数repo:代码仓库路径,例如 user/repo,pipelineId:流水线ID,例如 cnb-708-1ji9sog7o-001',
55
- middleware: ['admin-auth'],
55
+ middleware: ['auth-admin'],
56
56
  metadata: {
57
57
  tags: [],
58
58
  ...({
@@ -80,7 +80,7 @@ app.route({
80
80
  path: 'cnb',
81
81
  key: 'keep-alive-current-workspace',
82
82
  description: '保持当前工作空间存活技能',
83
- middleware: ['admin-auth'],
83
+ middleware: ['auth-admin'],
84
84
  metadata: {
85
85
  tags: ['opencode'],
86
86
  skill: 'keep-alive-current-workspace',
@@ -35,7 +35,7 @@ app.route({
35
35
  path: 'cnb',
36
36
  key: 'clean-closed-workspace',
37
37
  description: '批量删除已停止的cnb工作空间',
38
- middleware: ['admin-auth'],
38
+ middleware: ['auth-admin'],
39
39
  metadata: {
40
40
  tags: ['opencode'],
41
41
  ...createSkill({
@@ -45,7 +45,7 @@ app.route({
45
45
  })
46
46
  }
47
47
  }).define(async (ctx) => {
48
- const closedWorkspaces = await cnb.workspace.list({ status: 'closed' });
48
+ const closedWorkspaces = await cnb.workspace.list({ status: 'closed', pageSize: 100 });
49
49
  if (closedWorkspaces.code !== 200) {
50
50
  ctx.throw(500, '获取已关闭工作空间列表失败');
51
51
  }
package/dist/opencode.js CHANGED
@@ -33946,7 +33946,7 @@ app.route({
33946
33946
  path: "cnb",
33947
33947
  key: "user-check",
33948
33948
  description: "检查用户登录状态,参数checkToken,default true; checkCookie, default false",
33949
- middleware: ["admin-auth"],
33949
+ middleware: ["auth-admin"],
33950
33950
  metadata: {
33951
33951
  tags: ["opencode"],
33952
33952
  ...createSkill({
@@ -33991,7 +33991,7 @@ app.route({
33991
33991
  path: "cnb",
33992
33992
  key: "list-repos",
33993
33993
  description: "列出我的代码仓库",
33994
- middleware: ["admin-auth"],
33994
+ middleware: ["auth-admin"],
33995
33995
  metadata: {
33996
33996
  tags: ["opencode"],
33997
33997
  ...createSkill({
@@ -34032,7 +34032,7 @@ app.route({
34032
34032
  path: "cnb",
34033
34033
  key: "create-repo",
34034
34034
  description: "创建代码仓库, 参数name, visibility, description",
34035
- middleware: ["admin-auth"],
34035
+ middleware: ["auth-admin"],
34036
34036
  metadata: {
34037
34037
  tags: ["opencode"],
34038
34038
  ...createSkill({
@@ -34068,8 +34068,8 @@ app.route({
34068
34068
  app.route({
34069
34069
  path: "cnb",
34070
34070
  key: "create-repo-file",
34071
- description: "在代码仓库中创建文件, repoName, filePath, content, encoding",
34072
- middleware: ["admin-auth"],
34071
+ description: "在代码仓库中创建文件, repoName, filePath, content, encoding。使用CNB_COOKIE进行鉴权",
34072
+ middleware: ["auth-admin"],
34073
34073
  metadata: {
34074
34074
  tags: ["opencode"],
34075
34075
  ...createSkill({
@@ -34104,7 +34104,7 @@ app.route({
34104
34104
  path: "cnb",
34105
34105
  key: "delete-repo",
34106
34106
  description: "删除代码仓库, 参数name",
34107
- middleware: ["admin-auth"],
34107
+ middleware: ["auth-admin"],
34108
34108
  metadata: {
34109
34109
  tags: ["opencode"],
34110
34110
  ...createSkill({
@@ -34130,7 +34130,7 @@ app.route({
34130
34130
  path: "cnb",
34131
34131
  key: "clean-closed-workspace",
34132
34132
  description: "批量删除已停止的cnb工作空间",
34133
- middleware: ["admin-auth"],
34133
+ middleware: ["auth-admin"],
34134
34134
  metadata: {
34135
34135
  tags: ["opencode"],
34136
34136
  ...createSkill({
@@ -34140,7 +34140,7 @@ app.route({
34140
34140
  })
34141
34141
  }
34142
34142
  }).define(async (ctx) => {
34143
- const closedWorkspaces = await cnb.workspace.list({ status: "closed" });
34143
+ const closedWorkspaces = await cnb.workspace.list({ status: "closed", pageSize: 100 });
34144
34144
  if (closedWorkspaces.code !== 200) {
34145
34145
  ctx.throw(500, "获取已关闭工作空间列表失败");
34146
34146
  }
@@ -34259,7 +34259,7 @@ app.route({
34259
34259
  path: "cnb",
34260
34260
  key: "keep-workspace-alive",
34261
34261
  description: "保持工作空间存活技能,参数repo:代码仓库路径,例如 user/repo,pipelineId:流水线ID,例如 cnb-708-1ji9sog7o-001",
34262
- middleware: ["admin-auth"],
34262
+ middleware: ["auth-admin"],
34263
34263
  metadata: {
34264
34264
  tags: [],
34265
34265
  ...{
@@ -34297,7 +34297,7 @@ app.route({
34297
34297
  path: "cnb",
34298
34298
  key: "stop-keep-workspace-alive",
34299
34299
  description: "停止保持工作空间存活技能, 参数repo:代码仓库路径,例如 user/repo,pipelineId:流水线ID,例如 cnb-708-1ji9sog7o-001",
34300
- middleware: ["admin-auth"],
34300
+ middleware: ["auth-admin"],
34301
34301
  metadata: {
34302
34302
  tags: [],
34303
34303
  ...{
@@ -34320,7 +34320,7 @@ app.route({
34320
34320
  path: "cnb",
34321
34321
  key: "keep-alive-current-workspace",
34322
34322
  description: "保持当前工作空间存活技能",
34323
- middleware: ["admin-auth"],
34323
+ middleware: ["auth-admin"],
34324
34324
  metadata: {
34325
34325
  tags: ["opencode"],
34326
34326
  skill: "keep-alive-current-workspace",
@@ -34342,7 +34342,7 @@ app.route({
34342
34342
  path: "cnb",
34343
34343
  key: "start-workspace",
34344
34344
  description: "启动开发工作空间, 参数 repo",
34345
- middleware: ["admin-auth"],
34345
+ middleware: ["auth-admin"],
34346
34346
  metadata: {
34347
34347
  tags: ["opencode"],
34348
34348
  ...createSkill({
@@ -34373,7 +34373,7 @@ app.route({
34373
34373
  path: "cnb",
34374
34374
  key: "list-workspace",
34375
34375
  description: "获取cnb开发工作空间列表,可选参数 status=running 获取运行中的环境",
34376
- middleware: ["admin-auth"],
34376
+ middleware: ["auth-admin"],
34377
34377
  metadata: {
34378
34378
  tags: ["opencode"],
34379
34379
  ...createSkill({
@@ -34402,7 +34402,7 @@ app.route({
34402
34402
  path: "cnb",
34403
34403
  key: "get-workspace",
34404
34404
  description: "获取工作空间详情,通过 repo 和 sn 获取",
34405
- middleware: ["admin-auth"],
34405
+ middleware: ["auth-admin"],
34406
34406
  metadata: {
34407
34407
  tags: ["opencode"],
34408
34408
  ...createSkill({
@@ -34431,7 +34431,7 @@ app.route({
34431
34431
  path: "cnb",
34432
34432
  key: "delete-workspace",
34433
34433
  description: "删除工作空间,通过 pipelineId 或 sn",
34434
- middleware: ["admin-auth"],
34434
+ middleware: ["auth-admin"],
34435
34435
  metadata: {
34436
34436
  tags: ["opencode"],
34437
34437
  ...createSkill({
@@ -34468,7 +34468,7 @@ app.route({
34468
34468
  path: "cnb",
34469
34469
  key: "stop-workspace",
34470
34470
  description: "停止工作空间,通过 pipelineId 或 sn",
34471
- middleware: ["admin-auth"],
34471
+ middleware: ["auth-admin"],
34472
34472
  metadata: {
34473
34473
  tags: ["opencode"],
34474
34474
  ...createSkill({
@@ -34496,7 +34496,7 @@ app.route({
34496
34496
  path: "call",
34497
34497
  key: "",
34498
34498
  description: "调用",
34499
- middleware: ["admin-auth"],
34499
+ middleware: ["auth-admin"],
34500
34500
  metadata: {
34501
34501
  tags: ["opencode"],
34502
34502
  ...createSkill({
@@ -34545,7 +34545,7 @@ app.route({
34545
34545
  path: "cnb",
34546
34546
  key: "get-cnb-port-uri",
34547
34547
  description: "获取当前cnb工作空间的port代理uri",
34548
- middleware: ["admin-auth"],
34548
+ middleware: ["auth-admin"],
34549
34549
  metadata: {
34550
34550
  tags: ["opencode"],
34551
34551
  ...createSkill({
@@ -34553,12 +34553,12 @@ app.route({
34553
34553
  title: "获取当前cnb工作空间的port代理uri",
34554
34554
  summary: "获取当前cnb工作空间的port代理uri,用于端口转发",
34555
34555
  args: {
34556
- port: tool.schema.number().optional().describe("端口号,默认为4096")
34556
+ port: tool.schema.number().optional().describe("端口号,默认为51515")
34557
34557
  }
34558
34558
  })
34559
34559
  }
34560
34560
  }).define(async (ctx) => {
34561
- const port = ctx.query?.port || 4096;
34561
+ const port = ctx.query?.port || 51515;
34562
34562
  const uri = CNB_ENV?.CNB_VSCODE_PROXY_URI || "";
34563
34563
  const finalUri = uri.replace("{{port}}", port.toString());
34564
34564
  let content = `
@@ -34570,7 +34570,7 @@ app.route({
34570
34570
  path: "cnb",
34571
34571
  key: "get-cnb-vscode-uri",
34572
34572
  description: "获取当前cnb工作空间的vscode代理uri, 包括多种访问方式, 如web、vscode、codebuddy、cursor、ssh",
34573
- middleware: ["admin-auth"],
34573
+ middleware: ["auth-admin"],
34574
34574
  metadata: {
34575
34575
  tags: ["opencode"],
34576
34576
  ...createSkill({
@@ -34631,7 +34631,7 @@ app.route({
34631
34631
  path: "cnb",
34632
34632
  key: "set-cnb-cookie",
34633
34633
  description: "设置当前cnb工作空间的cookie环境变量",
34634
- middleware: ["admin-auth"],
34634
+ middleware: ["auth-admin"],
34635
34635
  metadata: {
34636
34636
  tags: ["opencode"],
34637
34637
  ...createSkill({
@@ -34656,7 +34656,7 @@ app.route({
34656
34656
  path: "cnb",
34657
34657
  key: "get-cnb-cookie",
34658
34658
  description: "获取当前cnb工作空间的cookie环境变量",
34659
- middleware: ["admin-auth"],
34659
+ middleware: ["auth-admin"],
34660
34660
  metadata: {
34661
34661
  tags: ["opencode"],
34662
34662
  ...createSkill({
@@ -54525,7 +54525,7 @@ app.route({
54525
54525
  path: "cnb",
54526
54526
  key: "cnb-ai-chat",
54527
54527
  description: "调用cnb的知识库ai对话功能进行聊天",
54528
- middleware: ["admin-auth"],
54528
+ middleware: ["auth-admin"],
54529
54529
  metadata: {
54530
54530
  tags: ["opencode"],
54531
54531
  ...createSkill({
@@ -54627,7 +54627,7 @@ app.route({
54627
54627
  path: "cnb",
54628
54628
  key: "cnb-rag-query",
54629
54629
  description: "调用cnb的知识库RAG查询功能进行问答",
54630
- middleware: ["admin-auth"],
54630
+ middleware: ["auth-admin"],
54631
54631
  metadata: {
54632
54632
  tags: ["opencode"],
54633
54633
  ...createSkill({
@@ -54646,7 +54646,7 @@ app.route({
54646
54646
  ctx.body = { content: "请提供有效的消息内容" };
54647
54647
  return;
54648
54648
  }
54649
- let repo2 = ctx.query?.repo;
54649
+ let repo2 = ctx.query?.repo || useKey("CNB_REPO_SLUG_LOWERCASE");
54650
54650
  if (!repo2) {
54651
54651
  const res = await cnb.repo.getRepoList({ flags: "KnowledgeBase" });
54652
54652
  if (res.code === 200 && res.data.length > 0) {
@@ -54690,7 +54690,7 @@ app.route({
54690
54690
  path: "cnb",
54691
54691
  key: "list-issues",
54692
54692
  description: "查询 Issue 列表, 参数 repo, state, keyword, labels, page, page_size 等",
54693
- middleware: ["admin-auth"],
54693
+ middleware: ["auth-admin"],
54694
54694
  metadata: {
54695
54695
  tags: ["opencode"],
54696
54696
  ...createSkill({
@@ -54709,7 +54709,7 @@ app.route({
54709
54709
  })
54710
54710
  }
54711
54711
  }).define(async (ctx) => {
54712
- const repo2 = ctx.query?.repo;
54712
+ const repo2 = ctx.query?.repo || useKey("CNB_REPO_SLUG_LOWERCASE");
54713
54713
  const state = ctx.query?.state;
54714
54714
  const keyword = ctx.query?.keyword;
54715
54715
  const labels = ctx.query?.labels;
@@ -54741,7 +54741,7 @@ app.route({
54741
54741
  path: "cnb",
54742
54742
  key: "create-issue",
54743
54743
  description: "创建 Issue, 参数 repo, title, body, assignees, labels, priority",
54744
- middleware: ["admin-auth"],
54744
+ middleware: ["auth-admin"],
54745
54745
  metadata: {
54746
54746
  tags: ["opencode"],
54747
54747
  ...createSkill({
@@ -54781,7 +54781,7 @@ app.route({
54781
54781
  path: "cnb",
54782
54782
  key: "complete-issue",
54783
54783
  description: "完成 Issue, 参数 repo, issueNumber",
54784
- middleware: ["admin-auth"],
54784
+ middleware: ["auth-admin"],
54785
54785
  metadata: {
54786
54786
  tags: ["opencode"],
54787
54787
  ...createSkill({
@@ -55573,8 +55573,8 @@ app.route({
55573
55573
  }
55574
55574
  }).addTo(app, { overwrite: false });
55575
55575
  app.route({
55576
- id: "admin-auth",
55577
- path: "admin-auth",
55576
+ id: "auth-admin",
55577
+ path: "auth-admin",
55578
55578
  middleware: ["auth"]
55579
55579
  }).define(async (ctx) => {
55580
55580
  if (checkAppId(ctx, app.appId)) {
package/dist/routes.js CHANGED
@@ -33946,7 +33946,7 @@ app.route({
33946
33946
  path: "cnb",
33947
33947
  key: "user-check",
33948
33948
  description: "检查用户登录状态,参数checkToken,default true; checkCookie, default false",
33949
- middleware: ["admin-auth"],
33949
+ middleware: ["auth-admin"],
33950
33950
  metadata: {
33951
33951
  tags: ["opencode"],
33952
33952
  ...createSkill({
@@ -33991,7 +33991,7 @@ app.route({
33991
33991
  path: "cnb",
33992
33992
  key: "list-repos",
33993
33993
  description: "列出我的代码仓库",
33994
- middleware: ["admin-auth"],
33994
+ middleware: ["auth-admin"],
33995
33995
  metadata: {
33996
33996
  tags: ["opencode"],
33997
33997
  ...createSkill({
@@ -34032,7 +34032,7 @@ app.route({
34032
34032
  path: "cnb",
34033
34033
  key: "create-repo",
34034
34034
  description: "创建代码仓库, 参数name, visibility, description",
34035
- middleware: ["admin-auth"],
34035
+ middleware: ["auth-admin"],
34036
34036
  metadata: {
34037
34037
  tags: ["opencode"],
34038
34038
  ...createSkill({
@@ -34068,8 +34068,8 @@ app.route({
34068
34068
  app.route({
34069
34069
  path: "cnb",
34070
34070
  key: "create-repo-file",
34071
- description: "在代码仓库中创建文件, repoName, filePath, content, encoding",
34072
- middleware: ["admin-auth"],
34071
+ description: "在代码仓库中创建文件, repoName, filePath, content, encoding。使用CNB_COOKIE进行鉴权",
34072
+ middleware: ["auth-admin"],
34073
34073
  metadata: {
34074
34074
  tags: ["opencode"],
34075
34075
  ...createSkill({
@@ -34104,7 +34104,7 @@ app.route({
34104
34104
  path: "cnb",
34105
34105
  key: "delete-repo",
34106
34106
  description: "删除代码仓库, 参数name",
34107
- middleware: ["admin-auth"],
34107
+ middleware: ["auth-admin"],
34108
34108
  metadata: {
34109
34109
  tags: ["opencode"],
34110
34110
  ...createSkill({
@@ -34130,7 +34130,7 @@ app.route({
34130
34130
  path: "cnb",
34131
34131
  key: "clean-closed-workspace",
34132
34132
  description: "批量删除已停止的cnb工作空间",
34133
- middleware: ["admin-auth"],
34133
+ middleware: ["auth-admin"],
34134
34134
  metadata: {
34135
34135
  tags: ["opencode"],
34136
34136
  ...createSkill({
@@ -34140,7 +34140,7 @@ app.route({
34140
34140
  })
34141
34141
  }
34142
34142
  }).define(async (ctx) => {
34143
- const closedWorkspaces = await cnb.workspace.list({ status: "closed" });
34143
+ const closedWorkspaces = await cnb.workspace.list({ status: "closed", pageSize: 100 });
34144
34144
  if (closedWorkspaces.code !== 200) {
34145
34145
  ctx.throw(500, "获取已关闭工作空间列表失败");
34146
34146
  }
@@ -34259,7 +34259,7 @@ app.route({
34259
34259
  path: "cnb",
34260
34260
  key: "keep-workspace-alive",
34261
34261
  description: "保持工作空间存活技能,参数repo:代码仓库路径,例如 user/repo,pipelineId:流水线ID,例如 cnb-708-1ji9sog7o-001",
34262
- middleware: ["admin-auth"],
34262
+ middleware: ["auth-admin"],
34263
34263
  metadata: {
34264
34264
  tags: [],
34265
34265
  ...{
@@ -34297,7 +34297,7 @@ app.route({
34297
34297
  path: "cnb",
34298
34298
  key: "stop-keep-workspace-alive",
34299
34299
  description: "停止保持工作空间存活技能, 参数repo:代码仓库路径,例如 user/repo,pipelineId:流水线ID,例如 cnb-708-1ji9sog7o-001",
34300
- middleware: ["admin-auth"],
34300
+ middleware: ["auth-admin"],
34301
34301
  metadata: {
34302
34302
  tags: [],
34303
34303
  ...{
@@ -34320,7 +34320,7 @@ app.route({
34320
34320
  path: "cnb",
34321
34321
  key: "keep-alive-current-workspace",
34322
34322
  description: "保持当前工作空间存活技能",
34323
- middleware: ["admin-auth"],
34323
+ middleware: ["auth-admin"],
34324
34324
  metadata: {
34325
34325
  tags: ["opencode"],
34326
34326
  skill: "keep-alive-current-workspace",
@@ -34342,7 +34342,7 @@ app.route({
34342
34342
  path: "cnb",
34343
34343
  key: "start-workspace",
34344
34344
  description: "启动开发工作空间, 参数 repo",
34345
- middleware: ["admin-auth"],
34345
+ middleware: ["auth-admin"],
34346
34346
  metadata: {
34347
34347
  tags: ["opencode"],
34348
34348
  ...createSkill({
@@ -34373,7 +34373,7 @@ app.route({
34373
34373
  path: "cnb",
34374
34374
  key: "list-workspace",
34375
34375
  description: "获取cnb开发工作空间列表,可选参数 status=running 获取运行中的环境",
34376
- middleware: ["admin-auth"],
34376
+ middleware: ["auth-admin"],
34377
34377
  metadata: {
34378
34378
  tags: ["opencode"],
34379
34379
  ...createSkill({
@@ -34402,7 +34402,7 @@ app.route({
34402
34402
  path: "cnb",
34403
34403
  key: "get-workspace",
34404
34404
  description: "获取工作空间详情,通过 repo 和 sn 获取",
34405
- middleware: ["admin-auth"],
34405
+ middleware: ["auth-admin"],
34406
34406
  metadata: {
34407
34407
  tags: ["opencode"],
34408
34408
  ...createSkill({
@@ -34431,7 +34431,7 @@ app.route({
34431
34431
  path: "cnb",
34432
34432
  key: "delete-workspace",
34433
34433
  description: "删除工作空间,通过 pipelineId 或 sn",
34434
- middleware: ["admin-auth"],
34434
+ middleware: ["auth-admin"],
34435
34435
  metadata: {
34436
34436
  tags: ["opencode"],
34437
34437
  ...createSkill({
@@ -34468,7 +34468,7 @@ app.route({
34468
34468
  path: "cnb",
34469
34469
  key: "stop-workspace",
34470
34470
  description: "停止工作空间,通过 pipelineId 或 sn",
34471
- middleware: ["admin-auth"],
34471
+ middleware: ["auth-admin"],
34472
34472
  metadata: {
34473
34473
  tags: ["opencode"],
34474
34474
  ...createSkill({
@@ -34496,7 +34496,7 @@ app.route({
34496
34496
  path: "call",
34497
34497
  key: "",
34498
34498
  description: "调用",
34499
- middleware: ["admin-auth"],
34499
+ middleware: ["auth-admin"],
34500
34500
  metadata: {
34501
34501
  tags: ["opencode"],
34502
34502
  ...createSkill({
@@ -34545,7 +34545,7 @@ app.route({
34545
34545
  path: "cnb",
34546
34546
  key: "get-cnb-port-uri",
34547
34547
  description: "获取当前cnb工作空间的port代理uri",
34548
- middleware: ["admin-auth"],
34548
+ middleware: ["auth-admin"],
34549
34549
  metadata: {
34550
34550
  tags: ["opencode"],
34551
34551
  ...createSkill({
@@ -34553,12 +34553,12 @@ app.route({
34553
34553
  title: "获取当前cnb工作空间的port代理uri",
34554
34554
  summary: "获取当前cnb工作空间的port代理uri,用于端口转发",
34555
34555
  args: {
34556
- port: tool.schema.number().optional().describe("端口号,默认为4096")
34556
+ port: tool.schema.number().optional().describe("端口号,默认为51515")
34557
34557
  }
34558
34558
  })
34559
34559
  }
34560
34560
  }).define(async (ctx) => {
34561
- const port = ctx.query?.port || 4096;
34561
+ const port = ctx.query?.port || 51515;
34562
34562
  const uri = CNB_ENV?.CNB_VSCODE_PROXY_URI || "";
34563
34563
  const finalUri = uri.replace("{{port}}", port.toString());
34564
34564
  let content = `
@@ -34570,7 +34570,7 @@ app.route({
34570
34570
  path: "cnb",
34571
34571
  key: "get-cnb-vscode-uri",
34572
34572
  description: "获取当前cnb工作空间的vscode代理uri, 包括多种访问方式, 如web、vscode、codebuddy、cursor、ssh",
34573
- middleware: ["admin-auth"],
34573
+ middleware: ["auth-admin"],
34574
34574
  metadata: {
34575
34575
  tags: ["opencode"],
34576
34576
  ...createSkill({
@@ -34631,7 +34631,7 @@ app.route({
34631
34631
  path: "cnb",
34632
34632
  key: "set-cnb-cookie",
34633
34633
  description: "设置当前cnb工作空间的cookie环境变量",
34634
- middleware: ["admin-auth"],
34634
+ middleware: ["auth-admin"],
34635
34635
  metadata: {
34636
34636
  tags: ["opencode"],
34637
34637
  ...createSkill({
@@ -34656,7 +34656,7 @@ app.route({
34656
34656
  path: "cnb",
34657
34657
  key: "get-cnb-cookie",
34658
34658
  description: "获取当前cnb工作空间的cookie环境变量",
34659
- middleware: ["admin-auth"],
34659
+ middleware: ["auth-admin"],
34660
34660
  metadata: {
34661
34661
  tags: ["opencode"],
34662
34662
  ...createSkill({
@@ -54525,7 +54525,7 @@ app.route({
54525
54525
  path: "cnb",
54526
54526
  key: "cnb-ai-chat",
54527
54527
  description: "调用cnb的知识库ai对话功能进行聊天",
54528
- middleware: ["admin-auth"],
54528
+ middleware: ["auth-admin"],
54529
54529
  metadata: {
54530
54530
  tags: ["opencode"],
54531
54531
  ...createSkill({
@@ -54627,7 +54627,7 @@ app.route({
54627
54627
  path: "cnb",
54628
54628
  key: "cnb-rag-query",
54629
54629
  description: "调用cnb的知识库RAG查询功能进行问答",
54630
- middleware: ["admin-auth"],
54630
+ middleware: ["auth-admin"],
54631
54631
  metadata: {
54632
54632
  tags: ["opencode"],
54633
54633
  ...createSkill({
@@ -54646,7 +54646,7 @@ app.route({
54646
54646
  ctx.body = { content: "请提供有效的消息内容" };
54647
54647
  return;
54648
54648
  }
54649
- let repo2 = ctx.query?.repo;
54649
+ let repo2 = ctx.query?.repo || useKey("CNB_REPO_SLUG_LOWERCASE");
54650
54650
  if (!repo2) {
54651
54651
  const res = await cnb.repo.getRepoList({ flags: "KnowledgeBase" });
54652
54652
  if (res.code === 200 && res.data.length > 0) {
@@ -54690,7 +54690,7 @@ app.route({
54690
54690
  path: "cnb",
54691
54691
  key: "list-issues",
54692
54692
  description: "查询 Issue 列表, 参数 repo, state, keyword, labels, page, page_size 等",
54693
- middleware: ["admin-auth"],
54693
+ middleware: ["auth-admin"],
54694
54694
  metadata: {
54695
54695
  tags: ["opencode"],
54696
54696
  ...createSkill({
@@ -54709,7 +54709,7 @@ app.route({
54709
54709
  })
54710
54710
  }
54711
54711
  }).define(async (ctx) => {
54712
- const repo2 = ctx.query?.repo;
54712
+ const repo2 = ctx.query?.repo || useKey("CNB_REPO_SLUG_LOWERCASE");
54713
54713
  const state = ctx.query?.state;
54714
54714
  const keyword = ctx.query?.keyword;
54715
54715
  const labels = ctx.query?.labels;
@@ -54741,7 +54741,7 @@ app.route({
54741
54741
  path: "cnb",
54742
54742
  key: "create-issue",
54743
54743
  description: "创建 Issue, 参数 repo, title, body, assignees, labels, priority",
54744
- middleware: ["admin-auth"],
54744
+ middleware: ["auth-admin"],
54745
54745
  metadata: {
54746
54746
  tags: ["opencode"],
54747
54747
  ...createSkill({
@@ -54781,7 +54781,7 @@ app.route({
54781
54781
  path: "cnb",
54782
54782
  key: "complete-issue",
54783
54783
  description: "完成 Issue, 参数 repo, issueNumber",
54784
- middleware: ["admin-auth"],
54784
+ middleware: ["auth-admin"],
54785
54785
  metadata: {
54786
54786
  tags: ["opencode"],
54787
54787
  ...createSkill({
@@ -55573,8 +55573,8 @@ app.route({
55573
55573
  }
55574
55574
  }).addTo(app, { overwrite: false });
55575
55575
  app.route({
55576
- id: "admin-auth",
55577
- path: "admin-auth",
55576
+ id: "auth-admin",
55577
+ path: "auth-admin",
55578
55578
  middleware: ["auth"]
55579
55579
  }).define(async (ctx) => {
55580
55580
  if (checkAppId(ctx, app.appId)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevisual/cnb",
3
- "version": "0.0.34",
3
+ "version": "0.0.35",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {