@kevisual/cnb 0.0.12 → 0.0.13

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/dist/opencode.js CHANGED
@@ -1,4 +1,20 @@
1
+ var __create = Object.create;
2
+ var __getProtoOf = Object.getPrototypeOf;
1
3
  var __defProp = Object.defineProperty;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __toESM = (mod, isNodeMode, target) => {
7
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
8
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
9
+ for (let key of __getOwnPropNames(mod))
10
+ if (!__hasOwnProp.call(to, key))
11
+ __defProp(to, key, {
12
+ get: () => mod[key],
13
+ enumerable: true
14
+ });
15
+ return to;
16
+ };
17
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
2
18
  var __export = (target, all) => {
3
19
  for (var name in all)
4
20
  __defProp(target, name, {
@@ -9,6 +25,297 @@ var __export = (target, all) => {
9
25
  });
10
26
  };
11
27
 
28
+ // node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/dayjs.min.js
29
+ var require_dayjs_min = __commonJS((exports, module) => {
30
+ (function(t, e) {
31
+ typeof exports == "object" && typeof module != "undefined" ? module.exports = e() : typeof define == "function" && define.amd ? define(e) : (t = typeof globalThis != "undefined" ? globalThis : t || self).dayjs = e();
32
+ })(exports, function() {
33
+ var t = 1000, e = 60000, n = 3600000, r = "millisecond", i = "second", s = "minute", u = "hour", a = "day", o = "week", c = "month", f = "quarter", h = "year", d = "date", l = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(t2) {
34
+ var e2 = ["th", "st", "nd", "rd"], n2 = t2 % 100;
35
+ return "[" + t2 + (e2[(n2 - 20) % 10] || e2[n2] || e2[0]) + "]";
36
+ } }, m = function(t2, e2, n2) {
37
+ var r2 = String(t2);
38
+ return !r2 || r2.length >= e2 ? t2 : "" + Array(e2 + 1 - r2.length).join(n2) + t2;
39
+ }, v = { s: m, z: function(t2) {
40
+ var e2 = -t2.utcOffset(), n2 = Math.abs(e2), r2 = Math.floor(n2 / 60), i2 = n2 % 60;
41
+ return (e2 <= 0 ? "+" : "-") + m(r2, 2, "0") + ":" + m(i2, 2, "0");
42
+ }, m: function t2(e2, n2) {
43
+ if (e2.date() < n2.date())
44
+ return -t2(n2, e2);
45
+ var r2 = 12 * (n2.year() - e2.year()) + (n2.month() - e2.month()), i2 = e2.clone().add(r2, c), s2 = n2 - i2 < 0, u2 = e2.clone().add(r2 + (s2 ? -1 : 1), c);
46
+ return +(-(r2 + (n2 - i2) / (s2 ? i2 - u2 : u2 - i2)) || 0);
47
+ }, a: function(t2) {
48
+ return t2 < 0 ? Math.ceil(t2) || 0 : Math.floor(t2);
49
+ }, p: function(t2) {
50
+ return { M: c, y: h, w: o, d: a, D: d, h: u, m: s, s: i, ms: r, Q: f }[t2] || String(t2 || "").toLowerCase().replace(/s$/, "");
51
+ }, u: function(t2) {
52
+ return t2 === undefined;
53
+ } }, g = "en", D = {};
54
+ D[g] = M;
55
+ var p = "$isDayjsObject", S = function(t2) {
56
+ return t2 instanceof _ || !(!t2 || !t2[p]);
57
+ }, w = function t2(e2, n2, r2) {
58
+ var i2;
59
+ if (!e2)
60
+ return g;
61
+ if (typeof e2 == "string") {
62
+ var s2 = e2.toLowerCase();
63
+ D[s2] && (i2 = s2), n2 && (D[s2] = n2, i2 = s2);
64
+ var u2 = e2.split("-");
65
+ if (!i2 && u2.length > 1)
66
+ return t2(u2[0]);
67
+ } else {
68
+ var a2 = e2.name;
69
+ D[a2] = e2, i2 = a2;
70
+ }
71
+ return !r2 && i2 && (g = i2), i2 || !r2 && g;
72
+ }, O = function(t2, e2) {
73
+ if (S(t2))
74
+ return t2.clone();
75
+ var n2 = typeof e2 == "object" ? e2 : {};
76
+ return n2.date = t2, n2.args = arguments, new _(n2);
77
+ }, b = v;
78
+ b.l = w, b.i = S, b.w = function(t2, e2) {
79
+ return O(t2, { locale: e2.$L, utc: e2.$u, x: e2.$x, $offset: e2.$offset });
80
+ };
81
+ var _ = function() {
82
+ function M2(t2) {
83
+ this.$L = w(t2.locale, null, true), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p] = true;
84
+ }
85
+ var m2 = M2.prototype;
86
+ return m2.parse = function(t2) {
87
+ this.$d = function(t3) {
88
+ var { date: e2, utc: n2 } = t3;
89
+ if (e2 === null)
90
+ return new Date(NaN);
91
+ if (b.u(e2))
92
+ return new Date;
93
+ if (e2 instanceof Date)
94
+ return new Date(e2);
95
+ if (typeof e2 == "string" && !/Z$/i.test(e2)) {
96
+ var r2 = e2.match($);
97
+ if (r2) {
98
+ var i2 = r2[2] - 1 || 0, s2 = (r2[7] || "0").substring(0, 3);
99
+ return n2 ? new Date(Date.UTC(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2)) : new Date(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2);
100
+ }
101
+ }
102
+ return new Date(e2);
103
+ }(t2), this.init();
104
+ }, m2.init = function() {
105
+ var t2 = this.$d;
106
+ this.$y = t2.getFullYear(), this.$M = t2.getMonth(), this.$D = t2.getDate(), this.$W = t2.getDay(), this.$H = t2.getHours(), this.$m = t2.getMinutes(), this.$s = t2.getSeconds(), this.$ms = t2.getMilliseconds();
107
+ }, m2.$utils = function() {
108
+ return b;
109
+ }, m2.isValid = function() {
110
+ return !(this.$d.toString() === l);
111
+ }, m2.isSame = function(t2, e2) {
112
+ var n2 = O(t2);
113
+ return this.startOf(e2) <= n2 && n2 <= this.endOf(e2);
114
+ }, m2.isAfter = function(t2, e2) {
115
+ return O(t2) < this.startOf(e2);
116
+ }, m2.isBefore = function(t2, e2) {
117
+ return this.endOf(e2) < O(t2);
118
+ }, m2.$g = function(t2, e2, n2) {
119
+ return b.u(t2) ? this[e2] : this.set(n2, t2);
120
+ }, m2.unix = function() {
121
+ return Math.floor(this.valueOf() / 1000);
122
+ }, m2.valueOf = function() {
123
+ return this.$d.getTime();
124
+ }, m2.startOf = function(t2, e2) {
125
+ var n2 = this, r2 = !!b.u(e2) || e2, f2 = b.p(t2), l2 = function(t3, e3) {
126
+ var i2 = b.w(n2.$u ? Date.UTC(n2.$y, e3, t3) : new Date(n2.$y, e3, t3), n2);
127
+ return r2 ? i2 : i2.endOf(a);
128
+ }, $2 = function(t3, e3) {
129
+ return b.w(n2.toDate()[t3].apply(n2.toDate("s"), (r2 ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e3)), n2);
130
+ }, y2 = this.$W, M3 = this.$M, m3 = this.$D, v2 = "set" + (this.$u ? "UTC" : "");
131
+ switch (f2) {
132
+ case h:
133
+ return r2 ? l2(1, 0) : l2(31, 11);
134
+ case c:
135
+ return r2 ? l2(1, M3) : l2(0, M3 + 1);
136
+ case o:
137
+ var g2 = this.$locale().weekStart || 0, D2 = (y2 < g2 ? y2 + 7 : y2) - g2;
138
+ return l2(r2 ? m3 - D2 : m3 + (6 - D2), M3);
139
+ case a:
140
+ case d:
141
+ return $2(v2 + "Hours", 0);
142
+ case u:
143
+ return $2(v2 + "Minutes", 1);
144
+ case s:
145
+ return $2(v2 + "Seconds", 2);
146
+ case i:
147
+ return $2(v2 + "Milliseconds", 3);
148
+ default:
149
+ return this.clone();
150
+ }
151
+ }, m2.endOf = function(t2) {
152
+ return this.startOf(t2, false);
153
+ }, m2.$set = function(t2, e2) {
154
+ var n2, o2 = b.p(t2), f2 = "set" + (this.$u ? "UTC" : ""), l2 = (n2 = {}, n2[a] = f2 + "Date", n2[d] = f2 + "Date", n2[c] = f2 + "Month", n2[h] = f2 + "FullYear", n2[u] = f2 + "Hours", n2[s] = f2 + "Minutes", n2[i] = f2 + "Seconds", n2[r] = f2 + "Milliseconds", n2)[o2], $2 = o2 === a ? this.$D + (e2 - this.$W) : e2;
155
+ if (o2 === c || o2 === h) {
156
+ var y2 = this.clone().set(d, 1);
157
+ y2.$d[l2]($2), y2.init(), this.$d = y2.set(d, Math.min(this.$D, y2.daysInMonth())).$d;
158
+ } else
159
+ l2 && this.$d[l2]($2);
160
+ return this.init(), this;
161
+ }, m2.set = function(t2, e2) {
162
+ return this.clone().$set(t2, e2);
163
+ }, m2.get = function(t2) {
164
+ return this[b.p(t2)]();
165
+ }, m2.add = function(r2, f2) {
166
+ var d2, l2 = this;
167
+ r2 = Number(r2);
168
+ var $2 = b.p(f2), y2 = function(t2) {
169
+ var e2 = O(l2);
170
+ return b.w(e2.date(e2.date() + Math.round(t2 * r2)), l2);
171
+ };
172
+ if ($2 === c)
173
+ return this.set(c, this.$M + r2);
174
+ if ($2 === h)
175
+ return this.set(h, this.$y + r2);
176
+ if ($2 === a)
177
+ return y2(1);
178
+ if ($2 === o)
179
+ return y2(7);
180
+ var M3 = (d2 = {}, d2[s] = e, d2[u] = n, d2[i] = t, d2)[$2] || 1, m3 = this.$d.getTime() + r2 * M3;
181
+ return b.w(m3, this);
182
+ }, m2.subtract = function(t2, e2) {
183
+ return this.add(-1 * t2, e2);
184
+ }, m2.format = function(t2) {
185
+ var e2 = this, n2 = this.$locale();
186
+ if (!this.isValid())
187
+ return n2.invalidDate || l;
188
+ var r2 = t2 || "YYYY-MM-DDTHH:mm:ssZ", i2 = b.z(this), s2 = this.$H, u2 = this.$m, a2 = this.$M, o2 = n2.weekdays, c2 = n2.months, f2 = n2.meridiem, h2 = function(t3, n3, i3, s3) {
189
+ return t3 && (t3[n3] || t3(e2, r2)) || i3[n3].slice(0, s3);
190
+ }, d2 = function(t3) {
191
+ return b.s(s2 % 12 || 12, t3, "0");
192
+ }, $2 = f2 || function(t3, e3, n3) {
193
+ var r3 = t3 < 12 ? "AM" : "PM";
194
+ return n3 ? r3.toLowerCase() : r3;
195
+ };
196
+ return r2.replace(y, function(t3, r3) {
197
+ return r3 || function(t4) {
198
+ switch (t4) {
199
+ case "YY":
200
+ return String(e2.$y).slice(-2);
201
+ case "YYYY":
202
+ return b.s(e2.$y, 4, "0");
203
+ case "M":
204
+ return a2 + 1;
205
+ case "MM":
206
+ return b.s(a2 + 1, 2, "0");
207
+ case "MMM":
208
+ return h2(n2.monthsShort, a2, c2, 3);
209
+ case "MMMM":
210
+ return h2(c2, a2);
211
+ case "D":
212
+ return e2.$D;
213
+ case "DD":
214
+ return b.s(e2.$D, 2, "0");
215
+ case "d":
216
+ return String(e2.$W);
217
+ case "dd":
218
+ return h2(n2.weekdaysMin, e2.$W, o2, 2);
219
+ case "ddd":
220
+ return h2(n2.weekdaysShort, e2.$W, o2, 3);
221
+ case "dddd":
222
+ return o2[e2.$W];
223
+ case "H":
224
+ return String(s2);
225
+ case "HH":
226
+ return b.s(s2, 2, "0");
227
+ case "h":
228
+ return d2(1);
229
+ case "hh":
230
+ return d2(2);
231
+ case "a":
232
+ return $2(s2, u2, true);
233
+ case "A":
234
+ return $2(s2, u2, false);
235
+ case "m":
236
+ return String(u2);
237
+ case "mm":
238
+ return b.s(u2, 2, "0");
239
+ case "s":
240
+ return String(e2.$s);
241
+ case "ss":
242
+ return b.s(e2.$s, 2, "0");
243
+ case "SSS":
244
+ return b.s(e2.$ms, 3, "0");
245
+ case "Z":
246
+ return i2;
247
+ }
248
+ return null;
249
+ }(t3) || i2.replace(":", "");
250
+ });
251
+ }, m2.utcOffset = function() {
252
+ return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
253
+ }, m2.diff = function(r2, d2, l2) {
254
+ var $2, y2 = this, M3 = b.p(d2), m3 = O(r2), v2 = (m3.utcOffset() - this.utcOffset()) * e, g2 = this - m3, D2 = function() {
255
+ return b.m(y2, m3);
256
+ };
257
+ switch (M3) {
258
+ case h:
259
+ $2 = D2() / 12;
260
+ break;
261
+ case c:
262
+ $2 = D2();
263
+ break;
264
+ case f:
265
+ $2 = D2() / 3;
266
+ break;
267
+ case o:
268
+ $2 = (g2 - v2) / 604800000;
269
+ break;
270
+ case a:
271
+ $2 = (g2 - v2) / 86400000;
272
+ break;
273
+ case u:
274
+ $2 = g2 / n;
275
+ break;
276
+ case s:
277
+ $2 = g2 / e;
278
+ break;
279
+ case i:
280
+ $2 = g2 / t;
281
+ break;
282
+ default:
283
+ $2 = g2;
284
+ }
285
+ return l2 ? $2 : b.a($2);
286
+ }, m2.daysInMonth = function() {
287
+ return this.endOf(c).$D;
288
+ }, m2.$locale = function() {
289
+ return D[this.$L];
290
+ }, m2.locale = function(t2, e2) {
291
+ if (!t2)
292
+ return this.$L;
293
+ var n2 = this.clone(), r2 = w(t2, e2, true);
294
+ return r2 && (n2.$L = r2), n2;
295
+ }, m2.clone = function() {
296
+ return b.w(this.$d, this);
297
+ }, m2.toDate = function() {
298
+ return new Date(this.valueOf());
299
+ }, m2.toJSON = function() {
300
+ return this.isValid() ? this.toISOString() : null;
301
+ }, m2.toISOString = function() {
302
+ return this.$d.toISOString();
303
+ }, m2.toString = function() {
304
+ return this.$d.toUTCString();
305
+ }, M2;
306
+ }(), k = _.prototype;
307
+ return O.prototype = k, [["$ms", r], ["$s", i], ["$m", s], ["$H", u], ["$W", a], ["$M", c], ["$y", h], ["$D", d]].forEach(function(t2) {
308
+ k[t2[1]] = function(e2) {
309
+ return this.$g(e2, t2[0], t2[1]);
310
+ };
311
+ }), O.extend = function(t2, e2) {
312
+ return t2.$i || (t2(e2, _, O), t2.$i = true), O;
313
+ }, O.locale = w, O.isDayjs = S, O.unix = function(t2) {
314
+ return O(1000 * t2);
315
+ }, O.en = D[g], O.Ls = D, O.p = {}, O;
316
+ });
317
+ });
318
+
12
319
  // node_modules/.pnpm/@kevisual+router@0.0.64_typescript@5.9.3/node_modules/@kevisual/router/dist/router.js
13
320
  import require$$1, { webcrypto } from "node:crypto";
14
321
  import require$$2 from "node:http";
@@ -18226,25 +18533,25 @@ InitEnv.init();
18226
18533
  import { createRequire } from "node:module";
18227
18534
  import fs from "node:fs";
18228
18535
  import path from "node:path";
18229
- var __create = Object.create;
18230
- var __getProtoOf = Object.getPrototypeOf;
18536
+ var __create2 = Object.create;
18537
+ var __getProtoOf2 = Object.getPrototypeOf;
18231
18538
  var __defProp2 = Object.defineProperty;
18232
- var __getOwnPropNames = Object.getOwnPropertyNames;
18233
- var __hasOwnProp = Object.prototype.hasOwnProperty;
18234
- var __toESM = (mod, isNodeMode, target) => {
18235
- target = mod != null ? __create(__getProtoOf(mod)) : {};
18539
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
18540
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
18541
+ var __toESM2 = (mod, isNodeMode, target) => {
18542
+ target = mod != null ? __create2(__getProtoOf2(mod)) : {};
18236
18543
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target;
18237
- for (let key of __getOwnPropNames(mod))
18238
- if (!__hasOwnProp.call(to, key))
18544
+ for (let key of __getOwnPropNames2(mod))
18545
+ if (!__hasOwnProp2.call(to, key))
18239
18546
  __defProp2(to, key, {
18240
18547
  get: () => mod[key],
18241
18548
  enumerable: true
18242
18549
  });
18243
18550
  return to;
18244
18551
  };
18245
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
18552
+ var __commonJS2 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
18246
18553
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
18247
- var require_package = __commonJS((exports, module) => {
18554
+ var require_package = __commonJS2((exports, module) => {
18248
18555
  module.exports = {
18249
18556
  name: "dotenv",
18250
18557
  version: "17.2.3",
@@ -18308,7 +18615,7 @@ var require_package = __commonJS((exports, module) => {
18308
18615
  }
18309
18616
  };
18310
18617
  });
18311
- var require_main = __commonJS((exports, module) => {
18618
+ var require_main = __commonJS2((exports, module) => {
18312
18619
  var fs2 = __require("fs");
18313
18620
  var path2 = __require("path");
18314
18621
  var os = __require("os");
@@ -18635,7 +18942,7 @@ var require_main = __commonJS((exports, module) => {
18635
18942
  exports.populate = DotenvModule.populate;
18636
18943
  module.exports = DotenvModule;
18637
18944
  });
18638
- var import_dotenv = __toESM(require_main(), 1);
18945
+ var import_dotenv = __toESM2(require_main(), 1);
18639
18946
  var fileIsExist = (path2) => {
18640
18947
  try {
18641
18948
  fs.accessSync(path2, fs.constants.F_OK);
@@ -33359,7 +33666,7 @@ app.route({
33359
33666
  path: "cnb",
33360
33667
  key: "user-check",
33361
33668
  description: "检查用户登录状态,参数checkToken,default true; checkCookie, default false",
33362
- middleware: ["auth"],
33669
+ middleware: ["admin-auth"],
33363
33670
  metadata: {
33364
33671
  tags: ["opencode"],
33365
33672
  ...createSkill({
@@ -33404,7 +33711,7 @@ app.route({
33404
33711
  path: "cnb",
33405
33712
  key: "list-repos",
33406
33713
  description: "列出我的代码仓库",
33407
- middleware: ["auth"],
33714
+ middleware: ["admin-auth"],
33408
33715
  metadata: {
33409
33716
  tags: ["opencode"],
33410
33717
  ...createSkill({
@@ -33445,7 +33752,7 @@ app.route({
33445
33752
  path: "cnb",
33446
33753
  key: "create-repo",
33447
33754
  description: "创建代码仓库, 参数name, visibility, description",
33448
- middleware: ["auth"],
33755
+ middleware: ["admin-auth"],
33449
33756
  metadata: {
33450
33757
  tags: ["opencode"],
33451
33758
  ...createSkill({
@@ -33482,7 +33789,7 @@ app.route({
33482
33789
  path: "cnb",
33483
33790
  key: "create-repo-file",
33484
33791
  description: "在代码仓库中创建文件, repoName, filePath, content, encoding",
33485
- middleware: ["auth"],
33792
+ middleware: ["admin-auth"],
33486
33793
  metadata: {
33487
33794
  tags: ["opencode"],
33488
33795
  ...createSkill({
@@ -33517,7 +33824,7 @@ app.route({
33517
33824
  path: "cnb",
33518
33825
  key: "delete-repo",
33519
33826
  description: "删除代码仓库, 参数name",
33520
- middleware: ["auth"],
33827
+ middleware: ["admin-auth"],
33521
33828
  metadata: {
33522
33829
  tags: ["opencode"],
33523
33830
  ...createSkill({
@@ -33543,7 +33850,7 @@ app.route({
33543
33850
  path: "cnb",
33544
33851
  key: "clean-closed-workspace",
33545
33852
  description: "批量删除已停止的cnb工作空间",
33546
- middleware: ["auth"],
33853
+ middleware: ["admin-auth"],
33547
33854
  metadata: {
33548
33855
  tags: ["opencode"],
33549
33856
  ...createSkill({
@@ -33571,6 +33878,39 @@ app.route({
33571
33878
  ctx.forward({ code: 200, message: "已关闭的工作空间删除完成", data: results });
33572
33879
  }).addTo(app);
33573
33880
 
33881
+ // node_modules/.pnpm/nanoid@5.1.6/node_modules/nanoid/index.js
33882
+ import { webcrypto as crypto2 } from "node:crypto";
33883
+
33884
+ // node_modules/.pnpm/nanoid@5.1.6/node_modules/nanoid/url-alphabet/index.js
33885
+ var urlAlphabet2 = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
33886
+
33887
+ // node_modules/.pnpm/nanoid@5.1.6/node_modules/nanoid/index.js
33888
+ var POOL_SIZE_MULTIPLIER2 = 128;
33889
+ var pool2;
33890
+ var poolOffset2;
33891
+ function fillPool2(bytes) {
33892
+ if (!pool2 || pool2.length < bytes) {
33893
+ pool2 = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER2);
33894
+ crypto2.getRandomValues(pool2);
33895
+ poolOffset2 = 0;
33896
+ } else if (poolOffset2 + bytes > pool2.length) {
33897
+ crypto2.getRandomValues(pool2);
33898
+ poolOffset2 = 0;
33899
+ }
33900
+ poolOffset2 += bytes;
33901
+ }
33902
+ function nanoid4(size = 21) {
33903
+ fillPool2(size |= 0);
33904
+ let id2 = "";
33905
+ for (let i = poolOffset2 - size;i < poolOffset2; i++) {
33906
+ id2 += urlAlphabet2[pool2[i] & 63];
33907
+ }
33908
+ return id2;
33909
+ }
33910
+
33911
+ // agent/routes/workspace/keep.ts
33912
+ var import_dayjs = __toESM(require_dayjs_min(), 1);
33913
+
33574
33914
  // src/workspace/keep-live.ts
33575
33915
  import WebSocket from "ws";
33576
33916
 
@@ -33724,7 +34064,7 @@ app.route({
33724
34064
  path: "cnb",
33725
34065
  key: "keep-workspace-alive",
33726
34066
  description: "保持工作空间存活技能,参数wsUrl:工作空间访问URL,cookie:访问工作空间所需的cookie",
33727
- middleware: ["auth"],
34067
+ middleware: ["admin-auth"],
33728
34068
  metadata: {
33729
34069
  tags: [],
33730
34070
  ...{
@@ -33743,9 +34083,9 @@ app.route({
33743
34083
  if (!cookie) {
33744
34084
  ctx.throw(400, "缺少访问工作空间所需的cookie参数");
33745
34085
  }
33746
- const existing = keepAliveMap.get(wsUrl);
34086
+ const existing = Array.from(keepAliveMap.values()).find((info) => info.id && info.KeepAlive?.wsUrl === wsUrl);
33747
34087
  if (existing) {
33748
- ctx.body = { message: `工作空间 ${wsUrl} 的保持存活任务已在运行中` };
34088
+ ctx.body = { message: `工作空间 ${wsUrl} 的保持存活任务已在运行中`, id: existing.id };
33749
34089
  return;
33750
34090
  }
33751
34091
  console.log(`启动保持工作空间 ${wsUrl} 存活的任务`);
@@ -33756,72 +34096,154 @@ app.route({
33756
34096
  console.log(`工作空间 ${wsUrl} 保持存活任务已连接`);
33757
34097
  },
33758
34098
  onMessage: (data) => {
33759
- const aliveInfo = keepAliveMap.get(wsUrl);
33760
- if (aliveInfo) {
33761
- aliveInfo.updatedTime = Date.now();
34099
+ for (const info of keepAliveMap.values()) {
34100
+ if (info.KeepAlive?.wsUrl === wsUrl) {
34101
+ info.updatedTime = Date.now();
34102
+ break;
34103
+ }
33762
34104
  }
33763
34105
  },
33764
34106
  debug: true,
33765
34107
  onExit: (code) => {
33766
34108
  console.log(`工作空间 ${wsUrl} 保持存活任务已退出,退出码: ${code}`);
33767
- keepAliveMap.delete(wsUrl);
34109
+ for (const [id3, info] of keepAliveMap.entries()) {
34110
+ if (info.KeepAlive?.wsUrl === wsUrl) {
34111
+ keepAliveMap.delete(id3);
34112
+ break;
34113
+ }
34114
+ }
33768
34115
  }
33769
34116
  });
33770
- keepAliveMap.set(wsUrl, { startTime: Date.now(), updatedTime: Date.now(), KeepAlive: keep });
33771
- ctx.body = { message: `已启动保持工作空间 ${wsUrl} 存活的任务` };
34117
+ const id2 = nanoid4(6).toLowerCase();
34118
+ keepAliveMap.set(id2, { startTime: Date.now(), updatedTime: Date.now(), KeepAlive: keep, id: id2 });
34119
+ ctx.body = { content: `已启动保持工作空间 ${wsUrl} 存活的任务`, id: id2 };
33772
34120
  }).addTo(app);
33773
34121
  app.route({
33774
34122
  path: "cnb",
33775
34123
  key: "list-keep-alive-tasks",
33776
34124
  description: "获取保持工作空间存活任务列表技能",
33777
- middleware: ["auth"],
34125
+ middleware: ["admin-auth"],
33778
34126
  metadata: {
33779
34127
  tags: []
33780
34128
  }
33781
34129
  }).define(async (ctx) => {
33782
- const list = Array.from(keepAliveMap.entries()).map(([wsUrl, info]) => ({
33783
- wsUrl,
33784
- startTime: info.startTime,
33785
- updatedTime: info.updatedTime
33786
- }));
34130
+ const list = Array.from(keepAliveMap.entries()).map(([id2, info]) => {
34131
+ const now = Date.now();
34132
+ const duration4 = Math.floor((now - info.startTime) / 60000);
34133
+ return {
34134
+ id: id2,
34135
+ wsUrl: info.KeepAlive?.wsUrl,
34136
+ startTime: info.startTime,
34137
+ startTimeStr: import_dayjs.default(info.startTime).format("YYYY-MM-DD HH:mm"),
34138
+ updatedTime: info.updatedTime,
34139
+ updatedTimeStr: import_dayjs.default(info.updatedTime).format("YYYY-MM-DD HH:mm"),
34140
+ duration: duration4
34141
+ };
34142
+ });
33787
34143
  ctx.body = { list };
33788
34144
  }).addTo(app);
33789
34145
  app.route({
33790
34146
  path: "cnb",
33791
34147
  key: "stop-keep-workspace-alive",
33792
- description: "停止保持工作空间存活技能, 参数wsUrl:工作空间访问URL",
33793
- middleware: ["auth"],
34148
+ description: "停止保持工作空间存活技能, 参数wsUrl:工作空间访问URL或者id",
34149
+ middleware: ["admin-auth"],
33794
34150
  metadata: {
33795
34151
  tags: [],
33796
34152
  ...{
33797
34153
  args: {
33798
- wsUrl: tool.schema.string().describe("工作空间的访问URL")
34154
+ wsUrl: tool.schema.string().optional().describe("工作空间的访问URL"),
34155
+ id: tool.schema.string().optional().describe("保持存活任务的唯一标识符")
33799
34156
  }
33800
34157
  }
33801
34158
  }
33802
34159
  }).define(async (ctx) => {
33803
34160
  const wsUrl = ctx.query?.wsUrl;
33804
- if (!wsUrl) {
33805
- ctx.throw(400, "缺少工作空间访问URL参数");
34161
+ const id2 = ctx.query?.id;
34162
+ if (!wsUrl && !id2) {
34163
+ ctx.throw(400, "缺少工作空间访问URL参数或唯一标识符");
34164
+ }
34165
+ let targetId;
34166
+ let wsUrlFound;
34167
+ if (id2) {
34168
+ const info = keepAliveMap.get(id2);
34169
+ if (info) {
34170
+ targetId = id2;
34171
+ wsUrlFound = info.KeepAlive?.wsUrl;
34172
+ }
34173
+ } else if (wsUrl) {
34174
+ for (const [key, info] of keepAliveMap.entries()) {
34175
+ if (info.KeepAlive?.wsUrl === wsUrl) {
34176
+ targetId = key;
34177
+ wsUrlFound = wsUrl;
34178
+ break;
34179
+ }
34180
+ }
33806
34181
  }
33807
- const keepAlive = keepAliveMap.get(wsUrl);
33808
- if (keepAlive) {
34182
+ if (targetId) {
34183
+ const keepAlive = keepAliveMap.get(targetId);
33809
34184
  const endTime = Date.now();
33810
34185
  const duration4 = endTime - keepAlive.startTime;
33811
34186
  keepAlive?.KeepAlive?.disconnect();
33812
- keepAliveMap.delete(wsUrl);
33813
- ctx.body = { message: `已停止保持工作空间 ${wsUrl} 存活的任务,持续时间: ${duration4}ms` };
34187
+ keepAliveMap.delete(targetId);
34188
+ ctx.body = { content: `已停止保持工作空间 ${wsUrlFound} 存活的任务,持续时间: ${duration4}ms`, id: targetId };
33814
34189
  } else {
33815
- ctx.body = { message: `没有找到工作空间 ${wsUrl} 的保持存活任务` };
34190
+ ctx.body = { content: `没有找到对应的工作空间保持存活任务` };
34191
+ }
34192
+ }).addTo(app);
34193
+ app.route({
34194
+ path: "cnb",
34195
+ key: "reset-keep-workspace-alive",
34196
+ description: "对存活的工作空间,startTime进行重置",
34197
+ middleware: ["admin-auth"],
34198
+ metadata: {
34199
+ tags: []
34200
+ }
34201
+ }).define(async (ctx) => {
34202
+ const now = Date.now();
34203
+ for (const info of keepAliveMap.values()) {
34204
+ info.startTime = now;
33816
34205
  }
34206
+ ctx.body = { content: `已重置所有存活工作空间的开始时间` };
34207
+ }).addTo(app);
34208
+ app.route({
34209
+ path: "cnb",
34210
+ key: "clear-keep-workspace-alive",
34211
+ description: "对存活的工作空间,超过5小时的进行清理",
34212
+ middleware: ["admin-auth"],
34213
+ metadata: {
34214
+ tags: []
34215
+ }
34216
+ }).define(async (ctx) => {
34217
+ const res = clearKeepAlive();
34218
+ ctx.body = {
34219
+ content: `已清理所有存活工作空间中超过5小时的任务` + (res.length ? `,清理项:${res.map((i) => i.wsUrl).join(", ")}` : ""),
34220
+ list: res
34221
+ };
33817
34222
  }).addTo(app);
34223
+ var clearKeepAlive = () => {
34224
+ const now = Date.now();
34225
+ let clearedArr = [];
34226
+ for (const [id2, info] of keepAliveMap.entries()) {
34227
+ if (now - info.startTime > FIVE_HOURS) {
34228
+ console.log(`工作空间 ${info.KeepAlive?.wsUrl} 超过5小时,自动停止`);
34229
+ info.KeepAlive?.disconnect?.();
34230
+ keepAliveMap.delete(id2);
34231
+ clearedArr.push({ id: id2, wsUrl: info.KeepAlive?.wsUrl });
34232
+ }
34233
+ }
34234
+ return clearedArr;
34235
+ };
34236
+ var FIVE_HOURS = 5 * 60 * 60 * 1000;
34237
+ setInterval(() => {
34238
+ clearKeepAlive();
34239
+ }, FIVE_HOURS);
33818
34240
 
33819
34241
  // agent/routes/workspace/index.ts
33820
34242
  app.route({
33821
34243
  path: "cnb",
33822
34244
  key: "start-workspace",
33823
34245
  description: "启动开发工作空间, 参数 repo",
33824
- middleware: ["auth"],
34246
+ middleware: ["admin-auth"],
33825
34247
  metadata: {
33826
34248
  tags: ["opencode"],
33827
34249
  ...createSkill({
@@ -33852,7 +34274,7 @@ app.route({
33852
34274
  path: "cnb",
33853
34275
  key: "list-workspace",
33854
34276
  description: "获取cnb开发工作空间列表,可选参数 status=running 获取运行中的环境",
33855
- middleware: ["auth"],
34277
+ middleware: ["admin-auth"],
33856
34278
  metadata: {
33857
34279
  tags: ["opencode"],
33858
34280
  ...createSkill({
@@ -33881,7 +34303,7 @@ app.route({
33881
34303
  path: "cnb",
33882
34304
  key: "get-workspace",
33883
34305
  description: "获取工作空间详情,通过 repo 和 sn 获取",
33884
- middleware: ["auth"],
34306
+ middleware: ["admin-auth"],
33885
34307
  metadata: {
33886
34308
  tags: ["opencode"],
33887
34309
  ...createSkill({
@@ -33910,7 +34332,7 @@ app.route({
33910
34332
  path: "cnb",
33911
34333
  key: "delete-workspace",
33912
34334
  description: "删除工作空间,通过 pipelineId 或 sn",
33913
- middleware: ["auth"],
34335
+ middleware: ["admin-auth"],
33914
34336
  metadata: {
33915
34337
  tags: ["opencode"],
33916
34338
  ...createSkill({
@@ -33947,7 +34369,7 @@ app.route({
33947
34369
  path: "cnb",
33948
34370
  key: "stop-workspace",
33949
34371
  description: "停止工作空间,通过 pipelineId 或 sn",
33950
- middleware: ["auth"],
34372
+ middleware: ["admin-auth"],
33951
34373
  metadata: {
33952
34374
  tags: ["opencode"],
33953
34375
  ...createSkill({
@@ -33971,33 +34393,35 @@ app.route({
33971
34393
  }).addTo(app);
33972
34394
 
33973
34395
  // agent/routes/call/index.ts
33974
- app.route({
33975
- path: "call",
33976
- key: "",
33977
- description: "调用",
33978
- middleware: ["auth"],
33979
- metadata: {
33980
- tags: ["opencode"],
33981
- ...createSkill({
33982
- skill: "call-app",
33983
- title: "调用app应用",
33984
- summary: "调用router的应用, 参数path, key, payload",
33985
- args: {
33986
- path: tool2.schema.string().describe("应用路径,例如 cnb"),
33987
- key: tool2.schema.string().optional().describe("应用key,例如 list-repos"),
33988
- payload: tool2.schema.object({}).optional().describe("调用参数")
33989
- }
33990
- })
33991
- }
33992
- }).define(async (ctx) => {
33993
- const { path: path2, key } = ctx.query;
33994
- console.log("call app", ctx.query);
33995
- if (!path2) {
33996
- ctx.throw("路径path不能为空");
33997
- }
33998
- const res = await ctx.run({ path: path2, key, payload: ctx.query.payload || {} });
33999
- ctx.forward(res);
34000
- }).addTo(app);
34396
+ if (!app.hasRoute("call")) {
34397
+ app.route({
34398
+ path: "call",
34399
+ key: "",
34400
+ description: "调用",
34401
+ middleware: ["admin-auth"],
34402
+ metadata: {
34403
+ tags: ["opencode"],
34404
+ ...createSkill({
34405
+ skill: "call-app",
34406
+ title: "调用app应用",
34407
+ summary: "调用router的应用, 参数path, key, payload",
34408
+ args: {
34409
+ path: tool2.schema.string().describe("应用路径,例如 cnb"),
34410
+ key: tool2.schema.string().optional().describe("应用key,例如 list-repos"),
34411
+ payload: tool2.schema.object({}).optional().describe("调用参数")
34412
+ }
34413
+ })
34414
+ }
34415
+ }).define(async (ctx) => {
34416
+ const { path: path2, key } = ctx.query;
34417
+ console.log("call app", ctx.query);
34418
+ if (!path2) {
34419
+ ctx.throw("路径path不能为空");
34420
+ }
34421
+ const res = await ctx.run({ path: path2, key, payload: ctx.query.payload || {} });
34422
+ ctx.forward(res);
34423
+ }).addTo(app);
34424
+ }
34001
34425
 
34002
34426
  // src/common/cnb-env.ts
34003
34427
  var CNB_ENV = {
@@ -34024,7 +34448,7 @@ app.route({
34024
34448
  path: "cnb",
34025
34449
  key: "get-cnb-port-uri",
34026
34450
  description: "获取当前cnb工作空间的port代理uri",
34027
- middleware: ["auth"],
34451
+ middleware: ["admin-auth"],
34028
34452
  metadata: {
34029
34453
  tags: ["opencode"],
34030
34454
  ...createSkill({
@@ -34049,7 +34473,7 @@ app.route({
34049
34473
  path: "cnb",
34050
34474
  key: "get-cnb-vscode-uri",
34051
34475
  description: "获取当前cnb工作空间的vscode代理uri, 包括多种访问方式, 如web、vscode、codebuddy、cursor、ssh",
34052
- middleware: ["auth"],
34476
+ middleware: ["admin-auth"],
34053
34477
  metadata: {
34054
34478
  tags: ["opencode"],
34055
34479
  ...createSkill({
@@ -34110,7 +34534,7 @@ app.route({
34110
34534
  path: "cnb",
34111
34535
  key: "set-cnb-cookie",
34112
34536
  description: "设置当前cnb工作空间的cookie环境变量",
34113
- middleware: ["auth"],
34537
+ middleware: ["admin-auth"],
34114
34538
  metadata: {
34115
34539
  tags: ["opencode"],
34116
34540
  ...createSkill({
@@ -34135,7 +34559,7 @@ app.route({
34135
34559
  path: "cnb",
34136
34560
  key: "get-cnb-cookie",
34137
34561
  description: "获取当前cnb工作空间的cookie环境变量",
34138
- middleware: ["auth"],
34562
+ middleware: ["admin-auth"],
34139
34563
  metadata: {
34140
34564
  tags: ["opencode"],
34141
34565
  ...createSkill({
@@ -34150,17 +34574,17 @@ app.route({
34150
34574
  }).addTo(app);
34151
34575
 
34152
34576
  // node_modules/.pnpm/@kevisual+ai@0.0.24/node_modules/@kevisual/ai/dist/ai-provider-browser.js
34153
- var __create2 = Object.create;
34154
- var __getProtoOf2 = Object.getPrototypeOf;
34577
+ var __create3 = Object.create;
34578
+ var __getProtoOf3 = Object.getPrototypeOf;
34155
34579
  var __defProp3 = Object.defineProperty;
34156
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
34580
+ var __getOwnPropNames3 = Object.getOwnPropertyNames;
34157
34581
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
34158
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
34159
- var __toESM2 = (mod, isNodeMode, target) => {
34160
- target = mod != null ? __create2(__getProtoOf2(mod)) : {};
34582
+ var __hasOwnProp3 = Object.prototype.hasOwnProperty;
34583
+ var __toESM3 = (mod, isNodeMode, target) => {
34584
+ target = mod != null ? __create3(__getProtoOf3(mod)) : {};
34161
34585
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp3(target, "default", { value: mod, enumerable: true }) : target;
34162
- for (let key of __getOwnPropNames2(mod))
34163
- if (!__hasOwnProp2.call(to, key))
34586
+ for (let key of __getOwnPropNames3(mod))
34587
+ if (!__hasOwnProp3.call(to, key))
34164
34588
  __defProp3(to, key, {
34165
34589
  get: () => mod[key],
34166
34590
  enumerable: true
@@ -34174,14 +34598,14 @@ var __toCommonJS = (from) => {
34174
34598
  return entry;
34175
34599
  entry = __defProp3({}, "__esModule", { value: true });
34176
34600
  if (from && typeof from === "object" || typeof from === "function")
34177
- __getOwnPropNames2(from).map((key) => !__hasOwnProp2.call(entry, key) && __defProp3(entry, key, {
34601
+ __getOwnPropNames3(from).map((key) => !__hasOwnProp3.call(entry, key) && __defProp3(entry, key, {
34178
34602
  get: () => from[key],
34179
34603
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
34180
34604
  }));
34181
34605
  __moduleCache.set(from, entry);
34182
34606
  return entry;
34183
34607
  };
34184
- var __commonJS2 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
34608
+ var __commonJS3 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
34185
34609
  var __export2 = (target, all) => {
34186
34610
  for (var name in all)
34187
34611
  __defProp3(target, name, {
@@ -36351,7 +36775,7 @@ var init_events = __esm(() => {
36351
36775
  Object.assign(EventEmitter4, { once: once2, getEventListeners, getMaxListeners: getMaxListeners2, setMaxListeners: setMaxListeners2, EventEmitter: EventEmitter4, usingDomains: false, captureRejectionSymbol, errorMonitor: kErrorMonitor, addAbortListener, init: EventEmitter4, listenerCount: listenerCount2 });
36352
36776
  events_default = EventEmitter4;
36353
36777
  });
36354
- var require_stream = __commonJS2((exports, module) => {
36778
+ var require_stream = __commonJS3((exports, module) => {
36355
36779
  var __commonJS22 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
36356
36780
  var require_primordials = __commonJS22((exports2, module2) => {
36357
36781
 
@@ -41412,27 +41836,27 @@ var init_crypto = __esm(() => {
41412
41836
  exports.pbkdf2Sync = nativePBKDF2Sync, exports.pbkdf2 = nativePBKDF2;
41413
41837
  });
41414
41838
  require_browserify_cipher = __commonJS22((exports) => {
41415
- var crypto2 = (init_crypto(), __toCommonJS(exports_crypto));
41416
- exports.createCipher = exports.Cipher = crypto2.createCipher;
41417
- exports.createCipheriv = exports.Cipheriv = crypto2.createCipheriv;
41418
- exports.createDecipher = exports.Decipher = crypto2.createDecipher;
41419
- exports.createDecipheriv = exports.Decipheriv = crypto2.createDecipheriv;
41420
- exports.listCiphers = exports.getCiphers = crypto2.getCiphers;
41839
+ var crypto22 = (init_crypto(), __toCommonJS(exports_crypto));
41840
+ exports.createCipher = exports.Cipher = crypto22.createCipher;
41841
+ exports.createCipheriv = exports.Cipheriv = crypto22.createCipheriv;
41842
+ exports.createDecipher = exports.Decipher = crypto22.createDecipher;
41843
+ exports.createDecipheriv = exports.Decipheriv = crypto22.createDecipheriv;
41844
+ exports.listCiphers = exports.getCiphers = crypto22.getCiphers;
41421
41845
  });
41422
41846
  require_diffie_hellman = __commonJS22((exports) => {
41423
- var crypto2 = (init_crypto(), __toCommonJS(exports_crypto));
41424
- exports.DiffieHellmanGroup = crypto2.DiffieHellmanGroup;
41425
- exports.createDiffieHellmanGroup = crypto2.createDiffieHellmanGroup;
41426
- exports.getDiffieHellman = crypto2.getDiffieHellman;
41427
- exports.createDiffieHellman = crypto2.createDiffieHellman;
41428
- exports.DiffieHellman = crypto2.DiffieHellman;
41847
+ var crypto22 = (init_crypto(), __toCommonJS(exports_crypto));
41848
+ exports.DiffieHellmanGroup = crypto22.DiffieHellmanGroup;
41849
+ exports.createDiffieHellmanGroup = crypto22.createDiffieHellmanGroup;
41850
+ exports.getDiffieHellman = crypto22.getDiffieHellman;
41851
+ exports.createDiffieHellman = crypto22.createDiffieHellman;
41852
+ exports.DiffieHellman = crypto22.DiffieHellman;
41429
41853
  });
41430
41854
  require_browserify_sign = __commonJS22((exports) => {
41431
- var crypto2 = (init_crypto(), __toCommonJS(exports_crypto));
41432
- exports.createSign = crypto2.createSign;
41433
- exports.Sign = crypto2.Sign;
41434
- exports.createVerify = crypto2.createVerify;
41435
- exports.Verify = crypto2.Verify;
41855
+ var crypto22 = (init_crypto(), __toCommonJS(exports_crypto));
41856
+ exports.createSign = crypto22.createSign;
41857
+ exports.Sign = crypto22.Sign;
41858
+ exports.createVerify = crypto22.createVerify;
41859
+ exports.Verify = crypto22.Verify;
41436
41860
  });
41437
41861
  require_package2 = __commonJS22((exports, module) => {
41438
41862
  module.exports = { name: "elliptic", version: "6.6.1", description: "EC cryptography", main: "lib/elliptic.js", files: ["lib"], scripts: { lint: "eslint lib test", "lint:fix": "npm run lint -- --fix", unit: "istanbul test _mocha --reporter=spec test/index.js", test: "npm run lint && npm run unit", version: "grunt dist && git add dist/" }, repository: { type: "git", url: "git@github.com:indutny/elliptic" }, keywords: ["EC", "Elliptic", "curve", "Cryptography"], author: "Fedor Indutny <fedor@indutny.com>", license: "MIT", bugs: { url: "https://github.com/indutny/elliptic/issues" }, homepage: "https://github.com/indutny/elliptic", devDependencies: { brfs: "^2.0.2", coveralls: "^3.1.0", eslint: "^7.6.0", grunt: "^1.2.1", "grunt-browserify": "^5.3.0", "grunt-cli": "^1.3.2", "grunt-contrib-connect": "^3.0.0", "grunt-contrib-copy": "^1.0.0", "grunt-contrib-uglify": "^5.0.0", "grunt-mocha-istanbul": "^5.0.2", "grunt-saucelabs": "^9.0.1", istanbul: "^0.4.5", mocha: "^8.0.1" }, dependencies: { "bn.js": "^4.11.9", brorand: "^1.1.0", "hash.js": "^1.0.0", "hmac-drbg": "^1.0.1", inherits: "^2.0.4", "minimalistic-assert": "^1.0.1", "minimalistic-crypto-utils": "^1.0.1" } };
@@ -43011,13 +43435,13 @@ var init_crypto = __esm(() => {
43011
43435
  };
43012
43436
  } else
43013
43437
  try {
43014
- if (crypto2 = (init_crypto(), __toCommonJS(exports_crypto)), typeof crypto2.randomBytes !== "function")
43438
+ if (crypto22 = (init_crypto(), __toCommonJS(exports_crypto)), typeof crypto22.randomBytes !== "function")
43015
43439
  throw Error("Not supported");
43016
43440
  Rand.prototype._rand = function(n) {
43017
- return crypto2.randomBytes(n);
43441
+ return crypto22.randomBytes(n);
43018
43442
  };
43019
43443
  } catch (e) {}
43020
- var crypto2;
43444
+ var crypto22;
43021
43445
  });
43022
43446
  require_base = __commonJS22((exports, module) => {
43023
43447
  var BN = require_bn(), utils = require_utils2(), getNAF = utils.getNAF, getJSF = utils.getJSF, assert3 = utils.assert;
@@ -49218,12 +49642,12 @@ var init_crypto = __esm(() => {
49218
49642
  module.exports = EVP_BytesToKey;
49219
49643
  });
49220
49644
  require_browserify_aes = __commonJS22((exports) => {
49221
- var crypto2 = (init_crypto(), __toCommonJS(exports_crypto));
49222
- exports.createCipher = exports.Cipher = crypto2.createCipher;
49223
- exports.createCipheriv = exports.Cipheriv = crypto2.createCipheriv;
49224
- exports.createDecipher = exports.Decipher = crypto2.createDecipher;
49225
- exports.createDecipheriv = exports.Decipheriv = crypto2.createDecipheriv;
49226
- exports.listCiphers = exports.getCiphers = crypto2.getCiphers;
49645
+ var crypto22 = (init_crypto(), __toCommonJS(exports_crypto));
49646
+ exports.createCipher = exports.Cipher = crypto22.createCipher;
49647
+ exports.createCipheriv = exports.Cipheriv = crypto22.createCipheriv;
49648
+ exports.createDecipher = exports.Decipher = crypto22.createDecipher;
49649
+ exports.createDecipheriv = exports.Decipheriv = crypto22.createDecipheriv;
49650
+ exports.listCiphers = exports.getCiphers = crypto22.getCiphers;
49227
49651
  });
49228
49652
  require_fixProc = __commonJS22((exports, module) => {
49229
49653
  var findProc = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m, startRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m, fullRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m, evp = require_evp_bytestokey(), ciphers = require_browserify_aes(), Buffer22 = require_safe_buffer().Buffer;
@@ -52338,22 +52762,22 @@ var init_crypto = __esm(() => {
52338
52762
  };
52339
52763
  });
52340
52764
  require_public_encrypt = __commonJS22((exports) => {
52341
- var crypto2 = (init_crypto(), __toCommonJS(exports_crypto));
52342
- if (typeof crypto2.publicEncrypt !== "function")
52343
- crypto2 = require_browser2();
52344
- exports.publicEncrypt = crypto2.publicEncrypt;
52345
- exports.privateDecrypt = crypto2.privateDecrypt;
52346
- if (typeof crypto2.privateEncrypt !== "function")
52765
+ var crypto22 = (init_crypto(), __toCommonJS(exports_crypto));
52766
+ if (typeof crypto22.publicEncrypt !== "function")
52767
+ crypto22 = require_browser2();
52768
+ exports.publicEncrypt = crypto22.publicEncrypt;
52769
+ exports.privateDecrypt = crypto22.privateDecrypt;
52770
+ if (typeof crypto22.privateEncrypt !== "function")
52347
52771
  exports.privateEncrypt = require_browser2().privateEncrypt;
52348
52772
  else
52349
- exports.privateEncrypt = crypto2.privateEncrypt;
52350
- if (typeof crypto2.publicDecrypt !== "function")
52773
+ exports.privateEncrypt = crypto22.privateEncrypt;
52774
+ if (typeof crypto22.publicDecrypt !== "function")
52351
52775
  exports.publicDecrypt = require_browser2().publicDecrypt;
52352
52776
  else
52353
- exports.publicDecrypt = crypto2.publicDecrypt;
52777
+ exports.publicDecrypt = crypto22.publicDecrypt;
52354
52778
  });
52355
52779
  require_browser3 = __commonJS22((exports) => {
52356
- var safeBuffer = require_safe_buffer(), randombytes = require_randombytes(), Buffer22 = safeBuffer.Buffer, kBufferMaxLength = safeBuffer.kMaxLength, crypto2 = globalThis.crypto || globalThis.msCrypto, kMaxUint32 = Math.pow(2, 32) - 1;
52780
+ var safeBuffer = require_safe_buffer(), randombytes = require_randombytes(), Buffer22 = safeBuffer.Buffer, kBufferMaxLength = safeBuffer.kMaxLength, crypto22 = globalThis.crypto || globalThis.msCrypto, kMaxUint32 = Math.pow(2, 32) - 1;
52357
52781
  function assertOffset(offset, length) {
52358
52782
  if (typeof offset !== "number" || offset !== offset)
52359
52783
  throw TypeError("offset must be a number");
@@ -52370,7 +52794,7 @@ var init_crypto = __esm(() => {
52370
52794
  if (size + offset > length || size > kBufferMaxLength)
52371
52795
  throw RangeError("buffer too small");
52372
52796
  }
52373
- crypto2 && crypto2.getRandomValues, exports.randomFill = randomFill, exports.randomFillSync = randomFillSync;
52797
+ crypto22 && crypto22.getRandomValues, exports.randomFill = randomFill, exports.randomFillSync = randomFillSync;
52374
52798
  function randomFill(buf, offset, size, cb) {
52375
52799
  if (!Buffer22.isBuffer(buf) && !(buf instanceof globalThis.Uint8Array))
52376
52800
  throw TypeError('"buf" argument must be a Buffer or Uint8Array');
@@ -52407,9 +52831,9 @@ var init_crypto = __esm(() => {
52407
52831
  }
52408
52832
  });
52409
52833
  require_randomfill = __commonJS22((exports, module) => {
52410
- var crypto2 = (init_crypto(), __toCommonJS(exports_crypto));
52411
- if (typeof crypto2.randomFill === "function" && typeof crypto2.randomFillSync === "function")
52412
- exports.randomFill = crypto2.randomFill, exports.randomFillSync = crypto2.randomFillSync;
52834
+ var crypto22 = (init_crypto(), __toCommonJS(exports_crypto));
52835
+ if (typeof crypto22.randomFill === "function" && typeof crypto22.randomFillSync === "function")
52836
+ exports.randomFill = crypto22.randomFill, exports.randomFillSync = crypto22.randomFillSync;
52413
52837
  else
52414
52838
  module.exports = require_browser3();
52415
52839
  });
@@ -52506,7 +52930,7 @@ https://github.com/browserify/crypto-browserify`);
52506
52930
  webcrypto2 = crypto;
52507
52931
  crypto_default = crypto;
52508
52932
  });
52509
- var require_core = __commonJS2((exports, module) => {
52933
+ var require_core = __commonJS3((exports, module) => {
52510
52934
  (function(root, factory) {
52511
52935
  if (typeof exports === "object") {
52512
52936
  module.exports = exports = factory();
@@ -52517,37 +52941,37 @@ var require_core = __commonJS2((exports, module) => {
52517
52941
  }
52518
52942
  })(exports, function() {
52519
52943
  var CryptoJS = CryptoJS || function(Math2, undefined2) {
52520
- var crypto2;
52944
+ var crypto22;
52521
52945
  if (typeof window !== "undefined" && window.crypto) {
52522
- crypto2 = window.crypto;
52946
+ crypto22 = window.crypto;
52523
52947
  }
52524
52948
  if (typeof self !== "undefined" && self.crypto) {
52525
- crypto2 = self.crypto;
52949
+ crypto22 = self.crypto;
52526
52950
  }
52527
52951
  if (typeof globalThis !== "undefined" && globalThis.crypto) {
52528
- crypto2 = globalThis.crypto;
52952
+ crypto22 = globalThis.crypto;
52529
52953
  }
52530
- if (!crypto2 && typeof window !== "undefined" && window.msCrypto) {
52531
- crypto2 = window.msCrypto;
52954
+ if (!crypto22 && typeof window !== "undefined" && window.msCrypto) {
52955
+ crypto22 = window.msCrypto;
52532
52956
  }
52533
- if (!crypto2 && typeof global !== "undefined" && global.crypto) {
52534
- crypto2 = global.crypto;
52957
+ if (!crypto22 && typeof global !== "undefined" && global.crypto) {
52958
+ crypto22 = global.crypto;
52535
52959
  }
52536
- if (!crypto2 && true) {
52960
+ if (!crypto22 && true) {
52537
52961
  try {
52538
- crypto2 = (init_crypto(), __toCommonJS(exports_crypto));
52962
+ crypto22 = (init_crypto(), __toCommonJS(exports_crypto));
52539
52963
  } catch (err) {}
52540
52964
  }
52541
52965
  var cryptoSecureRandomInt = function() {
52542
- if (crypto2) {
52543
- if (typeof crypto2.getRandomValues === "function") {
52966
+ if (crypto22) {
52967
+ if (typeof crypto22.getRandomValues === "function") {
52544
52968
  try {
52545
- return crypto2.getRandomValues(new Uint32Array(1))[0];
52969
+ return crypto22.getRandomValues(new Uint32Array(1))[0];
52546
52970
  } catch (err) {}
52547
52971
  }
52548
- if (typeof crypto2.randomBytes === "function") {
52972
+ if (typeof crypto22.randomBytes === "function") {
52549
52973
  try {
52550
- return crypto2.randomBytes(4).readInt32LE();
52974
+ return crypto22.randomBytes(4).readInt32LE();
52551
52975
  } catch (err) {}
52552
52976
  }
52553
52977
  }
@@ -52789,7 +53213,7 @@ var require_core = __commonJS2((exports, module) => {
52789
53213
  return CryptoJS;
52790
53214
  });
52791
53215
  });
52792
- var require_enc_base64 = __commonJS2((exports, module) => {
53216
+ var require_enc_base64 = __commonJS3((exports, module) => {
52793
53217
  (function(root, factory) {
52794
53218
  if (typeof exports === "object") {
52795
53219
  module.exports = exports = factory(require_core());
@@ -52867,7 +53291,7 @@ var require_enc_base64 = __commonJS2((exports, module) => {
52867
53291
  return CryptoJS.enc.Base64;
52868
53292
  });
52869
53293
  });
52870
- var require_md52 = __commonJS2((exports, module) => {
53294
+ var require_md52 = __commonJS3((exports, module) => {
52871
53295
  (function(root, factory) {
52872
53296
  if (typeof exports === "object") {
52873
53297
  module.exports = exports = factory(require_core());
@@ -53042,7 +53466,7 @@ var require_md52 = __commonJS2((exports, module) => {
53042
53466
  return CryptoJS.MD5;
53043
53467
  });
53044
53468
  });
53045
- var require_sha1 = __commonJS2((exports, module) => {
53469
+ var require_sha1 = __commonJS3((exports, module) => {
53046
53470
  (function(root, factory) {
53047
53471
  if (typeof exports === "object") {
53048
53472
  module.exports = exports = factory(require_core());
@@ -53129,7 +53553,7 @@ var require_sha1 = __commonJS2((exports, module) => {
53129
53553
  return CryptoJS.SHA1;
53130
53554
  });
53131
53555
  });
53132
- var require_hmac2 = __commonJS2((exports, module) => {
53556
+ var require_hmac2 = __commonJS3((exports, module) => {
53133
53557
  (function(root, factory) {
53134
53558
  if (typeof exports === "object") {
53135
53559
  module.exports = exports = factory(require_core());
@@ -53189,7 +53613,7 @@ var require_hmac2 = __commonJS2((exports, module) => {
53189
53613
  })();
53190
53614
  });
53191
53615
  });
53192
- var require_evpkdf = __commonJS2((exports, module) => {
53616
+ var require_evpkdf = __commonJS3((exports, module) => {
53193
53617
  (function(root, factory, undef) {
53194
53618
  if (typeof exports === "object") {
53195
53619
  module.exports = exports = factory(require_core(), require_sha1(), require_hmac2());
@@ -53246,7 +53670,7 @@ var require_evpkdf = __commonJS2((exports, module) => {
53246
53670
  return CryptoJS.EvpKDF;
53247
53671
  });
53248
53672
  });
53249
- var require_cipher_core = __commonJS2((exports, module) => {
53673
+ var require_cipher_core = __commonJS3((exports, module) => {
53250
53674
  (function(root, factory, undef) {
53251
53675
  if (typeof exports === "object") {
53252
53676
  module.exports = exports = factory(require_core(), require_evpkdf());
@@ -53542,7 +53966,7 @@ var require_cipher_core = __commonJS2((exports, module) => {
53542
53966
  }();
53543
53967
  });
53544
53968
  });
53545
- var require_aes = __commonJS2((exports, module) => {
53969
+ var require_aes = __commonJS3((exports, module) => {
53546
53970
  (function(root, factory, undef) {
53547
53971
  if (typeof exports === "object") {
53548
53972
  module.exports = exports = factory(require_core(), require_enc_base64(), require_md52(), require_evpkdf(), require_cipher_core());
@@ -53692,7 +54116,7 @@ var require_aes = __commonJS2((exports, module) => {
53692
54116
  return CryptoJS.AES;
53693
54117
  });
53694
54118
  });
53695
- var require_enc_utf8 = __commonJS2((exports, module) => {
54119
+ var require_enc_utf8 = __commonJS3((exports, module) => {
53696
54120
  (function(root, factory) {
53697
54121
  if (typeof exports === "object") {
53698
54122
  module.exports = exports = factory(require_core());
@@ -53995,8 +54419,8 @@ class CNBChat extends BaseChat {
53995
54419
  };
53996
54420
  }
53997
54421
  }
53998
- var import_aes = __toESM2(require_aes(), 1);
53999
- var import_enc_utf8 = __toESM2(require_enc_utf8(), 1);
54422
+ var import_aes = __toESM3(require_aes(), 1);
54423
+ var import_enc_utf8 = __toESM3(require_enc_utf8(), 1);
54000
54424
  var CryptoJS = { AES: import_aes.default, enc: { Utf8: import_enc_utf8.default } };
54001
54425
 
54002
54426
  // agent/routes/knowledge/ai.ts
@@ -54004,7 +54428,7 @@ app.route({
54004
54428
  path: "cnb",
54005
54429
  key: "cnb-ai-chat",
54006
54430
  description: "调用cnb的知识库ai对话功能进行聊天",
54007
- middleware: ["auth"],
54431
+ middleware: ["admin-auth"],
54008
54432
  metadata: {
54009
54433
  tags: ["opencode"],
54010
54434
  ...createSkill({
@@ -54106,7 +54530,7 @@ app.route({
54106
54530
  path: "cnb",
54107
54531
  key: "cnb-rag-query",
54108
54532
  description: "调用cnb的知识库RAG查询功能进行问答",
54109
- middleware: ["auth"],
54533
+ middleware: ["admin-auth"],
54110
54534
  metadata: {
54111
54535
  tags: ["opencode"],
54112
54536
  ...createSkill({
@@ -54169,7 +54593,7 @@ app.route({
54169
54593
  path: "cnb",
54170
54594
  key: "list-issues",
54171
54595
  description: "查询 Issue 列表, 参数 repo, state, keyword, labels, page, page_size 等",
54172
- middleware: ["auth"],
54596
+ middleware: ["admin-auth"],
54173
54597
  metadata: {
54174
54598
  tags: ["opencode"],
54175
54599
  ...createSkill({
@@ -54220,7 +54644,7 @@ app.route({
54220
54644
  path: "cnb",
54221
54645
  key: "create-issue",
54222
54646
  description: "创建 Issue, 参数 repo, title, body, assignees, labels, priority",
54223
- middleware: ["auth"],
54647
+ middleware: ["admin-auth"],
54224
54648
  metadata: {
54225
54649
  tags: ["opencode"],
54226
54650
  ...createSkill({
@@ -54260,7 +54684,7 @@ app.route({
54260
54684
  path: "cnb",
54261
54685
  key: "complete-issue",
54262
54686
  description: "完成 Issue, 参数 repo, issueNumber",
54263
- middleware: ["auth"],
54687
+ middleware: ["admin-auth"],
54264
54688
  metadata: {
54265
54689
  tags: ["opencode"],
54266
54690
  ...createSkill({
@@ -66711,7 +67135,7 @@ var ZodNanoID3 = /* @__PURE__ */ $constructor3("ZodNanoID", (inst, def) => {
66711
67135
  $ZodNanoID3.init(inst, def);
66712
67136
  ZodStringFormat3.init(inst, def);
66713
67137
  });
66714
- function nanoid4(params) {
67138
+ function nanoid5(params) {
66715
67139
  return _nanoid3(ZodNanoID3, params);
66716
67140
  }
66717
67141
  var ZodCUID5 = /* @__PURE__ */ $constructor3("ZodCUID", (inst, def) => {
@@ -67709,7 +68133,7 @@ var _schemas2 = /* @__PURE__ */ Object.freeze({
67709
68133
  map: map3,
67710
68134
  meta: meta4,
67711
68135
  nan: nan3,
67712
- nanoid: nanoid4,
68136
+ nanoid: nanoid5,
67713
68137
  nativeEnum: nativeEnum3,
67714
68138
  never: never3,
67715
68139
  nonoptional: nonoptional3,
@@ -68427,7 +68851,7 @@ var z3 = /* @__PURE__ */ Object.freeze({
68427
68851
  minSize: _minSize3,
68428
68852
  multipleOf: _multipleOf3,
68429
68853
  nan: nan3,
68430
- nanoid: nanoid4,
68854
+ nanoid: nanoid5,
68431
68855
  nativeEnum: nativeEnum3,
68432
68856
  negative: _negative3,
68433
68857
  never: never3,