@kevisual/cnb 0.0.78 → 0.0.80
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/cli.js +58 -47
- package/dist/npc.js +58 -47
- package/dist/opencode.js +15 -14
- package/dist/routes.js +14 -13
- package/package.json +5 -6
- package/src/git/index.ts +33 -10
- package/src/repo/download.ts +26 -0
package/dist/cli.js
CHANGED
|
@@ -20038,7 +20038,7 @@ var require_commander2 = __commonJS((exports) => {
|
|
|
20038
20038
|
exports.InvalidOptionArgumentError = InvalidArgumentError4;
|
|
20039
20039
|
});
|
|
20040
20040
|
|
|
20041
|
-
// ../../node_modules/.pnpm/@kevisual+router@0.2.
|
|
20041
|
+
// ../../node_modules/.pnpm/@kevisual+router@0.2.6/node_modules/@kevisual/router/dist/router.js
|
|
20042
20042
|
import { createRequire as createRequire2 } from "node:module";
|
|
20043
20043
|
import { webcrypto as crypto } from "node:crypto";
|
|
20044
20044
|
import url2 from "node:url";
|
|
@@ -23692,7 +23692,7 @@ var listenProcess = async ({ app, mockProcess, params = {}, timeout: timeout2 =
|
|
|
23692
23692
|
const ctx = mergeParams?.context || {};
|
|
23693
23693
|
if (!msg.path && !msg.id) {
|
|
23694
23694
|
const route = app.routes.find((r) => r.path !== "router");
|
|
23695
|
-
msg.id = route?.
|
|
23695
|
+
msg.id = route?.rid;
|
|
23696
23696
|
}
|
|
23697
23697
|
const result = await app.run(msg, ctx);
|
|
23698
23698
|
const response = {
|
|
@@ -37601,9 +37601,9 @@ class QueryRouter {
|
|
|
37601
37601
|
if (!message?.path) {
|
|
37602
37602
|
return Promise.resolve({ code: 404, body: null, message: "Not found path" });
|
|
37603
37603
|
}
|
|
37604
|
-
const { path, key = "", payload = {}, ...query } = message;
|
|
37604
|
+
const { path, key = "", payload = {}, args = {}, ...query } = message;
|
|
37605
37605
|
ctx = ctx || {};
|
|
37606
|
-
ctx.query = { ...ctx.query, ...query, ...payload };
|
|
37606
|
+
ctx.query = { ...ctx.query, ...query, ...payload, ...args };
|
|
37607
37607
|
ctx.args = ctx.query;
|
|
37608
37608
|
ctx.state = { ...ctx?.state };
|
|
37609
37609
|
ctx.throw = this.throw;
|
|
@@ -37813,7 +37813,8 @@ class QueryRouterServer extends QueryRouter {
|
|
|
37813
37813
|
const { path, key, rid } = api2;
|
|
37814
37814
|
return this.run({ path, key, rid, payload }, ctx);
|
|
37815
37815
|
}
|
|
37816
|
-
async createAuth(fun) {
|
|
37816
|
+
async createAuth(fun, opts) {
|
|
37817
|
+
const overwrite = opts?.overwrite ?? false;
|
|
37817
37818
|
this.route({
|
|
37818
37819
|
path: "auth",
|
|
37819
37820
|
key: "auth",
|
|
@@ -37823,7 +37824,7 @@ class QueryRouterServer extends QueryRouter {
|
|
|
37823
37824
|
if (fun) {
|
|
37824
37825
|
await fun(ctx, "auth");
|
|
37825
37826
|
}
|
|
37826
|
-
}).addTo(this, { overwrite
|
|
37827
|
+
}).addTo(this, { overwrite });
|
|
37827
37828
|
this.route({
|
|
37828
37829
|
path: "auth-admin",
|
|
37829
37830
|
key: "auth-admin",
|
|
@@ -37834,7 +37835,7 @@ class QueryRouterServer extends QueryRouter {
|
|
|
37834
37835
|
if (fun) {
|
|
37835
37836
|
await fun(ctx, "auth-admin");
|
|
37836
37837
|
}
|
|
37837
|
-
}).addTo(this, { overwrite
|
|
37838
|
+
}).addTo(this, { overwrite });
|
|
37838
37839
|
this.route({
|
|
37839
37840
|
path: "auth-can",
|
|
37840
37841
|
key: "auth-can",
|
|
@@ -37844,7 +37845,7 @@ class QueryRouterServer extends QueryRouter {
|
|
|
37844
37845
|
if (fun) {
|
|
37845
37846
|
await fun(ctx, "auth-can");
|
|
37846
37847
|
}
|
|
37847
|
-
}).addTo(this, { overwrite
|
|
37848
|
+
}).addTo(this, { overwrite });
|
|
37848
37849
|
}
|
|
37849
37850
|
}
|
|
37850
37851
|
var isNode2 = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
@@ -65719,7 +65720,7 @@ app.route({
|
|
|
65719
65720
|
};
|
|
65720
65721
|
}).addTo(app);
|
|
65721
65722
|
|
|
65722
|
-
// ../../node_modules/.pnpm/@ai-sdk+gateway@3.0.
|
|
65723
|
+
// ../../node_modules/.pnpm/@ai-sdk+gateway@3.0.98_zod@4.3.6/node_modules/@ai-sdk/gateway/dist/index.mjs
|
|
65723
65724
|
var import_oidc = __toESM(require_dist(), 1);
|
|
65724
65725
|
var import_oidc2 = __toESM(require_dist(), 1);
|
|
65725
65726
|
var marker17 = "vercel.ai.gateway.error";
|
|
@@ -66176,7 +66177,7 @@ var gatewayAvailableModelsResponseSchema = lazySchema(() => zodSchema(exports_ex
|
|
|
66176
66177
|
provider: exports_external2.string(),
|
|
66177
66178
|
modelId: exports_external2.string()
|
|
66178
66179
|
}),
|
|
66179
|
-
modelType: exports_external2.enum(["embedding", "image", "language", "video"]).nullish()
|
|
66180
|
+
modelType: exports_external2.enum(["embedding", "image", "language", "reranking", "video"]).nullish()
|
|
66180
66181
|
}))
|
|
66181
66182
|
})));
|
|
66182
66183
|
var gatewayCreditsResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
|
|
@@ -67015,7 +67016,7 @@ async function getVercelRequestId() {
|
|
|
67015
67016
|
var _a92;
|
|
67016
67017
|
return (_a92 = import_oidc.getContext().headers) == null ? undefined : _a92["x-vercel-id"];
|
|
67017
67018
|
}
|
|
67018
|
-
var VERSION3 = "3.0.
|
|
67019
|
+
var VERSION3 = "3.0.98";
|
|
67019
67020
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
67020
67021
|
function createGatewayProvider(options = {}) {
|
|
67021
67022
|
var _a92, _b92;
|
|
@@ -67202,7 +67203,7 @@ async function getGatewayAuthToken(options) {
|
|
|
67202
67203
|
};
|
|
67203
67204
|
}
|
|
67204
67205
|
|
|
67205
|
-
// ../../node_modules/.pnpm/ai@6.0.
|
|
67206
|
+
// ../../node_modules/.pnpm/ai@6.0.161_zod@4.3.6/node_modules/ai/dist/index.mjs
|
|
67206
67207
|
var import_api = __toESM(require_src(), 1);
|
|
67207
67208
|
var import_api2 = __toESM(require_src(), 1);
|
|
67208
67209
|
var __defProp4 = Object.defineProperty;
|
|
@@ -67773,7 +67774,7 @@ function detectMediaType({
|
|
|
67773
67774
|
}
|
|
67774
67775
|
return;
|
|
67775
67776
|
}
|
|
67776
|
-
var VERSION4 = "6.0.
|
|
67777
|
+
var VERSION4 = "6.0.161";
|
|
67777
67778
|
var download = async ({
|
|
67778
67779
|
url: url4,
|
|
67779
67780
|
maxBytes,
|
|
@@ -72918,7 +72919,7 @@ app.route({
|
|
|
72918
72919
|
}
|
|
72919
72920
|
}).addTo(app, { overwrite: false });
|
|
72920
72921
|
|
|
72921
|
-
// ../../node_modules/.pnpm/@kevisual+router@0.2.
|
|
72922
|
+
// ../../node_modules/.pnpm/@kevisual+router@0.2.6/node_modules/@kevisual/router/dist/commander.js
|
|
72922
72923
|
import { createRequire as createRequire4 } from "node:module";
|
|
72923
72924
|
var __create4 = Object.create;
|
|
72924
72925
|
var __getProtoOf4 = Object.getPrototypeOf;
|
|
@@ -89051,51 +89052,61 @@ var parseDescription = (route) => {
|
|
|
89051
89052
|
}
|
|
89052
89053
|
return desc;
|
|
89053
89054
|
};
|
|
89054
|
-
var
|
|
89055
|
+
var createCommandList = (opts) => {
|
|
89055
89056
|
const { program: program2 } = opts;
|
|
89056
89057
|
const app3 = opts.app;
|
|
89057
89058
|
const routes = app3.routes;
|
|
89058
89059
|
const groupRoutes = groupByPath(routes);
|
|
89059
89060
|
for (const path3 in groupRoutes) {
|
|
89060
89061
|
const routeList = groupRoutes[path3];
|
|
89061
|
-
|
|
89062
|
+
if (!routeList)
|
|
89063
|
+
continue;
|
|
89064
|
+
const keys = routeList.map((route) => route.key);
|
|
89062
89065
|
const subProgram = program2.command(path3).description(`路由[${path3}] ${keys.length > 0 ? ": " + keys.join(", ") : ""}`);
|
|
89063
89066
|
routeList.forEach((route) => {
|
|
89064
|
-
if (!route.key)
|
|
89065
|
-
return;
|
|
89066
89067
|
const description = parseDescription(route);
|
|
89067
|
-
|
|
89068
|
-
|
|
89069
|
-
|
|
89070
|
-
|
|
89071
|
-
|
|
89072
|
-
|
|
89073
|
-
process.stdout.write(String(data) + `
|
|
89074
|
-
`);
|
|
89075
|
-
}
|
|
89076
|
-
};
|
|
89077
|
-
try {
|
|
89078
|
-
let args = {};
|
|
89079
|
-
if (options.args) {
|
|
89080
|
-
args = parseArgs(options.args);
|
|
89081
|
-
} else if (passedArgs.length > 0) {
|
|
89082
|
-
args = parseArgs(passedArgs.join(" "));
|
|
89083
|
-
}
|
|
89084
|
-
const res = await app3.run({ path: path3, key: route.key, payload: args }, { appId: app3.appId });
|
|
89085
|
-
if (res.code === 200) {
|
|
89086
|
-
output(res.data);
|
|
89087
|
-
} else {
|
|
89088
|
-
output(`Error: ${res.message}`);
|
|
89089
|
-
}
|
|
89090
|
-
} catch (error482) {
|
|
89091
|
-
output(`Execution error: ${error482 instanceof Error ? error482.message : String(error482)}`);
|
|
89092
|
-
}
|
|
89093
|
-
});
|
|
89068
|
+
if (!route.key) {
|
|
89069
|
+
createCommand2(subProgram, { description, app: app3, route });
|
|
89070
|
+
return;
|
|
89071
|
+
}
|
|
89072
|
+
const _sumCommandy = subProgram.command(route.key);
|
|
89073
|
+
createCommand2(_sumCommandy, { description, app: app3, route });
|
|
89094
89074
|
});
|
|
89095
89075
|
}
|
|
89096
89076
|
};
|
|
89077
|
+
var createCommand2 = (command, opts) => {
|
|
89078
|
+
const { description, app: app3, route } = opts;
|
|
89079
|
+
const path3 = route.path;
|
|
89080
|
+
command.description(description || "").option("--args <args>", `命令参数,支持 JSON 格式或 key=value 形式,例如: --args '{"a":1}' 或 --args 'a=1 b=2'`).argument("[args...]", `位置参数(推荐通过 -- 分隔传入),支持 JSON 或 key=value 格式,例如: -- a=1 b=2 或 -- '{"a":1}'`).action(async (passedArgs, options, _command) => {
|
|
89081
|
+
const output = (data) => {
|
|
89082
|
+
if (typeof data === "object") {
|
|
89083
|
+
process.stdout.write(JSON.stringify(data, null, 2) + `
|
|
89084
|
+
`);
|
|
89085
|
+
} else {
|
|
89086
|
+
process.stdout.write(String(data) + `
|
|
89087
|
+
`);
|
|
89088
|
+
}
|
|
89089
|
+
};
|
|
89090
|
+
try {
|
|
89091
|
+
let args = {};
|
|
89092
|
+
if (options.args) {
|
|
89093
|
+
args = parseArgs(options.args);
|
|
89094
|
+
} else if (passedArgs.length > 0) {
|
|
89095
|
+
args = parseArgs(passedArgs.join(" "));
|
|
89096
|
+
}
|
|
89097
|
+
const res = await app3.run({ path: path3, key: route.key, payload: args }, { appId: app3.appId });
|
|
89098
|
+
if (res.code === 200) {
|
|
89099
|
+
output(res.data);
|
|
89100
|
+
} else {
|
|
89101
|
+
output(`Error: ${res.message}`);
|
|
89102
|
+
}
|
|
89103
|
+
} catch (error482) {
|
|
89104
|
+
output(`Execution error: ${error482 instanceof Error ? error482.message : String(error482)}`);
|
|
89105
|
+
}
|
|
89106
|
+
});
|
|
89107
|
+
};
|
|
89097
89108
|
var parse5 = async (opts) => {
|
|
89098
|
-
const { description, parse: parse62 = true, version: version22, exitOnEnd =
|
|
89109
|
+
const { description, parse: parse62 = true, version: version22, exitOnEnd = false } = opts;
|
|
89099
89110
|
const app3 = opts.app;
|
|
89100
89111
|
const _program = opts.program || program;
|
|
89101
89112
|
_program.description(description || "Router 命令行工具");
|
|
@@ -89104,7 +89115,7 @@ var parse5 = async (opts) => {
|
|
|
89104
89115
|
}
|
|
89105
89116
|
app3.createRouteList();
|
|
89106
89117
|
createCliList(app3);
|
|
89107
|
-
|
|
89118
|
+
createCommandList({ app: app3, program: _program });
|
|
89108
89119
|
if (opts.remote) {
|
|
89109
89120
|
const { token: token2, username, id, url: url22 } = opts.remote;
|
|
89110
89121
|
const remoteApp = new RemoteApp({
|
package/dist/npc.js
CHANGED
|
@@ -17945,7 +17945,7 @@ var require_form_data = __commonJS((exports, module) => {
|
|
|
17945
17945
|
module.exports = FormData2;
|
|
17946
17946
|
});
|
|
17947
17947
|
|
|
17948
|
-
// ../../node_modules/.pnpm/@kevisual+router@0.2.
|
|
17948
|
+
// ../../node_modules/.pnpm/@kevisual+router@0.2.6/node_modules/@kevisual/router/dist/router.js
|
|
17949
17949
|
import { createRequire as createRequire2 } from "node:module";
|
|
17950
17950
|
import { webcrypto as crypto } from "node:crypto";
|
|
17951
17951
|
import url2 from "node:url";
|
|
@@ -21599,7 +21599,7 @@ var listenProcess = async ({ app, mockProcess, params = {}, timeout: timeout2 =
|
|
|
21599
21599
|
const ctx = mergeParams?.context || {};
|
|
21600
21600
|
if (!msg.path && !msg.id) {
|
|
21601
21601
|
const route = app.routes.find((r) => r.path !== "router");
|
|
21602
|
-
msg.id = route?.
|
|
21602
|
+
msg.id = route?.rid;
|
|
21603
21603
|
}
|
|
21604
21604
|
const result = await app.run(msg, ctx);
|
|
21605
21605
|
const response = {
|
|
@@ -35508,9 +35508,9 @@ class QueryRouter {
|
|
|
35508
35508
|
if (!message?.path) {
|
|
35509
35509
|
return Promise.resolve({ code: 404, body: null, message: "Not found path" });
|
|
35510
35510
|
}
|
|
35511
|
-
const { path, key = "", payload = {}, ...query } = message;
|
|
35511
|
+
const { path, key = "", payload = {}, args = {}, ...query } = message;
|
|
35512
35512
|
ctx = ctx || {};
|
|
35513
|
-
ctx.query = { ...ctx.query, ...query, ...payload };
|
|
35513
|
+
ctx.query = { ...ctx.query, ...query, ...payload, ...args };
|
|
35514
35514
|
ctx.args = ctx.query;
|
|
35515
35515
|
ctx.state = { ...ctx?.state };
|
|
35516
35516
|
ctx.throw = this.throw;
|
|
@@ -35720,7 +35720,8 @@ class QueryRouterServer extends QueryRouter {
|
|
|
35720
35720
|
const { path, key, rid } = api2;
|
|
35721
35721
|
return this.run({ path, key, rid, payload }, ctx);
|
|
35722
35722
|
}
|
|
35723
|
-
async createAuth(fun) {
|
|
35723
|
+
async createAuth(fun, opts) {
|
|
35724
|
+
const overwrite = opts?.overwrite ?? false;
|
|
35724
35725
|
this.route({
|
|
35725
35726
|
path: "auth",
|
|
35726
35727
|
key: "auth",
|
|
@@ -35730,7 +35731,7 @@ class QueryRouterServer extends QueryRouter {
|
|
|
35730
35731
|
if (fun) {
|
|
35731
35732
|
await fun(ctx, "auth");
|
|
35732
35733
|
}
|
|
35733
|
-
}).addTo(this, { overwrite
|
|
35734
|
+
}).addTo(this, { overwrite });
|
|
35734
35735
|
this.route({
|
|
35735
35736
|
path: "auth-admin",
|
|
35736
35737
|
key: "auth-admin",
|
|
@@ -35741,7 +35742,7 @@ class QueryRouterServer extends QueryRouter {
|
|
|
35741
35742
|
if (fun) {
|
|
35742
35743
|
await fun(ctx, "auth-admin");
|
|
35743
35744
|
}
|
|
35744
|
-
}).addTo(this, { overwrite
|
|
35745
|
+
}).addTo(this, { overwrite });
|
|
35745
35746
|
this.route({
|
|
35746
35747
|
path: "auth-can",
|
|
35747
35748
|
key: "auth-can",
|
|
@@ -35751,7 +35752,7 @@ class QueryRouterServer extends QueryRouter {
|
|
|
35751
35752
|
if (fun) {
|
|
35752
35753
|
await fun(ctx, "auth-can");
|
|
35753
35754
|
}
|
|
35754
|
-
}).addTo(this, { overwrite
|
|
35755
|
+
}).addTo(this, { overwrite });
|
|
35755
35756
|
}
|
|
35756
35757
|
}
|
|
35757
35758
|
var isNode2 = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
@@ -63660,7 +63661,7 @@ app.route({
|
|
|
63660
63661
|
};
|
|
63661
63662
|
}).addTo(app);
|
|
63662
63663
|
|
|
63663
|
-
// ../../node_modules/.pnpm/@ai-sdk+gateway@3.0.
|
|
63664
|
+
// ../../node_modules/.pnpm/@ai-sdk+gateway@3.0.98_zod@4.3.6/node_modules/@ai-sdk/gateway/dist/index.mjs
|
|
63664
63665
|
var import_oidc = __toESM(require_dist(), 1);
|
|
63665
63666
|
var import_oidc2 = __toESM(require_dist(), 1);
|
|
63666
63667
|
var marker17 = "vercel.ai.gateway.error";
|
|
@@ -64117,7 +64118,7 @@ var gatewayAvailableModelsResponseSchema = lazySchema(() => zodSchema(exports_ex
|
|
|
64117
64118
|
provider: exports_external2.string(),
|
|
64118
64119
|
modelId: exports_external2.string()
|
|
64119
64120
|
}),
|
|
64120
|
-
modelType: exports_external2.enum(["embedding", "image", "language", "video"]).nullish()
|
|
64121
|
+
modelType: exports_external2.enum(["embedding", "image", "language", "reranking", "video"]).nullish()
|
|
64121
64122
|
}))
|
|
64122
64123
|
})));
|
|
64123
64124
|
var gatewayCreditsResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
|
|
@@ -64956,7 +64957,7 @@ async function getVercelRequestId() {
|
|
|
64956
64957
|
var _a92;
|
|
64957
64958
|
return (_a92 = import_oidc.getContext().headers) == null ? undefined : _a92["x-vercel-id"];
|
|
64958
64959
|
}
|
|
64959
|
-
var VERSION3 = "3.0.
|
|
64960
|
+
var VERSION3 = "3.0.98";
|
|
64960
64961
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
64961
64962
|
function createGatewayProvider(options = {}) {
|
|
64962
64963
|
var _a92, _b92;
|
|
@@ -65143,7 +65144,7 @@ async function getGatewayAuthToken(options) {
|
|
|
65143
65144
|
};
|
|
65144
65145
|
}
|
|
65145
65146
|
|
|
65146
|
-
// ../../node_modules/.pnpm/ai@6.0.
|
|
65147
|
+
// ../../node_modules/.pnpm/ai@6.0.161_zod@4.3.6/node_modules/ai/dist/index.mjs
|
|
65147
65148
|
var import_api = __toESM(require_src(), 1);
|
|
65148
65149
|
var import_api2 = __toESM(require_src(), 1);
|
|
65149
65150
|
var __defProp4 = Object.defineProperty;
|
|
@@ -65714,7 +65715,7 @@ function detectMediaType({
|
|
|
65714
65715
|
}
|
|
65715
65716
|
return;
|
|
65716
65717
|
}
|
|
65717
|
-
var VERSION4 = "6.0.
|
|
65718
|
+
var VERSION4 = "6.0.161";
|
|
65718
65719
|
var download = async ({
|
|
65719
65720
|
url: url4,
|
|
65720
65721
|
maxBytes,
|
|
@@ -70859,7 +70860,7 @@ app.route({
|
|
|
70859
70860
|
}
|
|
70860
70861
|
}).addTo(app, { overwrite: false });
|
|
70861
70862
|
|
|
70862
|
-
// ../../node_modules/.pnpm/@kevisual+router@0.2.
|
|
70863
|
+
// ../../node_modules/.pnpm/@kevisual+router@0.2.6/node_modules/@kevisual/router/dist/commander.js
|
|
70863
70864
|
import { createRequire as createRequire4 } from "node:module";
|
|
70864
70865
|
var __create4 = Object.create;
|
|
70865
70866
|
var __getProtoOf4 = Object.getPrototypeOf;
|
|
@@ -86992,51 +86993,61 @@ var parseDescription = (route) => {
|
|
|
86992
86993
|
}
|
|
86993
86994
|
return desc;
|
|
86994
86995
|
};
|
|
86995
|
-
var
|
|
86996
|
+
var createCommandList = (opts) => {
|
|
86996
86997
|
const { program: program2 } = opts;
|
|
86997
86998
|
const app3 = opts.app;
|
|
86998
86999
|
const routes = app3.routes;
|
|
86999
87000
|
const groupRoutes = groupByPath(routes);
|
|
87000
87001
|
for (const path3 in groupRoutes) {
|
|
87001
87002
|
const routeList = groupRoutes[path3];
|
|
87002
|
-
|
|
87003
|
+
if (!routeList)
|
|
87004
|
+
continue;
|
|
87005
|
+
const keys = routeList.map((route) => route.key);
|
|
87003
87006
|
const subProgram = program2.command(path3).description(`路由[${path3}] ${keys.length > 0 ? ": " + keys.join(", ") : ""}`);
|
|
87004
87007
|
routeList.forEach((route) => {
|
|
87005
|
-
if (!route.key)
|
|
87006
|
-
return;
|
|
87007
87008
|
const description = parseDescription(route);
|
|
87008
|
-
|
|
87009
|
-
|
|
87010
|
-
|
|
87011
|
-
|
|
87012
|
-
|
|
87013
|
-
|
|
87014
|
-
process.stdout.write(String(data) + `
|
|
87015
|
-
`);
|
|
87016
|
-
}
|
|
87017
|
-
};
|
|
87018
|
-
try {
|
|
87019
|
-
let args = {};
|
|
87020
|
-
if (options.args) {
|
|
87021
|
-
args = parseArgs(options.args);
|
|
87022
|
-
} else if (passedArgs.length > 0) {
|
|
87023
|
-
args = parseArgs(passedArgs.join(" "));
|
|
87024
|
-
}
|
|
87025
|
-
const res = await app3.run({ path: path3, key: route.key, payload: args }, { appId: app3.appId });
|
|
87026
|
-
if (res.code === 200) {
|
|
87027
|
-
output(res.data);
|
|
87028
|
-
} else {
|
|
87029
|
-
output(`Error: ${res.message}`);
|
|
87030
|
-
}
|
|
87031
|
-
} catch (error482) {
|
|
87032
|
-
output(`Execution error: ${error482 instanceof Error ? error482.message : String(error482)}`);
|
|
87033
|
-
}
|
|
87034
|
-
});
|
|
87009
|
+
if (!route.key) {
|
|
87010
|
+
createCommand2(subProgram, { description, app: app3, route });
|
|
87011
|
+
return;
|
|
87012
|
+
}
|
|
87013
|
+
const _sumCommandy = subProgram.command(route.key);
|
|
87014
|
+
createCommand2(_sumCommandy, { description, app: app3, route });
|
|
87035
87015
|
});
|
|
87036
87016
|
}
|
|
87037
87017
|
};
|
|
87018
|
+
var createCommand2 = (command, opts) => {
|
|
87019
|
+
const { description, app: app3, route } = opts;
|
|
87020
|
+
const path3 = route.path;
|
|
87021
|
+
command.description(description || "").option("--args <args>", `命令参数,支持 JSON 格式或 key=value 形式,例如: --args '{"a":1}' 或 --args 'a=1 b=2'`).argument("[args...]", `位置参数(推荐通过 -- 分隔传入),支持 JSON 或 key=value 格式,例如: -- a=1 b=2 或 -- '{"a":1}'`).action(async (passedArgs, options, _command) => {
|
|
87022
|
+
const output = (data) => {
|
|
87023
|
+
if (typeof data === "object") {
|
|
87024
|
+
process.stdout.write(JSON.stringify(data, null, 2) + `
|
|
87025
|
+
`);
|
|
87026
|
+
} else {
|
|
87027
|
+
process.stdout.write(String(data) + `
|
|
87028
|
+
`);
|
|
87029
|
+
}
|
|
87030
|
+
};
|
|
87031
|
+
try {
|
|
87032
|
+
let args = {};
|
|
87033
|
+
if (options.args) {
|
|
87034
|
+
args = parseArgs(options.args);
|
|
87035
|
+
} else if (passedArgs.length > 0) {
|
|
87036
|
+
args = parseArgs(passedArgs.join(" "));
|
|
87037
|
+
}
|
|
87038
|
+
const res = await app3.run({ path: path3, key: route.key, payload: args }, { appId: app3.appId });
|
|
87039
|
+
if (res.code === 200) {
|
|
87040
|
+
output(res.data);
|
|
87041
|
+
} else {
|
|
87042
|
+
output(`Error: ${res.message}`);
|
|
87043
|
+
}
|
|
87044
|
+
} catch (error482) {
|
|
87045
|
+
output(`Execution error: ${error482 instanceof Error ? error482.message : String(error482)}`);
|
|
87046
|
+
}
|
|
87047
|
+
});
|
|
87048
|
+
};
|
|
87038
87049
|
var parse5 = async (opts) => {
|
|
87039
|
-
const { description, parse: parse62 = true, version: version22, exitOnEnd =
|
|
87050
|
+
const { description, parse: parse62 = true, version: version22, exitOnEnd = false } = opts;
|
|
87040
87051
|
const app3 = opts.app;
|
|
87041
87052
|
const _program = opts.program || program;
|
|
87042
87053
|
_program.description(description || "Router 命令行工具");
|
|
@@ -87045,7 +87056,7 @@ var parse5 = async (opts) => {
|
|
|
87045
87056
|
}
|
|
87046
87057
|
app3.createRouteList();
|
|
87047
87058
|
createCliList(app3);
|
|
87048
|
-
|
|
87059
|
+
createCommandList({ app: app3, program: _program });
|
|
87049
87060
|
if (opts.remote) {
|
|
87050
87061
|
const { token: token2, username, id, url: url22 } = opts.remote;
|
|
87051
87062
|
const remoteApp = new RemoteApp({
|
package/dist/opencode.js
CHANGED
|
@@ -17945,7 +17945,7 @@ var require_form_data = __commonJS((exports, module) => {
|
|
|
17945
17945
|
module.exports = FormData2;
|
|
17946
17946
|
});
|
|
17947
17947
|
|
|
17948
|
-
// ../../node_modules/.pnpm/@kevisual+router@0.2.
|
|
17948
|
+
// ../../node_modules/.pnpm/@kevisual+router@0.2.6/node_modules/@kevisual/router/dist/router.js
|
|
17949
17949
|
import { createRequire as createRequire2 } from "node:module";
|
|
17950
17950
|
import { webcrypto as crypto } from "node:crypto";
|
|
17951
17951
|
import url2 from "node:url";
|
|
@@ -21599,7 +21599,7 @@ var listenProcess = async ({ app, mockProcess, params = {}, timeout: timeout2 =
|
|
|
21599
21599
|
const ctx = mergeParams?.context || {};
|
|
21600
21600
|
if (!msg.path && !msg.id) {
|
|
21601
21601
|
const route = app.routes.find((r) => r.path !== "router");
|
|
21602
|
-
msg.id = route?.
|
|
21602
|
+
msg.id = route?.rid;
|
|
21603
21603
|
}
|
|
21604
21604
|
const result = await app.run(msg, ctx);
|
|
21605
21605
|
const response = {
|
|
@@ -35508,9 +35508,9 @@ class QueryRouter {
|
|
|
35508
35508
|
if (!message?.path) {
|
|
35509
35509
|
return Promise.resolve({ code: 404, body: null, message: "Not found path" });
|
|
35510
35510
|
}
|
|
35511
|
-
const { path, key = "", payload = {}, ...query } = message;
|
|
35511
|
+
const { path, key = "", payload = {}, args = {}, ...query } = message;
|
|
35512
35512
|
ctx = ctx || {};
|
|
35513
|
-
ctx.query = { ...ctx.query, ...query, ...payload };
|
|
35513
|
+
ctx.query = { ...ctx.query, ...query, ...payload, ...args };
|
|
35514
35514
|
ctx.args = ctx.query;
|
|
35515
35515
|
ctx.state = { ...ctx?.state };
|
|
35516
35516
|
ctx.throw = this.throw;
|
|
@@ -35720,7 +35720,8 @@ class QueryRouterServer extends QueryRouter {
|
|
|
35720
35720
|
const { path, key, rid } = api2;
|
|
35721
35721
|
return this.run({ path, key, rid, payload }, ctx);
|
|
35722
35722
|
}
|
|
35723
|
-
async createAuth(fun) {
|
|
35723
|
+
async createAuth(fun, opts) {
|
|
35724
|
+
const overwrite = opts?.overwrite ?? false;
|
|
35724
35725
|
this.route({
|
|
35725
35726
|
path: "auth",
|
|
35726
35727
|
key: "auth",
|
|
@@ -35730,7 +35731,7 @@ class QueryRouterServer extends QueryRouter {
|
|
|
35730
35731
|
if (fun) {
|
|
35731
35732
|
await fun(ctx, "auth");
|
|
35732
35733
|
}
|
|
35733
|
-
}).addTo(this, { overwrite
|
|
35734
|
+
}).addTo(this, { overwrite });
|
|
35734
35735
|
this.route({
|
|
35735
35736
|
path: "auth-admin",
|
|
35736
35737
|
key: "auth-admin",
|
|
@@ -35741,7 +35742,7 @@ class QueryRouterServer extends QueryRouter {
|
|
|
35741
35742
|
if (fun) {
|
|
35742
35743
|
await fun(ctx, "auth-admin");
|
|
35743
35744
|
}
|
|
35744
|
-
}).addTo(this, { overwrite
|
|
35745
|
+
}).addTo(this, { overwrite });
|
|
35745
35746
|
this.route({
|
|
35746
35747
|
path: "auth-can",
|
|
35747
35748
|
key: "auth-can",
|
|
@@ -35751,7 +35752,7 @@ class QueryRouterServer extends QueryRouter {
|
|
|
35751
35752
|
if (fun) {
|
|
35752
35753
|
await fun(ctx, "auth-can");
|
|
35753
35754
|
}
|
|
35754
|
-
}).addTo(this, { overwrite
|
|
35755
|
+
}).addTo(this, { overwrite });
|
|
35755
35756
|
}
|
|
35756
35757
|
}
|
|
35757
35758
|
var isNode2 = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
@@ -63626,7 +63627,7 @@ app.route({
|
|
|
63626
63627
|
};
|
|
63627
63628
|
}).addTo(app);
|
|
63628
63629
|
|
|
63629
|
-
// ../../node_modules/.pnpm/@ai-sdk+gateway@3.0.
|
|
63630
|
+
// ../../node_modules/.pnpm/@ai-sdk+gateway@3.0.98_zod@4.3.6/node_modules/@ai-sdk/gateway/dist/index.mjs
|
|
63630
63631
|
var import_oidc = __toESM(require_dist(), 1);
|
|
63631
63632
|
var import_oidc2 = __toESM(require_dist(), 1);
|
|
63632
63633
|
var marker17 = "vercel.ai.gateway.error";
|
|
@@ -64083,7 +64084,7 @@ var gatewayAvailableModelsResponseSchema = lazySchema(() => zodSchema(exports_ex
|
|
|
64083
64084
|
provider: exports_external2.string(),
|
|
64084
64085
|
modelId: exports_external2.string()
|
|
64085
64086
|
}),
|
|
64086
|
-
modelType: exports_external2.enum(["embedding", "image", "language", "video"]).nullish()
|
|
64087
|
+
modelType: exports_external2.enum(["embedding", "image", "language", "reranking", "video"]).nullish()
|
|
64087
64088
|
}))
|
|
64088
64089
|
})));
|
|
64089
64090
|
var gatewayCreditsResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
|
|
@@ -64922,7 +64923,7 @@ async function getVercelRequestId() {
|
|
|
64922
64923
|
var _a92;
|
|
64923
64924
|
return (_a92 = import_oidc.getContext().headers) == null ? undefined : _a92["x-vercel-id"];
|
|
64924
64925
|
}
|
|
64925
|
-
var VERSION3 = "3.0.
|
|
64926
|
+
var VERSION3 = "3.0.98";
|
|
64926
64927
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
64927
64928
|
function createGatewayProvider(options = {}) {
|
|
64928
64929
|
var _a92, _b92;
|
|
@@ -65109,7 +65110,7 @@ async function getGatewayAuthToken(options) {
|
|
|
65109
65110
|
};
|
|
65110
65111
|
}
|
|
65111
65112
|
|
|
65112
|
-
// ../../node_modules/.pnpm/ai@6.0.
|
|
65113
|
+
// ../../node_modules/.pnpm/ai@6.0.161_zod@4.3.6/node_modules/ai/dist/index.mjs
|
|
65113
65114
|
var import_api = __toESM(require_src(), 1);
|
|
65114
65115
|
var import_api2 = __toESM(require_src(), 1);
|
|
65115
65116
|
var __defProp4 = Object.defineProperty;
|
|
@@ -65680,7 +65681,7 @@ function detectMediaType({
|
|
|
65680
65681
|
}
|
|
65681
65682
|
return;
|
|
65682
65683
|
}
|
|
65683
|
-
var VERSION4 = "6.0.
|
|
65684
|
+
var VERSION4 = "6.0.161";
|
|
65684
65685
|
var download = async ({
|
|
65685
65686
|
url: url4,
|
|
65686
65687
|
maxBytes,
|
|
@@ -70825,7 +70826,7 @@ app.route({
|
|
|
70825
70826
|
}
|
|
70826
70827
|
}).addTo(app, { overwrite: false });
|
|
70827
70828
|
|
|
70828
|
-
// ../../node_modules/.pnpm/@kevisual+router@0.2.
|
|
70829
|
+
// ../../node_modules/.pnpm/@kevisual+router@0.2.6/node_modules/@kevisual/router/dist/opencode.js
|
|
70829
70830
|
import { createRequire as createRequire4 } from "node:module";
|
|
70830
70831
|
import { webcrypto as crypto3 } from "node:crypto";
|
|
70831
70832
|
var __create4 = Object.create;
|
package/dist/routes.js
CHANGED
|
@@ -17945,7 +17945,7 @@ var require_form_data = __commonJS((exports, module) => {
|
|
|
17945
17945
|
module.exports = FormData2;
|
|
17946
17946
|
});
|
|
17947
17947
|
|
|
17948
|
-
// ../../node_modules/.pnpm/@kevisual+router@0.2.
|
|
17948
|
+
// ../../node_modules/.pnpm/@kevisual+router@0.2.6/node_modules/@kevisual/router/dist/router.js
|
|
17949
17949
|
import { createRequire as createRequire2 } from "node:module";
|
|
17950
17950
|
import { webcrypto as crypto } from "node:crypto";
|
|
17951
17951
|
import url2 from "node:url";
|
|
@@ -21599,7 +21599,7 @@ var listenProcess = async ({ app, mockProcess, params = {}, timeout: timeout2 =
|
|
|
21599
21599
|
const ctx = mergeParams?.context || {};
|
|
21600
21600
|
if (!msg.path && !msg.id) {
|
|
21601
21601
|
const route = app.routes.find((r) => r.path !== "router");
|
|
21602
|
-
msg.id = route?.
|
|
21602
|
+
msg.id = route?.rid;
|
|
21603
21603
|
}
|
|
21604
21604
|
const result = await app.run(msg, ctx);
|
|
21605
21605
|
const response = {
|
|
@@ -35508,9 +35508,9 @@ class QueryRouter {
|
|
|
35508
35508
|
if (!message?.path) {
|
|
35509
35509
|
return Promise.resolve({ code: 404, body: null, message: "Not found path" });
|
|
35510
35510
|
}
|
|
35511
|
-
const { path, key = "", payload = {}, ...query } = message;
|
|
35511
|
+
const { path, key = "", payload = {}, args = {}, ...query } = message;
|
|
35512
35512
|
ctx = ctx || {};
|
|
35513
|
-
ctx.query = { ...ctx.query, ...query, ...payload };
|
|
35513
|
+
ctx.query = { ...ctx.query, ...query, ...payload, ...args };
|
|
35514
35514
|
ctx.args = ctx.query;
|
|
35515
35515
|
ctx.state = { ...ctx?.state };
|
|
35516
35516
|
ctx.throw = this.throw;
|
|
@@ -35720,7 +35720,8 @@ class QueryRouterServer extends QueryRouter {
|
|
|
35720
35720
|
const { path, key, rid } = api2;
|
|
35721
35721
|
return this.run({ path, key, rid, payload }, ctx);
|
|
35722
35722
|
}
|
|
35723
|
-
async createAuth(fun) {
|
|
35723
|
+
async createAuth(fun, opts) {
|
|
35724
|
+
const overwrite = opts?.overwrite ?? false;
|
|
35724
35725
|
this.route({
|
|
35725
35726
|
path: "auth",
|
|
35726
35727
|
key: "auth",
|
|
@@ -35730,7 +35731,7 @@ class QueryRouterServer extends QueryRouter {
|
|
|
35730
35731
|
if (fun) {
|
|
35731
35732
|
await fun(ctx, "auth");
|
|
35732
35733
|
}
|
|
35733
|
-
}).addTo(this, { overwrite
|
|
35734
|
+
}).addTo(this, { overwrite });
|
|
35734
35735
|
this.route({
|
|
35735
35736
|
path: "auth-admin",
|
|
35736
35737
|
key: "auth-admin",
|
|
@@ -35741,7 +35742,7 @@ class QueryRouterServer extends QueryRouter {
|
|
|
35741
35742
|
if (fun) {
|
|
35742
35743
|
await fun(ctx, "auth-admin");
|
|
35743
35744
|
}
|
|
35744
|
-
}).addTo(this, { overwrite
|
|
35745
|
+
}).addTo(this, { overwrite });
|
|
35745
35746
|
this.route({
|
|
35746
35747
|
path: "auth-can",
|
|
35747
35748
|
key: "auth-can",
|
|
@@ -35751,7 +35752,7 @@ class QueryRouterServer extends QueryRouter {
|
|
|
35751
35752
|
if (fun) {
|
|
35752
35753
|
await fun(ctx, "auth-can");
|
|
35753
35754
|
}
|
|
35754
|
-
}).addTo(this, { overwrite
|
|
35755
|
+
}).addTo(this, { overwrite });
|
|
35755
35756
|
}
|
|
35756
35757
|
}
|
|
35757
35758
|
var isNode2 = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
@@ -63626,7 +63627,7 @@ app.route({
|
|
|
63626
63627
|
};
|
|
63627
63628
|
}).addTo(app);
|
|
63628
63629
|
|
|
63629
|
-
// ../../node_modules/.pnpm/@ai-sdk+gateway@3.0.
|
|
63630
|
+
// ../../node_modules/.pnpm/@ai-sdk+gateway@3.0.98_zod@4.3.6/node_modules/@ai-sdk/gateway/dist/index.mjs
|
|
63630
63631
|
var import_oidc = __toESM(require_dist(), 1);
|
|
63631
63632
|
var import_oidc2 = __toESM(require_dist(), 1);
|
|
63632
63633
|
var marker17 = "vercel.ai.gateway.error";
|
|
@@ -64083,7 +64084,7 @@ var gatewayAvailableModelsResponseSchema = lazySchema(() => zodSchema(exports_ex
|
|
|
64083
64084
|
provider: exports_external2.string(),
|
|
64084
64085
|
modelId: exports_external2.string()
|
|
64085
64086
|
}),
|
|
64086
|
-
modelType: exports_external2.enum(["embedding", "image", "language", "video"]).nullish()
|
|
64087
|
+
modelType: exports_external2.enum(["embedding", "image", "language", "reranking", "video"]).nullish()
|
|
64087
64088
|
}))
|
|
64088
64089
|
})));
|
|
64089
64090
|
var gatewayCreditsResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
|
|
@@ -64922,7 +64923,7 @@ async function getVercelRequestId() {
|
|
|
64922
64923
|
var _a92;
|
|
64923
64924
|
return (_a92 = import_oidc.getContext().headers) == null ? undefined : _a92["x-vercel-id"];
|
|
64924
64925
|
}
|
|
64925
|
-
var VERSION3 = "3.0.
|
|
64926
|
+
var VERSION3 = "3.0.98";
|
|
64926
64927
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
64927
64928
|
function createGatewayProvider(options = {}) {
|
|
64928
64929
|
var _a92, _b92;
|
|
@@ -65109,7 +65110,7 @@ async function getGatewayAuthToken(options) {
|
|
|
65109
65110
|
};
|
|
65110
65111
|
}
|
|
65111
65112
|
|
|
65112
|
-
// ../../node_modules/.pnpm/ai@6.0.
|
|
65113
|
+
// ../../node_modules/.pnpm/ai@6.0.161_zod@4.3.6/node_modules/ai/dist/index.mjs
|
|
65113
65114
|
var import_api = __toESM(require_src(), 1);
|
|
65114
65115
|
var import_api2 = __toESM(require_src(), 1);
|
|
65115
65116
|
var __defProp4 = Object.defineProperty;
|
|
@@ -65680,7 +65681,7 @@ function detectMediaType({
|
|
|
65680
65681
|
}
|
|
65681
65682
|
return;
|
|
65682
65683
|
}
|
|
65683
|
-
var VERSION4 = "6.0.
|
|
65684
|
+
var VERSION4 = "6.0.161";
|
|
65684
65685
|
var download = async ({
|
|
65685
65686
|
url: url4,
|
|
65686
65687
|
maxBytes,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kevisual/cnb",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.80",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"basename": "/root/cnb",
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
},
|
|
19
19
|
"keywords": [],
|
|
20
20
|
"bin": {
|
|
21
|
-
"cnb": "bin/index.js",
|
|
22
21
|
"cloud": "bin/index.js",
|
|
23
22
|
"cloud-live": "bin/live.js",
|
|
24
23
|
"cloud-npc": "bin/npc.js"
|
|
@@ -41,11 +40,11 @@
|
|
|
41
40
|
"@kevisual/dts": "^0.0.4",
|
|
42
41
|
"@kevisual/remote-app": "^0.0.7",
|
|
43
42
|
"@kevisual/types": "^0.0.14",
|
|
44
|
-
"@opencode-ai/plugin": "^1.4.
|
|
43
|
+
"@opencode-ai/plugin": "^1.4.6",
|
|
45
44
|
"@types/bun": "^1.3.12",
|
|
46
45
|
"@types/node": "^25.6.0",
|
|
47
46
|
"@types/ws": "^8.18.1",
|
|
48
|
-
"ai": "^6.0.
|
|
47
|
+
"ai": "^6.0.161",
|
|
49
48
|
"commander": "^14.0.3",
|
|
50
49
|
"dayjs": "^1.11.20",
|
|
51
50
|
"dotenv": "^17.4.2",
|
|
@@ -60,9 +59,9 @@
|
|
|
60
59
|
},
|
|
61
60
|
"dependencies": {
|
|
62
61
|
"@kevisual/query": "^0.0.55",
|
|
63
|
-
"@kevisual/router": "^0.2.
|
|
62
|
+
"@kevisual/router": "^0.2.6",
|
|
64
63
|
"@kevisual/use-config": "^1.0.30",
|
|
65
|
-
"@opencode-ai/sdk": "^1.4.
|
|
64
|
+
"@opencode-ai/sdk": "^1.4.6",
|
|
66
65
|
"es-toolkit": "^1.45.1",
|
|
67
66
|
"form-data": "^4.0.5",
|
|
68
67
|
"nanoid": "^5.1.7",
|
package/src/git/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CustomError } from "@kevisual/router";
|
|
1
2
|
import { CNBCore, CNBCoreOptions, Result } from "../cnb-core.ts";
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -69,11 +70,12 @@ export type Content = {
|
|
|
69
70
|
html_url: string;
|
|
70
71
|
git_url: string;
|
|
71
72
|
download_url: string;
|
|
72
|
-
type:
|
|
73
|
+
type: 'lfs' | 'blob';
|
|
73
74
|
content?: string;
|
|
74
|
-
encoding?:
|
|
75
|
+
encoding?: 'base64' | 'utf-8';
|
|
75
76
|
};
|
|
76
77
|
|
|
78
|
+
|
|
77
79
|
/**
|
|
78
80
|
* Git Blob 对象
|
|
79
81
|
*/
|
|
@@ -307,7 +309,7 @@ export class Git extends CNBCore {
|
|
|
307
309
|
* @param params 查询参数
|
|
308
310
|
* @returns 文件或目录内容
|
|
309
311
|
*/
|
|
310
|
-
async getContent(repo: string, params?: GetContentParams): Promise<Result<FileListContent>> {
|
|
312
|
+
async getContent(repo: string, params?: GetContentParams): Promise<Result<FileListContent | FileContent>> {
|
|
311
313
|
const url = `/${repo}/-/git/contents`;
|
|
312
314
|
return this.get({ url, params });
|
|
313
315
|
}
|
|
@@ -319,7 +321,7 @@ export class Git extends CNBCore {
|
|
|
319
321
|
* @param params 查询参数
|
|
320
322
|
* @returns 文件内容
|
|
321
323
|
*/
|
|
322
|
-
async getContentWithPath(repo: string, filePath: string, params?: GetContentWithPathParams): Promise<Result<FileListContent>> {
|
|
324
|
+
async getContentWithPath(repo: string, filePath: string, params?: GetContentWithPathParams): Promise<Result<FileListContent | FileContent>> {
|
|
323
325
|
const url = `/${repo}/-/git/contents/${filePath}`;
|
|
324
326
|
return this.get({ url, params });
|
|
325
327
|
}
|
|
@@ -329,13 +331,12 @@ export class Git extends CNBCore {
|
|
|
329
331
|
const { recursive, ...rest } = opts;
|
|
330
332
|
const res = await this.getContentWithPath(repo, filePath, rest);
|
|
331
333
|
if (res.code !== 200) {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
console.log('列表为空', res);
|
|
334
|
+
throw new CustomError({ code: res.code, message: `获取文件列表失败: ${res.code}` });
|
|
335
|
+
}
|
|
336
|
+
if (!res.data) {
|
|
336
337
|
return [];
|
|
337
338
|
}
|
|
338
|
-
const fileList = res.data as
|
|
339
|
+
const fileList = res.data as FileListContent;
|
|
339
340
|
const entries = fileList.entries || [];
|
|
340
341
|
console.log('文件列表', fileList);
|
|
341
342
|
const treeList = entries.filter(item => item.type === 'tree');
|
|
@@ -711,7 +712,7 @@ type PutTagAnnotationsData = {
|
|
|
711
712
|
};
|
|
712
713
|
|
|
713
714
|
|
|
714
|
-
type FileListContent = {
|
|
715
|
+
export type FileListContent = {
|
|
715
716
|
type: 'blob' | 'tree';
|
|
716
717
|
size: number;
|
|
717
718
|
path: string;
|
|
@@ -725,4 +726,26 @@ type FIleEntry = {
|
|
|
725
726
|
sha: string;
|
|
726
727
|
path: string;
|
|
727
728
|
name: string;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
export type FileContent = FileContentBase64 | FileContentLFS;
|
|
732
|
+
type FileContentBase64 = {
|
|
733
|
+
type: 'blob';
|
|
734
|
+
size: number;
|
|
735
|
+
path: string;
|
|
736
|
+
name: string;
|
|
737
|
+
sha: string;
|
|
738
|
+
encoding: 'base64';
|
|
739
|
+
content: string;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
type FileContentLFS = {
|
|
743
|
+
type: 'lfs';
|
|
744
|
+
size: number;
|
|
745
|
+
path: string;
|
|
746
|
+
name: string;
|
|
747
|
+
sha: string;
|
|
748
|
+
lfs_oid: string;
|
|
749
|
+
lfs_size: number;
|
|
750
|
+
lfs_download_url: string;
|
|
728
751
|
}
|
package/src/repo/download.ts
CHANGED
|
@@ -94,6 +94,32 @@ export const downloadByCNBApi: DownloadFn = async (url, opts) => {
|
|
|
94
94
|
return { code: res.status, buffer: null };
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
*
|
|
99
|
+
* @param url
|
|
100
|
+
* @param opts
|
|
101
|
+
* @returns
|
|
102
|
+
*/
|
|
103
|
+
export const downloadByLFSUrl: DownloadFn = async (url, opts) => {
|
|
104
|
+
const headers = {
|
|
105
|
+
Accept: "application/vnd.cnb.api+json",
|
|
106
|
+
// Authorization: `${CNB_API_KEY}`
|
|
107
|
+
...(opts?.token ? { Authorization: `${opts.token}` } : {}),
|
|
108
|
+
...opts?.headers
|
|
109
|
+
}
|
|
110
|
+
const res = await fetch(url, { headers });
|
|
111
|
+
const stream = opts?.stream || false;
|
|
112
|
+
if (res.ok) {
|
|
113
|
+
if (stream) {
|
|
114
|
+
const readableStream = res.body;
|
|
115
|
+
return { code: 200, buffer: null, stream: readableStream };
|
|
116
|
+
}
|
|
117
|
+
const arrayBuffer = await res.arrayBuffer();
|
|
118
|
+
return { code: 200, buffer: Buffer.from(arrayBuffer) };
|
|
119
|
+
}
|
|
120
|
+
console.error(`下载失败 ${url}: ${res.statusText}`);
|
|
121
|
+
return { code: res.status, buffer: null };
|
|
122
|
+
}
|
|
97
123
|
|
|
98
124
|
|
|
99
125
|
export const downloadResource: DownloadFn = async (url, opts) => {
|