@kevisual/cnb 0.0.24 → 0.0.26

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
@@ -25,6 +25,7 @@ var __export = (target, all) => {
25
25
  set: (newValue) => all[name] = () => newValue
26
26
  });
27
27
  };
28
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
28
29
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
29
30
 
30
31
  // node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/dayjs.min.js
@@ -2437,9 +2438,9 @@ var require_websocket = __commonJS((exports, module) => {
2437
2438
  emitErrorAndClose(websocket2, err);
2438
2439
  });
2439
2440
  req.on("response", (res) => {
2440
- const location2 = res.headers.location;
2441
+ const location = res.headers.location;
2441
2442
  const statusCode = res.statusCode;
2442
- if (location2 && opts.followRedirects && statusCode >= 300 && statusCode < 400) {
2443
+ if (location && opts.followRedirects && statusCode >= 300 && statusCode < 400) {
2443
2444
  if (++websocket2._redirects > opts.maxRedirects) {
2444
2445
  abortHandshake(websocket2, req, "Maximum redirects exceeded");
2445
2446
  return;
@@ -2447,9 +2448,9 @@ var require_websocket = __commonJS((exports, module) => {
2447
2448
  req.abort();
2448
2449
  let addr;
2449
2450
  try {
2450
- addr = new URL2(location2, address);
2451
+ addr = new URL2(location, address);
2451
2452
  } catch (e) {
2452
- const err = new SyntaxError(`Invalid URL: ${location2}`);
2453
+ const err = new SyntaxError(`Invalid URL: ${location}`);
2453
2454
  emitErrorAndClose(websocket2, err);
2454
2455
  return;
2455
2456
  }
@@ -3138,6 +3139,26 @@ var require_websocket_server = __commonJS((exports, module) => {
3138
3139
  }
3139
3140
  });
3140
3141
 
3142
+ // node_modules/.pnpm/@kevisual+ws@8.19.0/node_modules/@kevisual/ws/wrapper.mjs
3143
+ var exports_wrapper = {};
3144
+ __export(exports_wrapper, {
3145
+ default: () => wrapper_default,
3146
+ createWebSocketStream: () => import_stream.default,
3147
+ WebSocketServer: () => import_websocket_server.default,
3148
+ WebSocket: () => import_websocket.default,
3149
+ Sender: () => import_sender.default,
3150
+ Receiver: () => import_receiver.default
3151
+ });
3152
+ var import_stream, import_receiver, import_sender, import_websocket, import_websocket_server, wrapper_default;
3153
+ var init_wrapper = __esm(() => {
3154
+ import_stream = __toESM(require_stream(), 1);
3155
+ import_receiver = __toESM(require_receiver(), 1);
3156
+ import_sender = __toESM(require_sender(), 1);
3157
+ import_websocket = __toESM(require_websocket(), 1);
3158
+ import_websocket_server = __toESM(require_websocket_server(), 1);
3159
+ wrapper_default = import_websocket.default;
3160
+ });
3161
+
3141
3162
  // node_modules/.pnpm/@kevisual+router@0.0.70/node_modules/@kevisual/router/dist/router.js
3142
3163
  import require$$1, { webcrypto } from "node:crypto";
3143
3164
  import require$$2 from "node:http";
@@ -20177,9 +20198,9 @@ function requireWebsocket() {
20177
20198
  emitErrorAndClose(websocket2, err);
20178
20199
  });
20179
20200
  req.on("response", (res) => {
20180
- const location2 = res.headers.location;
20201
+ const location = res.headers.location;
20181
20202
  const statusCode = res.statusCode;
20182
- if (location2 && opts.followRedirects && statusCode >= 300 && statusCode < 400) {
20203
+ if (location && opts.followRedirects && statusCode >= 300 && statusCode < 400) {
20183
20204
  if (++websocket2._redirects > opts.maxRedirects) {
20184
20205
  abortHandshake(websocket2, req, "Maximum redirects exceeded");
20185
20206
  return;
@@ -20187,9 +20208,9 @@ function requireWebsocket() {
20187
20208
  req.abort();
20188
20209
  let addr;
20189
20210
  try {
20190
- addr = new URL2(location2, address);
20211
+ addr = new URL2(location, address);
20191
20212
  } catch (e) {
20192
- const err = new SyntaxError(`Invalid URL: ${location2}`);
20213
+ const err = new SyntaxError(`Invalid URL: ${location}`);
20193
20214
  emitErrorAndClose(websocket2, err);
20194
20215
  return;
20195
20216
  }
@@ -20893,8 +20914,7 @@ function requireWebsocketServer() {
20893
20914
  }
20894
20915
  var websocketServerExports = requireWebsocketServer();
20895
20916
 
20896
- // node_modules/.pnpm/@kevisual+context@0.0.4/node_modules/@kevisual/context/dist/app.js
20897
- var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
20917
+ // node_modules/.pnpm/@kevisual+context@0.0.6/node_modules/@kevisual/context/dist/app.js
20898
20918
  function getDefaultExportFromCjs2(x) {
20899
20919
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
20900
20920
  }
@@ -21427,6 +21447,7 @@ var useConfigKey = (key, init, isNew) => {
21427
21447
  }
21428
21448
  return useEnvKey(key, init, "config");
21429
21449
  };
21450
+
21430
21451
  class InitEnv {
21431
21452
  static isInit = false;
21432
21453
  static init(opts) {
@@ -21957,7 +21978,7 @@ var useKey = (key, opts) => {
21957
21978
  }
21958
21979
  return v;
21959
21980
  };
21960
- var isBrowser2 = typeof window !== "undefined" && typeof window.document !== "undefined";
21981
+ var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
21961
21982
  function getDefaultExportFromCjs3(x) {
21962
21983
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
21963
21984
  }
@@ -22805,6 +22826,10 @@ class Repo extends CNBCore {
22805
22826
  const url2 = `/${repo}`;
22806
22827
  return this.patch({ url: url2, data: params });
22807
22828
  }
22829
+ getRepo(repo) {
22830
+ const url2 = `/${repo}`;
22831
+ return this.get({ url: url2 });
22832
+ }
22808
22833
  }
22809
22834
 
22810
22835
  // src/user/index.ts
@@ -36599,7 +36624,7 @@ config3(en_default());
36599
36624
  // node_modules/.pnpm/zod@4.3.6/node_modules/zod/index.js
36600
36625
  var zod_default = exports_external;
36601
36626
 
36602
- // node_modules/.pnpm/@opencode-ai+plugin@1.2.1/node_modules/@opencode-ai/plugin/dist/tool.js
36627
+ // node_modules/.pnpm/@opencode-ai+plugin@1.2.4/node_modules/@opencode-ai/plugin/dist/tool.js
36603
36628
  function tool2(input) {
36604
36629
  return input;
36605
36630
  }
@@ -36663,9 +36688,9 @@ app.route({
36663
36688
  title: "列出cnb代码仓库",
36664
36689
  summary: "列出cnb代码仓库, 可选flags参数,如 KnowledgeBase",
36665
36690
  args: {
36666
- search: tool2.schema.string().optional().describe("搜索关键词"),
36667
- pageSize: tool2.schema.number().optional().describe("每页数量,默认999"),
36668
- flags: tool2.schema.string().optional().describe("仓库标记,如果是知识库则填写 KnowledgeBase")
36691
+ search: tool.schema.string().optional().describe("搜索关键词"),
36692
+ pageSize: tool.schema.number().optional().describe("每页数量,默认999"),
36693
+ flags: tool.schema.string().optional().describe("仓库标记,如果是知识库则填写 KnowledgeBase")
36669
36694
  }
36670
36695
  })
36671
36696
  }
@@ -36703,9 +36728,9 @@ app.route({
36703
36728
  skill: "create-repo",
36704
36729
  title: "创建代码仓库",
36705
36730
  args: {
36706
- name: tool2.schema.string().describe("代码仓库名称, 如 my-user/my-repo"),
36707
- visibility: tool2.schema.string().describe("代码仓库可见性, public 或 private").default("public"),
36708
- description: tool2.schema.string().describe("代码仓库描述")
36731
+ name: tool.schema.string().describe("代码仓库名称, 如 my-user/my-repo"),
36732
+ visibility: tool.schema.string().describe("代码仓库可见性, public 或 private").default("public"),
36733
+ description: tool.schema.string().describe("代码仓库描述")
36709
36734
  },
36710
36735
  summary: "创建一个新的代码仓库"
36711
36736
  })
@@ -36741,10 +36766,10 @@ app.route({
36741
36766
  title: "在代码仓库中创建文件",
36742
36767
  summary: `在代码仓库中创建文件, encoding 可选,默认 raw`,
36743
36768
  args: {
36744
- repoName: tool2.schema.string().describe("代码仓库名称, 如 my-user/my-repo"),
36745
- filePath: tool2.schema.string().describe("文件路径, 如 src/index.ts"),
36746
- content: tool2.schema.string().describe("文本的字符串的内容"),
36747
- encoding: tool2.schema.string().describe("编码方式,如 raw").optional()
36769
+ repoName: tool.schema.string().describe("代码仓库名称, 如 my-user/my-repo"),
36770
+ filePath: tool.schema.string().describe("文件路径, 如 src/index.ts"),
36771
+ content: tool.schema.string().describe("文本的字符串的内容"),
36772
+ encoding: tool.schema.string().describe("编码方式,如 raw").optional()
36748
36773
  }
36749
36774
  })
36750
36775
  }
@@ -36775,7 +36800,7 @@ app.route({
36775
36800
  skill: "delete-repo",
36776
36801
  title: "删除代码仓库",
36777
36802
  args: {
36778
- name: tool2.schema.string().describe("代码仓库名称")
36803
+ name: tool.schema.string().describe("代码仓库名称")
36779
36804
  },
36780
36805
  summary: "删除一个代码仓库"
36781
36806
  })
@@ -36855,15 +36880,15 @@ function nanoid4(size = 21) {
36855
36880
  // agent/routes/workspace/keep.ts
36856
36881
  var import_dayjs = __toESM(require_dayjs_min(), 1);
36857
36882
 
36858
- // node_modules/.pnpm/@kevisual+ws@8.19.0/node_modules/@kevisual/ws/wrapper.mjs
36859
- var import_stream = __toESM(require_stream(), 1);
36860
- var import_receiver = __toESM(require_receiver(), 1);
36861
- var import_sender = __toESM(require_sender(), 1);
36862
- var import_websocket = __toESM(require_websocket(), 1);
36863
- var import_websocket_server = __toESM(require_websocket_server(), 1);
36864
- var wrapper_default = import_websocket.default;
36865
-
36866
36883
  // src/workspace/keep-live.ts
36884
+ var WebSocketModule;
36885
+ if (typeof Bun !== "undefined") {
36886
+ WebSocketModule = { WebSocket: globalThis.WebSocket };
36887
+ } else {
36888
+ WebSocketModule = await Promise.resolve().then(() => (init_wrapper(), exports_wrapper));
36889
+ }
36890
+ var WebSocket2 = WebSocketModule.WebSocket;
36891
+
36867
36892
  class WSKeepAlive {
36868
36893
  ws = null;
36869
36894
  config;
@@ -36871,6 +36896,7 @@ class WSKeepAlive {
36871
36896
  pingTimer = null;
36872
36897
  messageHandlers = new Set;
36873
36898
  url;
36899
+ isBun;
36874
36900
  constructor(config4) {
36875
36901
  this.config = {
36876
36902
  wsUrl: config4.wsUrl,
@@ -36887,6 +36913,7 @@ class WSKeepAlive {
36887
36913
  debug: config4.debug ?? false
36888
36914
  };
36889
36915
  this.url = new URL(this.config.wsUrl);
36916
+ this.isBun = typeof Bun !== "undefined";
36890
36917
  }
36891
36918
  log(message) {
36892
36919
  if (!this.config.debug)
@@ -36925,7 +36952,7 @@ class WSKeepAlive {
36925
36952
  connect() {
36926
36953
  const { wsUrl, cookie, debug } = this.config;
36927
36954
  this.log(`Connecting to ${wsUrl}...`);
36928
- this.ws = new wrapper_default(wsUrl, {
36955
+ this.ws = new WebSocket2(wsUrl, {
36929
36956
  headers: {
36930
36957
  Origin: this.url.origin,
36931
36958
  Cookie: cookie,
@@ -36936,40 +36963,77 @@ class WSKeepAlive {
36936
36963
  "Sec-WebSocket-Extensions": "permessage-deflate"
36937
36964
  }
36938
36965
  });
36939
- this.ws.on("open", () => {
36940
- debug && this.log("Connected!");
36941
- this.reconnectAttempts = 0;
36942
- this.config.onConnect();
36943
- this.startPing();
36944
- });
36945
- this.ws.on("message", (data) => {
36946
- if (Buffer.isBuffer(data)) {
36947
- const parsed = this.parseMessage(data);
36948
- this.config.onMessage(parsed?.raw ?? data);
36949
- this.messageHandlers.forEach((handler) => {
36950
- if (parsed)
36951
- handler(parsed);
36952
- });
36953
- } else {
36954
- this.config.onMessage(data);
36955
- }
36956
- });
36957
- this.ws.on("close", (code) => {
36958
- debug && this.log(`Disconnected (code: ${code})`);
36959
- this.stopPing();
36960
- this.config.onDisconnect(code);
36961
- this.handleReconnect();
36962
- });
36963
- this.ws.on("error", (err) => {
36964
- debug && this.log(`Error: ${err.message}`);
36965
- this.config.onError(err);
36966
- });
36966
+ if (this.isBun) {
36967
+ const ws = this.ws;
36968
+ ws.onopen = () => {
36969
+ debug && this.log("Connected!");
36970
+ this.reconnectAttempts = 0;
36971
+ this.config.onConnect();
36972
+ this.startPing();
36973
+ };
36974
+ ws.onmessage = async (event) => {
36975
+ let data;
36976
+ if (event.data instanceof Blob) {
36977
+ data = Buffer.from(await event.data.arrayBuffer());
36978
+ } else if (event.data instanceof ArrayBuffer) {
36979
+ data = Buffer.from(event.data);
36980
+ } else if (typeof event.data === "string") {
36981
+ data = event.data;
36982
+ } else {
36983
+ data = Buffer.from(event.data);
36984
+ }
36985
+ this.handleMessage(data);
36986
+ };
36987
+ ws.onclose = (event) => {
36988
+ debug && this.log(`Disconnected (code: ${event.code})`);
36989
+ this.stopPing();
36990
+ this.config.onDisconnect(event.code);
36991
+ this.handleReconnect();
36992
+ };
36993
+ ws.onerror = (event) => {
36994
+ debug && this.log(`Error: ${event}`);
36995
+ this.config.onError(new Error("WebSocket error"));
36996
+ };
36997
+ } else {
36998
+ const ws = this.ws;
36999
+ ws.on("open", () => {
37000
+ debug && this.log("Connected!");
37001
+ this.reconnectAttempts = 0;
37002
+ this.config.onConnect();
37003
+ this.startPing();
37004
+ });
37005
+ ws.on("message", (data) => {
37006
+ this.handleMessage(data);
37007
+ });
37008
+ ws.on("close", (code) => {
37009
+ debug && this.log(`Disconnected (code: ${code})`);
37010
+ this.stopPing();
37011
+ this.config.onDisconnect(code);
37012
+ this.handleReconnect();
37013
+ });
37014
+ ws.on("error", (err) => {
37015
+ debug && this.log(`Error: ${err.message}`);
37016
+ this.config.onError(err);
37017
+ });
37018
+ }
37019
+ }
37020
+ handleMessage(data) {
37021
+ if (Buffer.isBuffer(data)) {
37022
+ const parsed = this.parseMessage(data);
37023
+ this.config.onMessage(parsed?.raw ?? data);
37024
+ this.messageHandlers.forEach((handler) => {
37025
+ if (parsed)
37026
+ handler(parsed);
37027
+ });
37028
+ } else {
37029
+ this.config.onMessage(data);
37030
+ }
36967
37031
  }
36968
37032
  startPing() {
36969
37033
  this.stopPing();
36970
37034
  this.pingTimer = setInterval(() => {
36971
- if (this.ws && this.ws.readyState === wrapper_default.OPEN) {
36972
- this.ws.ping();
37035
+ if (this.ws && this.ws.readyState === WebSocket2.OPEN) {
37036
+ this.ws.send(JSON.stringify({ type: "ping", timestamp: Date.now() }));
36973
37037
  this.log("Sent ping");
36974
37038
  }
36975
37039
  }, this.config.pingInterval);
@@ -37356,9 +37420,9 @@ if (!app.hasRoute("call")) {
37356
37420
  title: "调用app应用",
37357
37421
  summary: "调用router的应用, 参数path, key, payload",
37358
37422
  args: {
37359
- path: tool2.schema.string().describe("应用路径,例如 cnb"),
37360
- key: tool2.schema.string().optional().describe("应用key,例如 list-repos"),
37361
- payload: tool2.schema.object({}).optional().describe("调用参数")
37423
+ path: tool.schema.string().describe("应用路径,例如 cnb"),
37424
+ key: tool.schema.string().optional().describe("应用key,例如 list-repos"),
37425
+ payload: tool.schema.object({}).optional().describe("调用参数")
37362
37426
  }
37363
37427
  })
37364
37428
  }
@@ -37565,7 +37629,7 @@ var __export2 = (target, all) => {
37565
37629
  set: (newValue) => all[name] = () => newValue
37566
37630
  });
37567
37631
  };
37568
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
37632
+ var __esm2 = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
37569
37633
  var exports_buffer = {};
37570
37634
  __export2(exports_buffer, {
37571
37635
  transcode: () => transcode,
@@ -38280,7 +38344,7 @@ var isAscii = (str) => {
38280
38344
  };
38281
38345
  var transcode;
38282
38346
  var buffer_default;
38283
- var init_buffer = __esm(() => {
38347
+ var init_buffer = __esm2(() => {
38284
38348
  lookup = [];
38285
38349
  revLookup = [];
38286
38350
  for (i = 0, len = code.length;i < len; ++i)
@@ -39274,7 +39338,7 @@ var promisify;
39274
39338
  var TextEncoder;
39275
39339
  var TextDecoder2;
39276
39340
  var util_default;
39277
- var init_util = __esm(() => {
39341
+ var init_util = __esm2(() => {
39278
39342
  formatRegExp = /%[sdj%]/g;
39279
39343
  debuglog = ((debugs = {}, debugEnvRegex = {}, debugEnv) => ((debugEnv = typeof process < "u" && false) && (debugEnv = debugEnv.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".*").replace(/,/g, "$|^").toUpperCase()), debugEnvRegex = new RegExp("^" + debugEnv + "$", "i"), (set3) => {
39280
39344
  if (set3 = set3.toUpperCase(), !debugs[set3])
@@ -39574,7 +39638,7 @@ var emitWithRejectionCapture = function(type2, ...args) {
39574
39638
  };
39575
39639
  var AbortError;
39576
39640
  var events_default;
39577
- var init_events = __esm(() => {
39641
+ var init_events = __esm2(() => {
39578
39642
  SymbolFor = Symbol.for;
39579
39643
  kCapture = Symbol("kCapture");
39580
39644
  kErrorMonitor = SymbolFor("events.errorMonitor");
@@ -43899,7 +43963,7 @@ var randomUUID = () => {
43899
43963
  var hardcoded_curves;
43900
43964
  var webcrypto2;
43901
43965
  var crypto_default;
43902
- var init_crypto = __esm(() => {
43966
+ var init_crypto = __esm2(() => {
43903
43967
  __create22 = Object.create;
43904
43968
  ({ getPrototypeOf: __getProtoOf22, defineProperty: __defProp22, getOwnPropertyNames: __getOwnPropNames22 } = Object);
43905
43969
  __hasOwnProp22 = Object.prototype.hasOwnProperty;
package/dist/routes.d.ts CHANGED
@@ -300,6 +300,7 @@ declare class Repo extends CNBCore {
300
300
  status?: 'active' | 'archived';
301
301
  }): Promise<Result<RepoItem[]>>;
302
302
  updateRepoInfo(repo: string, params: UpdateRepoInfo): Promise<any>;
303
+ getRepo(repo: string): Promise<Result<RepoItem>>;
303
304
  }
304
305
  type UpdateRepoInfo = {
305
306
  description?: string;