@kevisual/cnb 0.0.55 → 0.0.57
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/agent/routes/call/index.ts +5 -4
- package/agent/routes/cnb-env/env.ts +3 -2
- package/agent/routes/cnb-env/vscode.ts +9 -8
- package/agent/routes/index.ts +1 -0
- package/agent/routes/issues/comments.ts +18 -17
- package/agent/routes/issues/issue.ts +11 -10
- package/agent/routes/issues/list.ts +11 -10
- package/agent/routes/knowledge/ai.ts +6 -5
- package/agent/routes/labels/issue-label.ts +17 -16
- package/agent/routes/package/index.ts +2 -0
- package/agent/routes/package/package.ts +255 -0
- package/agent/routes/package/registry.ts +107 -0
- package/agent/routes/repo/list.ts +6 -5
- package/agent/routes/repo/repo-label.ts +17 -16
- package/agent/routes/repo/repo.ts +18 -17
- package/agent/routes/workspace/build.ts +7 -6
- package/agent/routes/workspace/index.ts +18 -17
- package/agent/routes/workspace/keep.ts +5 -5
- package/agent/routes/workspace/rerun.ts +60 -0
- package/agent/routes/workspace/skills.ts +2 -2
- package/dist/cli.js +927 -197
- package/dist/npc.js +981 -205
- package/dist/opencode.js +911 -203
- package/dist/routes.d.ts +235 -3
- package/dist/routes.js +903 -195
- package/package.json +1 -1
- package/src/index.ts +15 -1
- package/src/issue/index.ts +5 -2
- package/src/knowledge/index.ts +92 -5
- package/src/package/index.ts +2 -0
- package/src/package/package.ts +134 -0
- package/src/package/registry.ts +145 -0
package/dist/cli.js
CHANGED
|
@@ -21679,9 +21679,6 @@ var fromJSONSchema2 = (args = {}, opts) => {
|
|
|
21679
21679
|
return resultArgs;
|
|
21680
21680
|
};
|
|
21681
21681
|
var pickValue = ["path", "key", "id", "description", "type", "middleware", "metadata"];
|
|
21682
|
-
var tool = {
|
|
21683
|
-
schema: exports_external
|
|
21684
|
-
};
|
|
21685
21682
|
var createSkill = (skill) => {
|
|
21686
21683
|
if (skill.tags) {
|
|
21687
21684
|
const hasOpencode = skill.tags.includes("opencode");
|
|
@@ -24608,10 +24605,7 @@ class KnowledgeBase extends CNBCore {
|
|
|
24608
24605
|
}
|
|
24609
24606
|
queryKnowledgeBase(repo, data) {
|
|
24610
24607
|
const url3 = `/${repo}/-/knowledge/base/query`;
|
|
24611
|
-
|
|
24612
|
-
query: data.query
|
|
24613
|
-
};
|
|
24614
|
-
return this.post({ url: url3, data: postData });
|
|
24608
|
+
return this.post({ url: url3, data });
|
|
24615
24609
|
}
|
|
24616
24610
|
getEmbeddingModels(repo) {
|
|
24617
24611
|
const url3 = `/${repo}/-/knowledge/embedding/models`;
|
|
@@ -24625,6 +24619,30 @@ class KnowledgeBase extends CNBCore {
|
|
|
24625
24619
|
const url3 = `/${repo}/-/knowledge/base`;
|
|
24626
24620
|
return this.request({ url: url3, method: "DELETE" });
|
|
24627
24621
|
}
|
|
24622
|
+
createKnowledgeBase(repo, data) {
|
|
24623
|
+
const url3 = `/${repo}/-/knowledge/base`;
|
|
24624
|
+
return this.post({ url: url3, data });
|
|
24625
|
+
}
|
|
24626
|
+
updateKnowledgeBase(repo, data) {
|
|
24627
|
+
const url3 = `/${repo}/-/knowledge/base`;
|
|
24628
|
+
return this.put({ url: url3, data });
|
|
24629
|
+
}
|
|
24630
|
+
getEmbedding(repo, text) {
|
|
24631
|
+
const url3 = `/${repo}/-/knowledge/embedding`;
|
|
24632
|
+
return this.post({ url: url3, data: { text } });
|
|
24633
|
+
}
|
|
24634
|
+
addDocument(repo, chunksData) {
|
|
24635
|
+
const url3 = `/${repo}/-/knowledge/documents/upsert-document-with-chunks`;
|
|
24636
|
+
return this.post({ url: url3, data: chunksData });
|
|
24637
|
+
}
|
|
24638
|
+
deleteDocument(repo, paths) {
|
|
24639
|
+
const url3 = `/${repo}/-/knowledge/documents`;
|
|
24640
|
+
return this.delete({ url: url3, data: { paths } });
|
|
24641
|
+
}
|
|
24642
|
+
listDocument(repo, page = 1, page_size = 50) {
|
|
24643
|
+
const url3 = `/${repo}/-/knowledge/documents`;
|
|
24644
|
+
return this.get({ url: url3, params: { page, page_size } });
|
|
24645
|
+
}
|
|
24628
24646
|
}
|
|
24629
24647
|
|
|
24630
24648
|
// src/repo/index.ts
|
|
@@ -25225,6 +25243,88 @@ class IssueLabel extends CNBCore {
|
|
|
25225
25243
|
return this.delete({ url: url3 });
|
|
25226
25244
|
}
|
|
25227
25245
|
}
|
|
25246
|
+
// src/package/registry.ts
|
|
25247
|
+
class RegistryPackage extends CNBCore {
|
|
25248
|
+
constructor(options) {
|
|
25249
|
+
super(options);
|
|
25250
|
+
}
|
|
25251
|
+
listGroupRegistries(slug, params) {
|
|
25252
|
+
const url3 = `/${slug}/-/registries`;
|
|
25253
|
+
return this.get({
|
|
25254
|
+
url: url3,
|
|
25255
|
+
params,
|
|
25256
|
+
headers: {
|
|
25257
|
+
Accept: "application/vnd.cnb.api+json"
|
|
25258
|
+
}
|
|
25259
|
+
});
|
|
25260
|
+
}
|
|
25261
|
+
setVisibility(registry2, data) {
|
|
25262
|
+
const url3 = `/${registry2}/-/settings/set_visibility`;
|
|
25263
|
+
return this.post({
|
|
25264
|
+
url: url3,
|
|
25265
|
+
data
|
|
25266
|
+
});
|
|
25267
|
+
}
|
|
25268
|
+
remove(registry2) {
|
|
25269
|
+
const url3 = `/${registry2}`;
|
|
25270
|
+
return this.delete({ url: url3 });
|
|
25271
|
+
}
|
|
25272
|
+
}
|
|
25273
|
+
// src/package/package.ts
|
|
25274
|
+
class PackageManagement extends CNBCore {
|
|
25275
|
+
constructor(options) {
|
|
25276
|
+
super(options);
|
|
25277
|
+
}
|
|
25278
|
+
list(slug, type, params) {
|
|
25279
|
+
const url3 = `/${slug}/-/packages`;
|
|
25280
|
+
return this.get({
|
|
25281
|
+
url: url3,
|
|
25282
|
+
params: {
|
|
25283
|
+
type,
|
|
25284
|
+
...params
|
|
25285
|
+
},
|
|
25286
|
+
headers: {
|
|
25287
|
+
Accept: "application/vnd.cnb.api+json"
|
|
25288
|
+
}
|
|
25289
|
+
});
|
|
25290
|
+
}
|
|
25291
|
+
getOne(slug, type, name) {
|
|
25292
|
+
const url3 = `/${slug}/-/packages/${type}/${encodeURIComponent(name)}`;
|
|
25293
|
+
return this.get({
|
|
25294
|
+
url: url3,
|
|
25295
|
+
headers: {
|
|
25296
|
+
Accept: "application/vnd.cnb.api+json"
|
|
25297
|
+
}
|
|
25298
|
+
});
|
|
25299
|
+
}
|
|
25300
|
+
remove(slug, type, name) {
|
|
25301
|
+
const url3 = `/${slug}/-/packages/${type}/${encodeURIComponent(name)}`;
|
|
25302
|
+
return this.delete({ url: url3 });
|
|
25303
|
+
}
|
|
25304
|
+
getTag(slug, type, name, tag) {
|
|
25305
|
+
const url3 = `/${slug}/-/packages/${type}/${encodeURIComponent(name)}/tags/${encodeURIComponent(tag)}`;
|
|
25306
|
+
return this.get({
|
|
25307
|
+
url: url3,
|
|
25308
|
+
headers: {
|
|
25309
|
+
Accept: "application/vnd.cnb.api+json"
|
|
25310
|
+
}
|
|
25311
|
+
});
|
|
25312
|
+
}
|
|
25313
|
+
removeTag(slug, type, name, tag) {
|
|
25314
|
+
const url3 = `/${slug}/-/packages/${type}/${encodeURIComponent(name)}/tags/${encodeURIComponent(tag)}`;
|
|
25315
|
+
return this.delete({ url: url3 });
|
|
25316
|
+
}
|
|
25317
|
+
listTags(slug, type, name, params) {
|
|
25318
|
+
const url3 = `/${slug}/-/packages/${type}/${encodeURIComponent(name)}/tags`;
|
|
25319
|
+
return this.get({
|
|
25320
|
+
url: url3,
|
|
25321
|
+
params,
|
|
25322
|
+
headers: {
|
|
25323
|
+
Accept: "application/vnd.cnb.api+json"
|
|
25324
|
+
}
|
|
25325
|
+
});
|
|
25326
|
+
}
|
|
25327
|
+
}
|
|
25228
25328
|
// src/index.ts
|
|
25229
25329
|
class CNB extends CNBCore {
|
|
25230
25330
|
workspace;
|
|
@@ -25236,6 +25336,7 @@ class CNB extends CNBCore {
|
|
|
25236
25336
|
mission;
|
|
25237
25337
|
ai;
|
|
25238
25338
|
labels;
|
|
25339
|
+
packages;
|
|
25239
25340
|
constructor(options) {
|
|
25240
25341
|
super({ ...options, token: options.token, cookie: options.cookie, cnb: options.cnb });
|
|
25241
25342
|
this.init(options);
|
|
@@ -25258,6 +25359,10 @@ class CNB extends CNBCore {
|
|
|
25258
25359
|
repoLabel: new RepoLabel(options),
|
|
25259
25360
|
issueLabel: new IssueLabel(options)
|
|
25260
25361
|
};
|
|
25362
|
+
this.packages = {
|
|
25363
|
+
registry: new RegistryPackage(options),
|
|
25364
|
+
package: new PackageManagement(options)
|
|
25365
|
+
};
|
|
25261
25366
|
}
|
|
25262
25367
|
setToken(token) {
|
|
25263
25368
|
this.token = token;
|
|
@@ -25269,6 +25374,8 @@ class CNB extends CNBCore {
|
|
|
25269
25374
|
this.mission.token = token;
|
|
25270
25375
|
this.labels.repoLabel.token = token;
|
|
25271
25376
|
this.labels.issueLabel.token = token;
|
|
25377
|
+
this.packages.registry.token = token;
|
|
25378
|
+
this.packages.package.token = token;
|
|
25272
25379
|
}
|
|
25273
25380
|
setCookie(cookie) {
|
|
25274
25381
|
this.cookie = cookie;
|
|
@@ -25280,6 +25387,8 @@ class CNB extends CNBCore {
|
|
|
25280
25387
|
this.mission.cookie = cookie;
|
|
25281
25388
|
this.labels.repoLabel.cookie = cookie;
|
|
25282
25389
|
this.labels.issueLabel.cookie = cookie;
|
|
25390
|
+
this.packages.registry.cookie = cookie;
|
|
25391
|
+
this.packages.package.cookie = cookie;
|
|
25283
25392
|
}
|
|
25284
25393
|
getCNBVersion = getCNBVersion;
|
|
25285
25394
|
}
|
|
@@ -25647,7 +25756,7 @@ __export(exports_external2, {
|
|
|
25647
25756
|
safeEncode: () => safeEncode5,
|
|
25648
25757
|
safeDecodeAsync: () => safeDecodeAsync5,
|
|
25649
25758
|
safeDecode: () => safeDecode5,
|
|
25650
|
-
registry: () =>
|
|
25759
|
+
registry: () => registry3,
|
|
25651
25760
|
regexes: () => exports_regexes2,
|
|
25652
25761
|
regex: () => _regex2,
|
|
25653
25762
|
refine: () => refine2,
|
|
@@ -25857,7 +25966,7 @@ __export(exports_core3, {
|
|
|
25857
25966
|
safeEncode: () => safeEncode3,
|
|
25858
25967
|
safeDecodeAsync: () => safeDecodeAsync3,
|
|
25859
25968
|
safeDecode: () => safeDecode3,
|
|
25860
|
-
registry: () =>
|
|
25969
|
+
registry: () => registry3,
|
|
25861
25970
|
regexes: () => exports_regexes2,
|
|
25862
25971
|
process: () => process3,
|
|
25863
25972
|
prettifyError: () => prettifyError2,
|
|
@@ -35377,10 +35486,10 @@ class $ZodRegistry2 {
|
|
|
35377
35486
|
return this._map.has(schema);
|
|
35378
35487
|
}
|
|
35379
35488
|
}
|
|
35380
|
-
function
|
|
35489
|
+
function registry3() {
|
|
35381
35490
|
return new $ZodRegistry2;
|
|
35382
35491
|
}
|
|
35383
|
-
(_a15 = globalThis).__zod_globalRegistry ?? (_a15.__zod_globalRegistry =
|
|
35492
|
+
(_a15 = globalThis).__zod_globalRegistry ?? (_a15.__zod_globalRegistry = registry3());
|
|
35384
35493
|
var globalRegistry2 = globalThis.__zod_globalRegistry;
|
|
35385
35494
|
// ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/api.js
|
|
35386
35495
|
function _string2(Class3, params) {
|
|
@@ -37160,21 +37269,21 @@ var allProcessors2 = {
|
|
|
37160
37269
|
};
|
|
37161
37270
|
function toJSONSchema4(input, params) {
|
|
37162
37271
|
if ("_idmap" in input) {
|
|
37163
|
-
const
|
|
37272
|
+
const registry4 = input;
|
|
37164
37273
|
const ctx2 = initializeContext2({ ...params, processors: allProcessors2 });
|
|
37165
37274
|
const defs = {};
|
|
37166
|
-
for (const entry of
|
|
37275
|
+
for (const entry of registry4._idmap.entries()) {
|
|
37167
37276
|
const [_, schema] = entry;
|
|
37168
37277
|
process3(schema, ctx2);
|
|
37169
37278
|
}
|
|
37170
37279
|
const schemas = {};
|
|
37171
37280
|
const external = {
|
|
37172
|
-
registry:
|
|
37281
|
+
registry: registry4,
|
|
37173
37282
|
uri: params?.uri,
|
|
37174
37283
|
defs
|
|
37175
37284
|
};
|
|
37176
37285
|
ctx2.external = external;
|
|
37177
|
-
for (const entry of
|
|
37286
|
+
for (const entry of registry4._idmap.entries()) {
|
|
37178
37287
|
const [key, schema] = entry;
|
|
37179
37288
|
extractDefs2(ctx2, schema);
|
|
37180
37289
|
schemas[key] = finalize2(ctx2, schema);
|
|
@@ -43060,7 +43169,7 @@ class EventSourceParserStream extends TransformStream {
|
|
|
43060
43169
|
}
|
|
43061
43170
|
}
|
|
43062
43171
|
|
|
43063
|
-
// ../../node_modules/.pnpm/@ai-sdk+provider-utils@4.0.
|
|
43172
|
+
// ../../node_modules/.pnpm/@ai-sdk+provider-utils@4.0.21_zod@4.3.6/node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
43064
43173
|
function combineHeaders(...headers) {
|
|
43065
43174
|
return headers.reduce((combinedHeaders, currentHeaders) => ({
|
|
43066
43175
|
...combinedHeaders,
|
|
@@ -43324,6 +43433,9 @@ async function downloadBlob(url4, options) {
|
|
|
43324
43433
|
const response = await fetch(url4, {
|
|
43325
43434
|
signal: options == null ? undefined : options.abortSignal
|
|
43326
43435
|
});
|
|
43436
|
+
if (response.redirected) {
|
|
43437
|
+
validateDownloadUrl(response.url);
|
|
43438
|
+
}
|
|
43327
43439
|
if (!response.ok) {
|
|
43328
43440
|
throw new DownloadError({
|
|
43329
43441
|
url: url4,
|
|
@@ -43480,7 +43592,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
43480
43592
|
normalizedHeaders.set("user-agent", [currentUserAgentHeader, ...userAgentSuffixParts].filter(Boolean).join(" "));
|
|
43481
43593
|
return Object.fromEntries(normalizedHeaders.entries());
|
|
43482
43594
|
}
|
|
43483
|
-
var VERSION = "4.0.
|
|
43595
|
+
var VERSION = "4.0.21";
|
|
43484
43596
|
var getOriginalFetch = () => globalThis.fetch;
|
|
43485
43597
|
var getFromApi = async ({
|
|
43486
43598
|
url: url4,
|
|
@@ -43655,7 +43767,7 @@ function visit(def) {
|
|
|
43655
43767
|
return def;
|
|
43656
43768
|
return addAdditionalPropertiesToJsonSchema(def);
|
|
43657
43769
|
}
|
|
43658
|
-
var ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
43770
|
+
var ignoreOverride = /* @__PURE__ */ Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
43659
43771
|
var defaultOptions = {
|
|
43660
43772
|
name: undefined,
|
|
43661
43773
|
$refStrategy: "root",
|
|
@@ -44648,7 +44760,7 @@ var zod3ToJsonSchema = (schema, options) => {
|
|
|
44648
44760
|
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
44649
44761
|
return combined;
|
|
44650
44762
|
};
|
|
44651
|
-
var schemaSymbol = Symbol.for("vercel.ai.schema");
|
|
44763
|
+
var schemaSymbol = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
|
|
44652
44764
|
function lazySchema(createSchema) {
|
|
44653
44765
|
let schema;
|
|
44654
44766
|
return () => {
|
|
@@ -44955,8 +45067,8 @@ var postToApi = async ({
|
|
|
44955
45067
|
throw handleFetchError({ error: error49, url: url4, requestBodyValues: body.values });
|
|
44956
45068
|
}
|
|
44957
45069
|
};
|
|
44958
|
-
function tool2
|
|
44959
|
-
return
|
|
45070
|
+
function tool(tool2) {
|
|
45071
|
+
return tool2;
|
|
44960
45072
|
}
|
|
44961
45073
|
function createProviderToolFactoryWithOutputSchema({
|
|
44962
45074
|
id,
|
|
@@ -44972,7 +45084,7 @@ function createProviderToolFactoryWithOutputSchema({
|
|
|
44972
45084
|
onInputDelta,
|
|
44973
45085
|
onInputAvailable,
|
|
44974
45086
|
...args
|
|
44975
|
-
}) =>
|
|
45087
|
+
}) => tool({
|
|
44976
45088
|
type: "provider",
|
|
44977
45089
|
id,
|
|
44978
45090
|
args,
|
|
@@ -45108,7 +45220,7 @@ async function* executeTool({
|
|
|
45108
45220
|
}
|
|
45109
45221
|
}
|
|
45110
45222
|
|
|
45111
|
-
// ../../node_modules/.pnpm/@ai-sdk+openai-compatible@2.0.
|
|
45223
|
+
// ../../node_modules/.pnpm/@ai-sdk+openai-compatible@2.0.37_zod@4.3.6/node_modules/@ai-sdk/openai-compatible/dist/index.mjs
|
|
45112
45224
|
var openaiCompatibleErrorDataSchema = exports_external2.object({
|
|
45113
45225
|
error: exports_external2.object({
|
|
45114
45226
|
message: exports_external2.string(),
|
|
@@ -45393,20 +45505,20 @@ function prepareTools({
|
|
|
45393
45505
|
return { tools: undefined, toolChoice: undefined, toolWarnings };
|
|
45394
45506
|
}
|
|
45395
45507
|
const openaiCompatTools = [];
|
|
45396
|
-
for (const
|
|
45397
|
-
if (
|
|
45508
|
+
for (const tool2 of tools) {
|
|
45509
|
+
if (tool2.type === "provider") {
|
|
45398
45510
|
toolWarnings.push({
|
|
45399
45511
|
type: "unsupported",
|
|
45400
|
-
feature: `provider-defined tool ${
|
|
45512
|
+
feature: `provider-defined tool ${tool2.id}`
|
|
45401
45513
|
});
|
|
45402
45514
|
} else {
|
|
45403
45515
|
openaiCompatTools.push({
|
|
45404
45516
|
type: "function",
|
|
45405
45517
|
function: {
|
|
45406
|
-
name:
|
|
45407
|
-
description:
|
|
45408
|
-
parameters:
|
|
45409
|
-
...
|
|
45518
|
+
name: tool2.name,
|
|
45519
|
+
description: tool2.description,
|
|
45520
|
+
parameters: tool2.inputSchema,
|
|
45521
|
+
...tool2.strict != null ? { strict: tool2.strict } : {}
|
|
45410
45522
|
}
|
|
45411
45523
|
});
|
|
45412
45524
|
}
|
|
@@ -46555,7 +46667,7 @@ async function fileToBlob(file3) {
|
|
|
46555
46667
|
function toCamelCase(str) {
|
|
46556
46668
|
return str.replace(/[_-]([a-z])/g, (g) => g[1].toUpperCase());
|
|
46557
46669
|
}
|
|
46558
|
-
var VERSION2 = "2.0.
|
|
46670
|
+
var VERSION2 = "2.0.37";
|
|
46559
46671
|
function createOpenAICompatible(options) {
|
|
46560
46672
|
const baseURL = withoutTrailingSlash(options.baseURL);
|
|
46561
46673
|
const providerName = options.name;
|
|
@@ -46803,22 +46915,27 @@ app.route({
|
|
|
46803
46915
|
title: "列出cnb代码仓库",
|
|
46804
46916
|
summary: "列出cnb代码仓库, 可选flags参数,如 KnowledgeBase",
|
|
46805
46917
|
args: {
|
|
46806
|
-
search:
|
|
46807
|
-
|
|
46808
|
-
|
|
46918
|
+
search: exports_external2.string().optional().describe("搜索关键词"),
|
|
46919
|
+
page: exports_external2.number().optional().describe("分页页码,默认 1"),
|
|
46920
|
+
pageSize: exports_external2.number().optional().describe("每页数量,默认99"),
|
|
46921
|
+
flags: exports_external2.string().optional().describe("仓库标记,如果是知识库则填写 KnowledgeBase")
|
|
46809
46922
|
}
|
|
46810
46923
|
})
|
|
46811
46924
|
}
|
|
46812
46925
|
}).define(async (ctx) => {
|
|
46813
46926
|
const cnb = await cnbManager.getContext(ctx);
|
|
46814
46927
|
const search = ctx.query?.search;
|
|
46815
|
-
const
|
|
46928
|
+
const page = ctx.query?.page || 1;
|
|
46929
|
+
let pageSize = ctx.query?.pageSize || 99;
|
|
46816
46930
|
const flags = ctx.query?.flags;
|
|
46817
46931
|
const params = {};
|
|
46818
46932
|
if (flags) {
|
|
46819
46933
|
params.flags = flags;
|
|
46820
46934
|
}
|
|
46821
|
-
|
|
46935
|
+
if (pageSize > 99) {
|
|
46936
|
+
pageSize = 99;
|
|
46937
|
+
}
|
|
46938
|
+
const res = await cnb.repo.getRepoList({ search, page, page_size: pageSize + 1, role: "developer", ...params });
|
|
46822
46939
|
if (res.code === 200) {
|
|
46823
46940
|
const repos = res.data.map((item) => ({
|
|
46824
46941
|
name: item.name,
|
|
@@ -46826,7 +46943,9 @@ app.route({
|
|
|
46826
46943
|
description: item.description,
|
|
46827
46944
|
web_url: item.web_url
|
|
46828
46945
|
}));
|
|
46829
|
-
|
|
46946
|
+
const list = repos.slice(0, pageSize);
|
|
46947
|
+
const hasMore = repos.length > pageSize;
|
|
46948
|
+
ctx.body = { content: JSON.stringify(repos), list, hasMore, page, pageSize };
|
|
46830
46949
|
} else {
|
|
46831
46950
|
ctx.throw(500, "获取仓库列表失败");
|
|
46832
46951
|
}
|
|
@@ -46844,9 +46963,9 @@ app.route({
|
|
|
46844
46963
|
skill: "create-repo",
|
|
46845
46964
|
title: "创建代码仓库",
|
|
46846
46965
|
args: {
|
|
46847
|
-
name:
|
|
46848
|
-
visibility:
|
|
46849
|
-
description:
|
|
46966
|
+
name: exports_external2.string().describe("代码仓库名称, 如 my-user/my-repo"),
|
|
46967
|
+
visibility: exports_external2.string().describe("代码仓库可见性, public 或 private").default("public"),
|
|
46968
|
+
description: exports_external2.string().describe("代码仓库描述")
|
|
46850
46969
|
},
|
|
46851
46970
|
summary: "创建一个新的代码仓库"
|
|
46852
46971
|
})
|
|
@@ -46878,7 +46997,7 @@ app.route({
|
|
|
46878
46997
|
middleware: ["auth"],
|
|
46879
46998
|
metadata: {
|
|
46880
46999
|
args: {
|
|
46881
|
-
name:
|
|
47000
|
+
name: exports_external2.string().describe("代码仓库名称, 如 my-user/my-repo")
|
|
46882
47001
|
}
|
|
46883
47002
|
}
|
|
46884
47003
|
}).define(async (ctx) => {
|
|
@@ -46902,10 +47021,10 @@ app.route({
|
|
|
46902
47021
|
title: "在代码仓库中创建文件",
|
|
46903
47022
|
summary: `在代码仓库中创建文件, encoding 可选,默认 raw`,
|
|
46904
47023
|
args: {
|
|
46905
|
-
repoName:
|
|
46906
|
-
filePath:
|
|
46907
|
-
content:
|
|
46908
|
-
encoding:
|
|
47024
|
+
repoName: exports_external2.string().describe("代码仓库名称, 如 my-user/my-repo"),
|
|
47025
|
+
filePath: exports_external2.string().describe("文件路径, 如 src/index.ts"),
|
|
47026
|
+
content: exports_external2.string().describe("文本的字符串的内容"),
|
|
47027
|
+
encoding: exports_external2.string().describe("编码方式,如 raw").optional()
|
|
46909
47028
|
}
|
|
46910
47029
|
})
|
|
46911
47030
|
}
|
|
@@ -46937,7 +47056,7 @@ app.route({
|
|
|
46937
47056
|
skill: "delete-repo",
|
|
46938
47057
|
title: "删除代码仓库",
|
|
46939
47058
|
args: {
|
|
46940
|
-
name:
|
|
47059
|
+
name: exports_external2.string().describe("代码仓库名称")
|
|
46941
47060
|
},
|
|
46942
47061
|
summary: "删除一个代码仓库"
|
|
46943
47062
|
})
|
|
@@ -46971,11 +47090,11 @@ app.route({
|
|
|
46971
47090
|
skill: "update-repo-info",
|
|
46972
47091
|
title: "更新代码仓库信息",
|
|
46973
47092
|
args: {
|
|
46974
|
-
name:
|
|
46975
|
-
description:
|
|
46976
|
-
license:
|
|
46977
|
-
site:
|
|
46978
|
-
topics:
|
|
47093
|
+
name: exports_external2.string().describe("代码仓库名称"),
|
|
47094
|
+
description: exports_external2.string().describe("代码仓库描述"),
|
|
47095
|
+
license: exports_external2.string().describe("代码仓库许可证类型,如 MIT").optional(),
|
|
47096
|
+
site: exports_external2.string().describe("代码仓库主页链接").optional(),
|
|
47097
|
+
topics: exports_external2.array(exports_external2.string()).describe("代码仓库话题标签列表").optional()
|
|
46979
47098
|
},
|
|
46980
47099
|
summary: "更新代码仓库的信息"
|
|
46981
47100
|
})
|
|
@@ -47003,8 +47122,8 @@ app.route({
|
|
|
47003
47122
|
middleware: ["auth"],
|
|
47004
47123
|
metadata: {
|
|
47005
47124
|
args: {
|
|
47006
|
-
name:
|
|
47007
|
-
visibility:
|
|
47125
|
+
name: exports_external2.string().describe("代码仓库名称"),
|
|
47126
|
+
visibility: exports_external2.string().describe("代码仓库可见性, public 或 private 或 protected")
|
|
47008
47127
|
}
|
|
47009
47128
|
}
|
|
47010
47129
|
}).define(async (ctx) => {
|
|
@@ -47037,10 +47156,10 @@ app.route({
|
|
|
47037
47156
|
title: "查询仓库标签列表",
|
|
47038
47157
|
summary: "查询仓库的标签列表",
|
|
47039
47158
|
args: {
|
|
47040
|
-
repo:
|
|
47041
|
-
page:
|
|
47042
|
-
pageSize:
|
|
47043
|
-
keyword:
|
|
47159
|
+
repo: exports_external2.string().describe("仓库路径, 如 my-user/my-repo"),
|
|
47160
|
+
page: exports_external2.number().optional().describe("分页页码,默认 1"),
|
|
47161
|
+
pageSize: exports_external2.number().optional().describe("分页每页大小,默认 30"),
|
|
47162
|
+
keyword: exports_external2.string().optional().describe("标签搜索关键词")
|
|
47044
47163
|
}
|
|
47045
47164
|
})
|
|
47046
47165
|
}
|
|
@@ -47072,10 +47191,10 @@ app.route({
|
|
|
47072
47191
|
title: "创建仓库标签",
|
|
47073
47192
|
summary: "创建一个仓库标签",
|
|
47074
47193
|
args: {
|
|
47075
|
-
repo:
|
|
47076
|
-
name:
|
|
47077
|
-
color:
|
|
47078
|
-
description:
|
|
47194
|
+
repo: exports_external2.string().describe("仓库路径, 如 my-user/my-repo"),
|
|
47195
|
+
name: exports_external2.string().describe("标签名称"),
|
|
47196
|
+
color: exports_external2.string().describe("标签颜色,十六进制颜色码,不含 # 前缀"),
|
|
47197
|
+
description: exports_external2.string().optional().describe("标签描述")
|
|
47079
47198
|
}
|
|
47080
47199
|
})
|
|
47081
47200
|
}
|
|
@@ -47107,11 +47226,11 @@ app.route({
|
|
|
47107
47226
|
title: "更新仓库标签",
|
|
47108
47227
|
summary: "更新仓库标签信息",
|
|
47109
47228
|
args: {
|
|
47110
|
-
repo:
|
|
47111
|
-
name:
|
|
47112
|
-
color:
|
|
47113
|
-
description:
|
|
47114
|
-
newName:
|
|
47229
|
+
repo: exports_external2.string().describe("仓库路径, 如 my-user/my-repo"),
|
|
47230
|
+
name: exports_external2.string().describe("标签名称"),
|
|
47231
|
+
color: exports_external2.string().optional().describe("标签颜色,十六进制颜色码,不含 # 前缀"),
|
|
47232
|
+
description: exports_external2.string().optional().describe("标签描述"),
|
|
47233
|
+
newName: exports_external2.string().optional().describe("新标签名称")
|
|
47115
47234
|
}
|
|
47116
47235
|
})
|
|
47117
47236
|
}
|
|
@@ -47144,8 +47263,8 @@ app.route({
|
|
|
47144
47263
|
title: "删除仓库标签",
|
|
47145
47264
|
summary: "删除指定的仓库标签",
|
|
47146
47265
|
args: {
|
|
47147
|
-
repo:
|
|
47148
|
-
name:
|
|
47266
|
+
repo: exports_external2.string().describe("仓库路径, 如 my-user/my-repo"),
|
|
47267
|
+
name: exports_external2.string().describe("标签名称")
|
|
47149
47268
|
}
|
|
47150
47269
|
})
|
|
47151
47270
|
}
|
|
@@ -47300,8 +47419,8 @@ app.route({
|
|
|
47300
47419
|
tags: [],
|
|
47301
47420
|
...{
|
|
47302
47421
|
args: {
|
|
47303
|
-
repo:
|
|
47304
|
-
pipelineId:
|
|
47422
|
+
repo: exports_external2.string().describe("代码仓库路径,例如 user/repo"),
|
|
47423
|
+
pipelineId: exports_external2.string().describe("流水线ID,例如 cnb-708-1ji9sog7o-001")
|
|
47305
47424
|
}
|
|
47306
47425
|
}
|
|
47307
47426
|
}
|
|
@@ -47340,8 +47459,8 @@ app.route({
|
|
|
47340
47459
|
tags: [],
|
|
47341
47460
|
...{
|
|
47342
47461
|
args: {
|
|
47343
|
-
repo:
|
|
47344
|
-
pipelineId:
|
|
47462
|
+
repo: exports_external2.string().describe("代码仓库路径,例如 user/repo"),
|
|
47463
|
+
pipelineId: exports_external2.string().describe("流水线ID,例如 cnb-708-1ji9sog7o-001")
|
|
47345
47464
|
}
|
|
47346
47465
|
}
|
|
47347
47466
|
}
|
|
@@ -47392,11 +47511,11 @@ app.route({
|
|
|
47392
47511
|
title: "云端构建",
|
|
47393
47512
|
summary: "在云端构建代码仓库,参数包括 event, repo, branch, ref, config, env",
|
|
47394
47513
|
args: {
|
|
47395
|
-
env:
|
|
47396
|
-
event:
|
|
47397
|
-
branch:
|
|
47398
|
-
config:
|
|
47399
|
-
repo:
|
|
47514
|
+
env: exports_external2.any().optional().describe('构建环境变量,格式为 { "KEY": "VALUE" }'),
|
|
47515
|
+
event: exports_external2.string().optional().describe("触发事件类型,例如 api_trigger_event"),
|
|
47516
|
+
branch: exports_external2.string().optional().describe("分支名称,默认主分支"),
|
|
47517
|
+
config: exports_external2.string().describe("构建config文件内容,例如 cloudbuild.yaml对应的yml的内容"),
|
|
47518
|
+
repo: exports_external2.string().describe("代码仓库路径,例如 user/repo")
|
|
47400
47519
|
}
|
|
47401
47520
|
})
|
|
47402
47521
|
}
|
|
@@ -47419,6 +47538,62 @@ app.route({
|
|
|
47419
47538
|
ctx.forward(res);
|
|
47420
47539
|
}).addTo(app);
|
|
47421
47540
|
|
|
47541
|
+
// agent/routes/workspace/rerun.ts
|
|
47542
|
+
app.route({
|
|
47543
|
+
path: "cnb",
|
|
47544
|
+
key: "rerun",
|
|
47545
|
+
description: "重新启动工作区,定时任务",
|
|
47546
|
+
middleware: ["auth"],
|
|
47547
|
+
metadata: {
|
|
47548
|
+
args: {
|
|
47549
|
+
repo: zod_default.string().optional().describe("仓库名称,例如:owner/repo"),
|
|
47550
|
+
config: zod_default.string().optional().describe("工作区配置"),
|
|
47551
|
+
event: zod_default.string().optional().describe("触发事件来源,api_trigger_event")
|
|
47552
|
+
}
|
|
47553
|
+
}
|
|
47554
|
+
}).define(async (ctx) => {
|
|
47555
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
47556
|
+
const repo2 = ctx.args.repo;
|
|
47557
|
+
const config3 = ctx.args.config;
|
|
47558
|
+
const event = ctx.args.event || "api_trigger_event";
|
|
47559
|
+
const res = await cnb.workspace.list({ status: "running" });
|
|
47560
|
+
if (res.code !== 200) {
|
|
47561
|
+
ctx.throw(500, res.message || "Failed to list workspaces");
|
|
47562
|
+
}
|
|
47563
|
+
const list = res.data?.list || [];
|
|
47564
|
+
const _list = list.filter((item) => {
|
|
47565
|
+
if (repo2) {
|
|
47566
|
+
if (item.slug === repo2) {
|
|
47567
|
+
return true;
|
|
47568
|
+
}
|
|
47569
|
+
} else {
|
|
47570
|
+
if (item.slug.includes("/dev")) {
|
|
47571
|
+
return true;
|
|
47572
|
+
}
|
|
47573
|
+
}
|
|
47574
|
+
return false;
|
|
47575
|
+
});
|
|
47576
|
+
for (const item of _list) {
|
|
47577
|
+
const branch = item.branch || "main";
|
|
47578
|
+
const repo3 = item.slug;
|
|
47579
|
+
const sn = item.sn;
|
|
47580
|
+
const res2 = await cnb.workspace.stopWorkspace({ sn });
|
|
47581
|
+
if (res2.code !== 200) {
|
|
47582
|
+
ctx.throw(500, res2.message || "Failed to stop workspace");
|
|
47583
|
+
} else {
|
|
47584
|
+
console.log(`工作区 ${repo3} 停止成功,${res2.data?.buildLogUrl ? `构建日志链接: ${res2.data.buildLogUrl}` : ""}`);
|
|
47585
|
+
}
|
|
47586
|
+
if (config3) {
|
|
47587
|
+
await cnb.build.startBuild(repo3, { branch, config: config3, event });
|
|
47588
|
+
} else {
|
|
47589
|
+
await cnb.workspace.startWorkspace(repo3, { branch });
|
|
47590
|
+
}
|
|
47591
|
+
}
|
|
47592
|
+
ctx.body = {
|
|
47593
|
+
content: "工作区重新启动中"
|
|
47594
|
+
};
|
|
47595
|
+
}).addTo(app);
|
|
47596
|
+
|
|
47422
47597
|
// agent/routes/workspace/index.ts
|
|
47423
47598
|
app.route({
|
|
47424
47599
|
path: "cnb",
|
|
@@ -47432,9 +47607,9 @@ app.route({
|
|
|
47432
47607
|
title: "启动cnb工作空间",
|
|
47433
47608
|
summary: "启动cnb工作空间",
|
|
47434
47609
|
args: {
|
|
47435
|
-
repo:
|
|
47436
|
-
branch:
|
|
47437
|
-
ref:
|
|
47610
|
+
repo: exports_external2.string().describe("代码仓库路径,例如 user/repo"),
|
|
47611
|
+
branch: exports_external2.string().optional().describe("分支名称,默认主分支"),
|
|
47612
|
+
ref: exports_external2.string().optional().describe("提交引用,例如 commit sha")
|
|
47438
47613
|
}
|
|
47439
47614
|
})
|
|
47440
47615
|
}
|
|
@@ -47464,11 +47639,11 @@ app.route({
|
|
|
47464
47639
|
title: "列出cnb工作空间",
|
|
47465
47640
|
summary: "列出cnb工作空间列表,支持按状态过滤, status 可选值 running 或 closed",
|
|
47466
47641
|
args: {
|
|
47467
|
-
status:
|
|
47468
|
-
page:
|
|
47469
|
-
pageSize:
|
|
47470
|
-
slug:
|
|
47471
|
-
branch:
|
|
47642
|
+
status: exports_external2.string().optional().describe("开发环境状态,running: 运行中,closed: 已关闭和停止的"),
|
|
47643
|
+
page: exports_external2.number().optional().describe("分页页码,默认 1"),
|
|
47644
|
+
pageSize: exports_external2.number().optional().describe("分页大小,默认 20,最大 100"),
|
|
47645
|
+
slug: exports_external2.string().optional().describe("仓库路径,例如 groupname/reponame"),
|
|
47646
|
+
branch: exports_external2.string().optional().describe("分支名称")
|
|
47472
47647
|
}
|
|
47473
47648
|
})
|
|
47474
47649
|
}
|
|
@@ -47494,8 +47669,8 @@ app.route({
|
|
|
47494
47669
|
title: "获取工作空间详情",
|
|
47495
47670
|
summary: "获取工作空间详细信息",
|
|
47496
47671
|
args: {
|
|
47497
|
-
repo:
|
|
47498
|
-
sn:
|
|
47672
|
+
repo: exports_external2.string().describe("代码仓库路径,例如 user/repo"),
|
|
47673
|
+
sn: exports_external2.string().describe("工作空间流水线的 sn")
|
|
47499
47674
|
}
|
|
47500
47675
|
})
|
|
47501
47676
|
}
|
|
@@ -47524,9 +47699,9 @@ app.route({
|
|
|
47524
47699
|
title: "删除工作空间",
|
|
47525
47700
|
summary: "删除工作空间,pipelineId 和 sn 二选一",
|
|
47526
47701
|
args: {
|
|
47527
|
-
pipelineId:
|
|
47528
|
-
sn:
|
|
47529
|
-
sns:
|
|
47702
|
+
pipelineId: exports_external2.string().optional().describe("流水线 ID,优先使用"),
|
|
47703
|
+
sn: exports_external2.string().optional().describe("流水线构建号"),
|
|
47704
|
+
sns: exports_external2.array(exports_external2.string()).optional().describe("批量流水线构建号")
|
|
47530
47705
|
}
|
|
47531
47706
|
})
|
|
47532
47707
|
}
|
|
@@ -47562,8 +47737,8 @@ app.route({
|
|
|
47562
47737
|
title: "停止工作空间",
|
|
47563
47738
|
summary: "停止运行中的工作空间",
|
|
47564
47739
|
args: {
|
|
47565
|
-
pipelineId:
|
|
47566
|
-
sn:
|
|
47740
|
+
pipelineId: exports_external2.string().optional().describe("流水线 ID,优先使用"),
|
|
47741
|
+
sn: exports_external2.string().optional().describe("流水线构建号")
|
|
47567
47742
|
}
|
|
47568
47743
|
})
|
|
47569
47744
|
}
|
|
@@ -47591,9 +47766,9 @@ app.route({
|
|
|
47591
47766
|
title: "调用app应用",
|
|
47592
47767
|
summary: "调用router的应用, 参数path, key, payload",
|
|
47593
47768
|
args: {
|
|
47594
|
-
path:
|
|
47595
|
-
key:
|
|
47596
|
-
payload:
|
|
47769
|
+
path: exports_external2.string().describe("应用路径,例如 cnb"),
|
|
47770
|
+
key: exports_external2.string().optional().describe("应用key,例如 list-repos"),
|
|
47771
|
+
payload: exports_external2.object({}).optional().describe("调用参数")
|
|
47597
47772
|
}
|
|
47598
47773
|
})
|
|
47599
47774
|
}
|
|
@@ -47640,7 +47815,7 @@ app.route({
|
|
|
47640
47815
|
title: "获取当前cnb工作空间的port代理uri",
|
|
47641
47816
|
summary: "获取当前cnb工作空间的port代理uri,用于端口转发",
|
|
47642
47817
|
args: {
|
|
47643
|
-
port:
|
|
47818
|
+
port: exports_external2.number().optional().describe("端口号,默认为51515")
|
|
47644
47819
|
}
|
|
47645
47820
|
})
|
|
47646
47821
|
}
|
|
@@ -47667,11 +47842,11 @@ app.route({
|
|
|
47667
47842
|
title: "获取当前cnb工作空间的编辑器访问地址",
|
|
47668
47843
|
summary: "获取当前cnb工作空间的vscode代理uri,用于在浏览器中访问vscode,包含多种访问方式,如web、vscode、codebuddy、cursor、ssh",
|
|
47669
47844
|
args: {
|
|
47670
|
-
web:
|
|
47671
|
-
vscode:
|
|
47672
|
-
codebuddy:
|
|
47673
|
-
cursor:
|
|
47674
|
-
ssh:
|
|
47845
|
+
web: exports_external2.boolean().optional().describe("是否获取vscode web的访问uri,默认为false"),
|
|
47846
|
+
vscode: exports_external2.boolean().optional().describe("是否获取vscode的代理uri,默认为true"),
|
|
47847
|
+
codebuddy: exports_external2.boolean().optional().describe("是否获取codebuddy的代理uri,默认为false"),
|
|
47848
|
+
cursor: exports_external2.boolean().optional().describe("是否获取cursor的代理uri,默认为false"),
|
|
47849
|
+
ssh: exports_external2.boolean().optional().describe("是否获取vscode remote ssh的连接字符串,默认为false")
|
|
47675
47850
|
}
|
|
47676
47851
|
})
|
|
47677
47852
|
}
|
|
@@ -47730,7 +47905,7 @@ app.route({
|
|
|
47730
47905
|
title: "设置当前cnb工作空间的cookie环境变量",
|
|
47731
47906
|
summary: "设置当前cnb工作空间的cookie环境变量,用于界面操作定制模块功能,例子:CNBSESSION=xxxx;csrfkey=2222xxxx;",
|
|
47732
47907
|
args: {
|
|
47733
|
-
cookie:
|
|
47908
|
+
cookie: exports_external2.string().describe("cnb的cookie值")
|
|
47734
47909
|
}
|
|
47735
47910
|
})
|
|
47736
47911
|
}
|
|
@@ -48067,8 +48242,8 @@ app.route({
|
|
|
48067
48242
|
title: "调用cnb的知识库ai对话功能进行聊天",
|
|
48068
48243
|
summary: "调用cnb的知识库ai对话功能进行聊天,基于cnb提供的ai能力",
|
|
48069
48244
|
args: {
|
|
48070
|
-
question:
|
|
48071
|
-
repo:
|
|
48245
|
+
question: exports_external2.string().describe("用户输入的消息内容"),
|
|
48246
|
+
repo: exports_external2.string().optional().describe("知识库仓库ID,默认为空表示使用默认知识库")
|
|
48072
48247
|
}
|
|
48073
48248
|
})
|
|
48074
48249
|
}
|
|
@@ -48170,8 +48345,8 @@ app.route({
|
|
|
48170
48345
|
title: "调用cnb的知识库RAG查询功能进行问答",
|
|
48171
48346
|
summary: "调用cnb的知识库RAG查询功能进行问答,基于cnb提供的知识库能力",
|
|
48172
48347
|
args: {
|
|
48173
|
-
question:
|
|
48174
|
-
repo:
|
|
48348
|
+
question: exports_external2.string().describe("用户输入的消息内容"),
|
|
48349
|
+
repo: exports_external2.string().optional().describe("知识库仓库ID,默认为空表示使用默认知识库")
|
|
48175
48350
|
}
|
|
48176
48351
|
})
|
|
48177
48352
|
}
|
|
@@ -48233,13 +48408,13 @@ app.route({
|
|
|
48233
48408
|
skill: "list-issues",
|
|
48234
48409
|
title: "查询 Issue 列表",
|
|
48235
48410
|
args: {
|
|
48236
|
-
repo:
|
|
48237
|
-
state:
|
|
48238
|
-
keyword:
|
|
48239
|
-
labels:
|
|
48240
|
-
page:
|
|
48241
|
-
page_size:
|
|
48242
|
-
order_by:
|
|
48411
|
+
repo: exports_external2.string().optional().describe("代码仓库名称, 如 my-user/my-repo"),
|
|
48412
|
+
state: exports_external2.string().optional().describe("Issue 状态:open 或 closed"),
|
|
48413
|
+
keyword: exports_external2.string().optional().describe("问题搜索关键词"),
|
|
48414
|
+
labels: exports_external2.string().optional().describe("问题标签,多个用逗号分隔"),
|
|
48415
|
+
page: exports_external2.number().optional().describe("分页页码,默认: 1"),
|
|
48416
|
+
page_size: exports_external2.number().optional().describe("分页每页大小,默认: 30"),
|
|
48417
|
+
order_by: exports_external2.string().optional().describe("排序方式,如 created_at, -updated_at")
|
|
48243
48418
|
},
|
|
48244
48419
|
summary: "查询 Issue 列表"
|
|
48245
48420
|
})
|
|
@@ -48283,8 +48458,8 @@ app.route({
|
|
|
48283
48458
|
skill: "getIssue",
|
|
48284
48459
|
title: "获取 单个 Issue",
|
|
48285
48460
|
args: {
|
|
48286
|
-
repo:
|
|
48287
|
-
issueNumber:
|
|
48461
|
+
repo: exports_external2.string().optional().describe("代码仓库名称, 如 my-user/my-repo"),
|
|
48462
|
+
issueNumber: exports_external2.union([exports_external2.string(), exports_external2.number()]).describe("Issue 编号")
|
|
48288
48463
|
},
|
|
48289
48464
|
summary: "获取 单个 Issue"
|
|
48290
48465
|
})
|
|
@@ -48315,12 +48490,12 @@ app.route({
|
|
|
48315
48490
|
skill: "create-issue",
|
|
48316
48491
|
title: "创建 Issue",
|
|
48317
48492
|
args: {
|
|
48318
|
-
repo:
|
|
48319
|
-
title:
|
|
48320
|
-
body:
|
|
48321
|
-
assignees:
|
|
48322
|
-
labels:
|
|
48323
|
-
priority:
|
|
48493
|
+
repo: exports_external2.string().describe("代码仓库名称, 如 my-user/my-repo"),
|
|
48494
|
+
title: exports_external2.string().describe("Issue 标题"),
|
|
48495
|
+
body: exports_external2.string().optional().describe("Issue 描述内容"),
|
|
48496
|
+
assignees: exports_external2.array(exports_external2.string()).optional().describe("指派人列表"),
|
|
48497
|
+
labels: exports_external2.array(exports_external2.string()).optional().describe("标签列表"),
|
|
48498
|
+
priority: exports_external2.string().optional().describe("优先级")
|
|
48324
48499
|
},
|
|
48325
48500
|
summary: "创建一个新的 Issue"
|
|
48326
48501
|
})
|
|
@@ -48356,9 +48531,9 @@ app.route({
|
|
|
48356
48531
|
skill: "complete-issue",
|
|
48357
48532
|
title: "完成 CNB的任务Issue",
|
|
48358
48533
|
args: {
|
|
48359
|
-
repo:
|
|
48360
|
-
issueNumber:
|
|
48361
|
-
state:
|
|
48534
|
+
repo: exports_external2.string().describe("代码仓库名称, 如 my-user/my-repo"),
|
|
48535
|
+
issueNumber: exports_external2.union([exports_external2.string(), exports_external2.number()]).describe("Issue 编号"),
|
|
48536
|
+
state: exports_external2.string().optional().describe("Issue 状态,默认为 closed")
|
|
48362
48537
|
},
|
|
48363
48538
|
summary: "完成一个 Issue(将 state 改为 closed)"
|
|
48364
48539
|
})
|
|
@@ -48391,10 +48566,10 @@ app.route({
|
|
|
48391
48566
|
skill: "list-issue-comments",
|
|
48392
48567
|
title: "查询 Issue 评论列表",
|
|
48393
48568
|
args: {
|
|
48394
|
-
repo:
|
|
48395
|
-
issueNumber:
|
|
48396
|
-
page:
|
|
48397
|
-
page_size:
|
|
48569
|
+
repo: exports_external2.string().optional().describe("代码仓库名称, 如 my-user/my-repo"),
|
|
48570
|
+
issueNumber: exports_external2.number().describe("Issue 编号"),
|
|
48571
|
+
page: exports_external2.number().optional().describe("分页页码,默认: 1"),
|
|
48572
|
+
page_size: exports_external2.number().optional().describe("分页每页大小,默认: 30")
|
|
48398
48573
|
},
|
|
48399
48574
|
summary: "查询 Issue 评论列表"
|
|
48400
48575
|
})
|
|
@@ -48403,8 +48578,8 @@ app.route({
|
|
|
48403
48578
|
const cnb = await cnbManager.getContext(ctx);
|
|
48404
48579
|
let repo2 = ctx.query?.repo || useKey("CNB_REPO_SLUG_LOWERCASE");
|
|
48405
48580
|
const issueNumber = ctx.query?.issueNumber;
|
|
48406
|
-
const page = ctx.query?.page
|
|
48407
|
-
const page_size = ctx.query?.page_size
|
|
48581
|
+
const page = ctx.query?.page ?? 1;
|
|
48582
|
+
const page_size = ctx.query?.page_size ?? 100;
|
|
48408
48583
|
if (!repo2) {
|
|
48409
48584
|
ctx.throw(400, "缺少参数 repo");
|
|
48410
48585
|
}
|
|
@@ -48430,10 +48605,10 @@ app.route({
|
|
|
48430
48605
|
skill: "create-issue-comment",
|
|
48431
48606
|
title: "创建 Issue 评论",
|
|
48432
48607
|
args: {
|
|
48433
|
-
repo:
|
|
48434
|
-
issueNumber:
|
|
48435
|
-
body:
|
|
48436
|
-
clearAt:
|
|
48608
|
+
repo: exports_external2.string().optional().describe("代码仓库名称, 如 my-user/my-repo"),
|
|
48609
|
+
issueNumber: exports_external2.number().describe("Issue 编号"),
|
|
48610
|
+
body: exports_external2.string().describe("评论内容"),
|
|
48611
|
+
clearAt: exports_external2.boolean().optional().describe("是否清除评论内容中的 @ 提及,默认: true")
|
|
48437
48612
|
},
|
|
48438
48613
|
summary: "创建 Issue 评论"
|
|
48439
48614
|
})
|
|
@@ -48470,9 +48645,9 @@ app.route({
|
|
|
48470
48645
|
skill: "get-issue-comment",
|
|
48471
48646
|
title: "获取 Issue 评论",
|
|
48472
48647
|
args: {
|
|
48473
|
-
repo:
|
|
48474
|
-
issueNumber:
|
|
48475
|
-
commentId:
|
|
48648
|
+
repo: exports_external2.string().optional().describe("代码仓库名称, 如 my-user/my-repo"),
|
|
48649
|
+
issueNumber: exports_external2.number().describe("Issue 编号"),
|
|
48650
|
+
commentId: exports_external2.number().describe("评论 ID")
|
|
48476
48651
|
},
|
|
48477
48652
|
summary: "获取 Issue 评论"
|
|
48478
48653
|
})
|
|
@@ -48505,11 +48680,11 @@ app.route({
|
|
|
48505
48680
|
skill: "update-issue-comment",
|
|
48506
48681
|
title: "修改 Issue 评论",
|
|
48507
48682
|
args: {
|
|
48508
|
-
repo:
|
|
48509
|
-
issueNumber:
|
|
48510
|
-
commentId:
|
|
48511
|
-
body:
|
|
48512
|
-
clearAt:
|
|
48683
|
+
repo: exports_external2.string().optional().describe("代码仓库名称, 如 my-user/my-repo"),
|
|
48684
|
+
issueNumber: exports_external2.number().describe("Issue 编号"),
|
|
48685
|
+
commentId: exports_external2.number().describe("评论 ID"),
|
|
48686
|
+
body: exports_external2.string().describe("评论内容"),
|
|
48687
|
+
clearAt: exports_external2.boolean().optional().describe("是否清除评论内容中的 @ 提及,默认: true")
|
|
48513
48688
|
},
|
|
48514
48689
|
summary: "修改 Issue 评论"
|
|
48515
48690
|
})
|
|
@@ -49425,7 +49600,7 @@ app.route({
|
|
|
49425
49600
|
};
|
|
49426
49601
|
}).addTo(app);
|
|
49427
49602
|
|
|
49428
|
-
// ../../node_modules/.pnpm/@ai-sdk+gateway@3.0.
|
|
49603
|
+
// ../../node_modules/.pnpm/@ai-sdk+gateway@3.0.77_zod@4.3.6/node_modules/@ai-sdk/gateway/dist/index.mjs
|
|
49429
49604
|
var import_oidc = __toESM(require_dist(), 1);
|
|
49430
49605
|
var import_oidc2 = __toESM(require_dist(), 1);
|
|
49431
49606
|
var marker17 = "vercel.ai.gateway.error";
|
|
@@ -50491,7 +50666,7 @@ async function getVercelRequestId() {
|
|
|
50491
50666
|
var _a92;
|
|
50492
50667
|
return (_a92 = import_oidc.getContext().headers) == null ? undefined : _a92["x-vercel-id"];
|
|
50493
50668
|
}
|
|
50494
|
-
var VERSION3 = "3.0.
|
|
50669
|
+
var VERSION3 = "3.0.77";
|
|
50495
50670
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
50496
50671
|
function createGatewayProvider(options = {}) {
|
|
50497
50672
|
var _a92, _b92;
|
|
@@ -50647,7 +50822,7 @@ async function getGatewayAuthToken(options) {
|
|
|
50647
50822
|
};
|
|
50648
50823
|
}
|
|
50649
50824
|
|
|
50650
|
-
// ../../node_modules/.pnpm/ai@6.0.
|
|
50825
|
+
// ../../node_modules/.pnpm/ai@6.0.134_zod@4.3.6/node_modules/ai/dist/index.mjs
|
|
50651
50826
|
var import_api = __toESM(require_src(), 1);
|
|
50652
50827
|
var import_api2 = __toESM(require_src(), 1);
|
|
50653
50828
|
var __defProp4 = Object.defineProperty;
|
|
@@ -51218,7 +51393,7 @@ function detectMediaType({
|
|
|
51218
51393
|
}
|
|
51219
51394
|
return;
|
|
51220
51395
|
}
|
|
51221
|
-
var VERSION4 = "6.0.
|
|
51396
|
+
var VERSION4 = "6.0.134";
|
|
51222
51397
|
var download = async ({
|
|
51223
51398
|
url: url4,
|
|
51224
51399
|
maxBytes,
|
|
@@ -51232,6 +51407,9 @@ var download = async ({
|
|
|
51232
51407
|
headers: withUserAgentSuffix({}, `ai-sdk/${VERSION4}`, getRuntimeEnvironmentUserAgent()),
|
|
51233
51408
|
signal: abortSignal
|
|
51234
51409
|
});
|
|
51410
|
+
if (response.redirected) {
|
|
51411
|
+
validateDownloadUrl(response.url);
|
|
51412
|
+
}
|
|
51235
51413
|
if (!response.ok) {
|
|
51236
51414
|
throw new DownloadError({
|
|
51237
51415
|
url: urlText,
|
|
@@ -51635,7 +51813,7 @@ async function createToolModelOutput({
|
|
|
51635
51813
|
toolCallId,
|
|
51636
51814
|
input,
|
|
51637
51815
|
output,
|
|
51638
|
-
tool:
|
|
51816
|
+
tool: tool2,
|
|
51639
51817
|
errorMode
|
|
51640
51818
|
}) {
|
|
51641
51819
|
if (errorMode === "text") {
|
|
@@ -51643,8 +51821,8 @@ async function createToolModelOutput({
|
|
|
51643
51821
|
} else if (errorMode === "json") {
|
|
51644
51822
|
return { type: "error-json", value: toJSONValue(output) };
|
|
51645
51823
|
}
|
|
51646
|
-
if (
|
|
51647
|
-
return await
|
|
51824
|
+
if (tool2 == null ? undefined : tool2.toModelOutput) {
|
|
51825
|
+
return await tool2.toModelOutput({ toolCallId, input, output });
|
|
51648
51826
|
}
|
|
51649
51827
|
return typeof output === "string" ? { type: "text", value: output } : { type: "json", value: toJSONValue(output) };
|
|
51650
51828
|
}
|
|
@@ -51758,8 +51936,8 @@ async function prepareToolsAndToolChoice({
|
|
|
51758
51936
|
}
|
|
51759
51937
|
const filteredTools = activeTools != null ? Object.entries(tools).filter(([name21]) => activeTools.includes(name21)) : Object.entries(tools);
|
|
51760
51938
|
const languageModelTools = [];
|
|
51761
|
-
for (const [name21,
|
|
51762
|
-
const toolType =
|
|
51939
|
+
for (const [name21, tool2] of filteredTools) {
|
|
51940
|
+
const toolType = tool2.type;
|
|
51763
51941
|
switch (toolType) {
|
|
51764
51942
|
case undefined:
|
|
51765
51943
|
case "dynamic":
|
|
@@ -51767,19 +51945,19 @@ async function prepareToolsAndToolChoice({
|
|
|
51767
51945
|
languageModelTools.push({
|
|
51768
51946
|
type: "function",
|
|
51769
51947
|
name: name21,
|
|
51770
|
-
description:
|
|
51771
|
-
inputSchema: await asSchema(
|
|
51772
|
-
...
|
|
51773
|
-
providerOptions:
|
|
51774
|
-
...
|
|
51948
|
+
description: tool2.description,
|
|
51949
|
+
inputSchema: await asSchema(tool2.inputSchema).jsonSchema,
|
|
51950
|
+
...tool2.inputExamples != null ? { inputExamples: tool2.inputExamples } : {},
|
|
51951
|
+
providerOptions: tool2.providerOptions,
|
|
51952
|
+
...tool2.strict != null ? { strict: tool2.strict } : {}
|
|
51775
51953
|
});
|
|
51776
51954
|
break;
|
|
51777
51955
|
case "provider":
|
|
51778
51956
|
languageModelTools.push({
|
|
51779
51957
|
type: "provider",
|
|
51780
51958
|
name: name21,
|
|
51781
|
-
id:
|
|
51782
|
-
args:
|
|
51959
|
+
id: tool2.id,
|
|
51960
|
+
args: tool2.args
|
|
51783
51961
|
});
|
|
51784
51962
|
break;
|
|
51785
51963
|
default: {
|
|
@@ -52545,8 +52723,8 @@ async function executeToolCall({
|
|
|
52545
52723
|
onToolCallFinish
|
|
52546
52724
|
}) {
|
|
52547
52725
|
const { toolName, toolCallId, input } = toolCall;
|
|
52548
|
-
const
|
|
52549
|
-
if ((
|
|
52726
|
+
const tool2 = tools == null ? undefined : tools[toolName];
|
|
52727
|
+
if ((tool2 == null ? undefined : tool2.execute) == null) {
|
|
52550
52728
|
return;
|
|
52551
52729
|
}
|
|
52552
52730
|
const baseCallbackEvent = {
|
|
@@ -52582,7 +52760,7 @@ async function executeToolCall({
|
|
|
52582
52760
|
const startTime = now();
|
|
52583
52761
|
try {
|
|
52584
52762
|
const stream = executeTool({
|
|
52585
|
-
execute:
|
|
52763
|
+
execute: tool2.execute.bind(tool2),
|
|
52586
52764
|
input,
|
|
52587
52765
|
options: {
|
|
52588
52766
|
toolCallId,
|
|
@@ -52621,7 +52799,7 @@ async function executeToolCall({
|
|
|
52621
52799
|
toolName,
|
|
52622
52800
|
input,
|
|
52623
52801
|
error: error49,
|
|
52624
|
-
dynamic:
|
|
52802
|
+
dynamic: tool2.type === "dynamic",
|
|
52625
52803
|
...toolCall.providerMetadata != null ? { providerMetadata: toolCall.providerMetadata } : {}
|
|
52626
52804
|
};
|
|
52627
52805
|
}
|
|
@@ -52651,7 +52829,7 @@ async function executeToolCall({
|
|
|
52651
52829
|
toolName,
|
|
52652
52830
|
input,
|
|
52653
52831
|
output,
|
|
52654
|
-
dynamic:
|
|
52832
|
+
dynamic: tool2.type === "dynamic",
|
|
52655
52833
|
...toolCall.providerMetadata != null ? { providerMetadata: toolCall.providerMetadata } : {}
|
|
52656
52834
|
};
|
|
52657
52835
|
}
|
|
@@ -52693,18 +52871,18 @@ var DefaultGeneratedFile = class {
|
|
|
52693
52871
|
}
|
|
52694
52872
|
};
|
|
52695
52873
|
async function isApprovalNeeded({
|
|
52696
|
-
tool:
|
|
52874
|
+
tool: tool2,
|
|
52697
52875
|
toolCall,
|
|
52698
52876
|
messages,
|
|
52699
52877
|
experimental_context
|
|
52700
52878
|
}) {
|
|
52701
|
-
if (
|
|
52879
|
+
if (tool2.needsApproval == null) {
|
|
52702
52880
|
return false;
|
|
52703
52881
|
}
|
|
52704
|
-
if (typeof
|
|
52705
|
-
return
|
|
52882
|
+
if (typeof tool2.needsApproval === "boolean") {
|
|
52883
|
+
return tool2.needsApproval;
|
|
52706
52884
|
}
|
|
52707
|
-
return await
|
|
52885
|
+
return await tool2.needsApproval(toolCall.input, {
|
|
52708
52886
|
toolCallId: toolCall.toolCallId,
|
|
52709
52887
|
messages,
|
|
52710
52888
|
experimental_context
|
|
@@ -53439,8 +53617,8 @@ async function doParseToolCall({
|
|
|
53439
53617
|
tools
|
|
53440
53618
|
}) {
|
|
53441
53619
|
const toolName = toolCall.toolName;
|
|
53442
|
-
const
|
|
53443
|
-
if (
|
|
53620
|
+
const tool2 = tools[toolName];
|
|
53621
|
+
if (tool2 == null) {
|
|
53444
53622
|
if (toolCall.providerExecuted && toolCall.dynamic) {
|
|
53445
53623
|
return await parseProviderExecutedDynamicToolCall(toolCall);
|
|
53446
53624
|
}
|
|
@@ -53449,7 +53627,7 @@ async function doParseToolCall({
|
|
|
53449
53627
|
availableTools: Object.keys(tools)
|
|
53450
53628
|
});
|
|
53451
53629
|
}
|
|
53452
|
-
const schema = asSchema(
|
|
53630
|
+
const schema = asSchema(tool2.inputSchema);
|
|
53453
53631
|
const parseResult = toolCall.input.trim() === "" ? await safeValidateTypes({ value: {}, schema }) : await safeParseJSON({ text: toolCall.input, schema });
|
|
53454
53632
|
if (parseResult.success === false) {
|
|
53455
53633
|
throw new InvalidToolInputError({
|
|
@@ -53458,7 +53636,7 @@ async function doParseToolCall({
|
|
|
53458
53636
|
cause: parseResult.error
|
|
53459
53637
|
});
|
|
53460
53638
|
}
|
|
53461
|
-
return
|
|
53639
|
+
return tool2.type === "dynamic" ? {
|
|
53462
53640
|
type: "tool-call",
|
|
53463
53641
|
toolCallId: toolCall.toolCallId,
|
|
53464
53642
|
toolName: toolCall.toolName,
|
|
@@ -53466,7 +53644,7 @@ async function doParseToolCall({
|
|
|
53466
53644
|
providerExecuted: toolCall.providerExecuted,
|
|
53467
53645
|
providerMetadata: toolCall.providerMetadata,
|
|
53468
53646
|
dynamic: true,
|
|
53469
|
-
title:
|
|
53647
|
+
title: tool2.title
|
|
53470
53648
|
} : {
|
|
53471
53649
|
type: "tool-call",
|
|
53472
53650
|
toolCallId: toolCall.toolCallId,
|
|
@@ -53474,7 +53652,7 @@ async function doParseToolCall({
|
|
|
53474
53652
|
input: parseResult.value,
|
|
53475
53653
|
providerExecuted: toolCall.providerExecuted,
|
|
53476
53654
|
providerMetadata: toolCall.providerMetadata,
|
|
53477
|
-
title:
|
|
53655
|
+
title: tool2.title
|
|
53478
53656
|
};
|
|
53479
53657
|
}
|
|
53480
53658
|
var DefaultStepResult = class {
|
|
@@ -53814,7 +53992,7 @@ async function generateText({
|
|
|
53814
53992
|
}),
|
|
53815
53993
|
tracer,
|
|
53816
53994
|
fn: async (span) => {
|
|
53817
|
-
var _a21, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
53995
|
+
var _a21, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
53818
53996
|
const initialMessages = initialPrompt.messages;
|
|
53819
53997
|
const responseMessages = [];
|
|
53820
53998
|
const { approvedToolApprovals, deniedToolApprovals } = collectToolApprovals({ messages: initialMessages });
|
|
@@ -53978,7 +54156,7 @@ async function generateText({
|
|
|
53978
54156
|
input: () => stringifyForTelemetry(promptMessages)
|
|
53979
54157
|
},
|
|
53980
54158
|
"ai.prompt.tools": {
|
|
53981
|
-
input: () => stepTools == null ? undefined : stepTools.map((
|
|
54159
|
+
input: () => stepTools == null ? undefined : stepTools.map((tool2) => JSON.stringify(tool2))
|
|
53982
54160
|
},
|
|
53983
54161
|
"ai.prompt.toolChoice": {
|
|
53984
54162
|
input: () => stepToolChoice != null ? JSON.stringify(stepToolChoice) : undefined
|
|
@@ -54014,6 +54192,7 @@ async function generateText({
|
|
|
54014
54192
|
headers: (_g2 = result.response) == null ? undefined : _g2.headers,
|
|
54015
54193
|
body: (_h2 = result.response) == null ? undefined : _h2.body
|
|
54016
54194
|
};
|
|
54195
|
+
const usage = asLanguageModelUsage(result.usage);
|
|
54017
54196
|
span2.setAttributes(await selectTelemetryAttributes({
|
|
54018
54197
|
telemetry,
|
|
54019
54198
|
attributes: {
|
|
@@ -54034,8 +54213,16 @@ async function generateText({
|
|
|
54034
54213
|
"ai.response.model": responseData.modelId,
|
|
54035
54214
|
"ai.response.timestamp": responseData.timestamp.toISOString(),
|
|
54036
54215
|
"ai.response.providerMetadata": JSON.stringify(result.providerMetadata),
|
|
54037
|
-
"ai.usage.
|
|
54038
|
-
"ai.usage.
|
|
54216
|
+
"ai.usage.inputTokens": result.usage.inputTokens.total,
|
|
54217
|
+
"ai.usage.inputTokenDetails.noCacheTokens": result.usage.inputTokens.noCache,
|
|
54218
|
+
"ai.usage.inputTokenDetails.cacheReadTokens": result.usage.inputTokens.cacheRead,
|
|
54219
|
+
"ai.usage.inputTokenDetails.cacheWriteTokens": result.usage.inputTokens.cacheWrite,
|
|
54220
|
+
"ai.usage.outputTokens": result.usage.outputTokens.total,
|
|
54221
|
+
"ai.usage.outputTokenDetails.textTokens": result.usage.outputTokens.text,
|
|
54222
|
+
"ai.usage.outputTokenDetails.reasoningTokens": result.usage.outputTokens.reasoning,
|
|
54223
|
+
"ai.usage.totalTokens": usage.totalTokens,
|
|
54224
|
+
"ai.usage.reasoningTokens": result.usage.outputTokens.reasoning,
|
|
54225
|
+
"ai.usage.cachedInputTokens": result.usage.inputTokens.cacheRead,
|
|
54039
54226
|
"gen_ai.response.finish_reasons": [
|
|
54040
54227
|
result.finishReason.unified
|
|
54041
54228
|
],
|
|
@@ -54061,12 +54248,12 @@ async function generateText({
|
|
|
54061
54248
|
if (toolCall.invalid) {
|
|
54062
54249
|
continue;
|
|
54063
54250
|
}
|
|
54064
|
-
const
|
|
54065
|
-
if (
|
|
54251
|
+
const tool2 = tools == null ? undefined : tools[toolCall.toolName];
|
|
54252
|
+
if (tool2 == null) {
|
|
54066
54253
|
continue;
|
|
54067
54254
|
}
|
|
54068
|
-
if ((
|
|
54069
|
-
await
|
|
54255
|
+
if ((tool2 == null ? undefined : tool2.onInputAvailable) != null) {
|
|
54256
|
+
await tool2.onInputAvailable({
|
|
54070
54257
|
input: toolCall.input,
|
|
54071
54258
|
toolCallId: toolCall.toolCallId,
|
|
54072
54259
|
messages: stepInputMessages,
|
|
@@ -54075,7 +54262,7 @@ async function generateText({
|
|
|
54075
54262
|
});
|
|
54076
54263
|
}
|
|
54077
54264
|
if (await isApprovalNeeded({
|
|
54078
|
-
tool:
|
|
54265
|
+
tool: tool2,
|
|
54079
54266
|
toolCall,
|
|
54080
54267
|
messages: stepInputMessages,
|
|
54081
54268
|
experimental_context
|
|
@@ -54124,8 +54311,8 @@ async function generateText({
|
|
|
54124
54311
|
for (const toolCall of stepToolCalls) {
|
|
54125
54312
|
if (!toolCall.providerExecuted)
|
|
54126
54313
|
continue;
|
|
54127
|
-
const
|
|
54128
|
-
if ((
|
|
54314
|
+
const tool2 = tools == null ? undefined : tools[toolCall.toolName];
|
|
54315
|
+
if ((tool2 == null ? undefined : tool2.type) === "provider" && tool2.supportsDeferredResults) {
|
|
54129
54316
|
const hasResultInResponse = currentModelResponse.content.some((part) => part.type === "tool-result" && part.toolCallId === toolCall.toolCallId);
|
|
54130
54317
|
if (!hasResultInResponse) {
|
|
54131
54318
|
pendingDeferredToolCalls.set(toolCall.toolCallId, {
|
|
@@ -54204,9 +54391,7 @@ async function generateText({
|
|
|
54204
54391
|
return toolCalls == null ? undefined : JSON.stringify(toolCalls);
|
|
54205
54392
|
}
|
|
54206
54393
|
},
|
|
54207
|
-
"ai.response.providerMetadata": JSON.stringify(currentModelResponse.providerMetadata)
|
|
54208
|
-
"ai.usage.promptTokens": currentModelResponse.usage.inputTokens.total,
|
|
54209
|
-
"ai.usage.completionTokens": currentModelResponse.usage.outputTokens.total
|
|
54394
|
+
"ai.response.providerMetadata": JSON.stringify(currentModelResponse.providerMetadata)
|
|
54210
54395
|
}
|
|
54211
54396
|
}));
|
|
54212
54397
|
const lastStep = steps[steps.length - 1];
|
|
@@ -54219,6 +54404,21 @@ async function generateText({
|
|
|
54219
54404
|
reasoningTokens: undefined,
|
|
54220
54405
|
cachedInputTokens: undefined
|
|
54221
54406
|
});
|
|
54407
|
+
span.setAttributes(await selectTelemetryAttributes({
|
|
54408
|
+
telemetry,
|
|
54409
|
+
attributes: {
|
|
54410
|
+
"ai.usage.inputTokens": totalUsage.inputTokens,
|
|
54411
|
+
"ai.usage.inputTokenDetails.noCacheTokens": (_n = totalUsage.inputTokenDetails) == null ? undefined : _n.noCacheTokens,
|
|
54412
|
+
"ai.usage.inputTokenDetails.cacheReadTokens": (_o = totalUsage.inputTokenDetails) == null ? undefined : _o.cacheReadTokens,
|
|
54413
|
+
"ai.usage.inputTokenDetails.cacheWriteTokens": (_p = totalUsage.inputTokenDetails) == null ? undefined : _p.cacheWriteTokens,
|
|
54414
|
+
"ai.usage.outputTokens": totalUsage.outputTokens,
|
|
54415
|
+
"ai.usage.outputTokenDetails.textTokens": (_q = totalUsage.outputTokenDetails) == null ? undefined : _q.textTokens,
|
|
54416
|
+
"ai.usage.outputTokenDetails.reasoningTokens": (_r = totalUsage.outputTokenDetails) == null ? undefined : _r.reasoningTokens,
|
|
54417
|
+
"ai.usage.totalTokens": totalUsage.totalTokens,
|
|
54418
|
+
"ai.usage.reasoningTokens": (_s = totalUsage.outputTokenDetails) == null ? undefined : _s.reasoningTokens,
|
|
54419
|
+
"ai.usage.cachedInputTokens": (_t = totalUsage.inputTokenDetails) == null ? undefined : _t.cacheReadTokens
|
|
54420
|
+
}
|
|
54421
|
+
}));
|
|
54222
54422
|
await notify({
|
|
54223
54423
|
event: {
|
|
54224
54424
|
stepNumber: lastStep.stepNumber,
|
|
@@ -54418,8 +54618,8 @@ function asContent({
|
|
|
54418
54618
|
case "tool-result": {
|
|
54419
54619
|
const toolCall = toolCalls.find((toolCall2) => toolCall2.toolCallId === part.toolCallId);
|
|
54420
54620
|
if (toolCall == null) {
|
|
54421
|
-
const
|
|
54422
|
-
const supportsDeferredResults = (
|
|
54621
|
+
const tool2 = tools == null ? undefined : tools[part.toolName];
|
|
54622
|
+
const supportsDeferredResults = (tool2 == null ? undefined : tool2.type) === "provider" && tool2.supportsDeferredResults;
|
|
54423
54623
|
if (!supportsDeferredResults) {
|
|
54424
54624
|
throw new Error(`Tool call ${part.toolCallId} not found.`);
|
|
54425
54625
|
}
|
|
@@ -54431,7 +54631,8 @@ function asContent({
|
|
|
54431
54631
|
input: undefined,
|
|
54432
54632
|
error: part.result,
|
|
54433
54633
|
providerExecuted: true,
|
|
54434
|
-
dynamic: part.dynamic
|
|
54634
|
+
dynamic: part.dynamic,
|
|
54635
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
|
|
54435
54636
|
});
|
|
54436
54637
|
} else {
|
|
54437
54638
|
contentParts.push({
|
|
@@ -54441,7 +54642,8 @@ function asContent({
|
|
|
54441
54642
|
input: undefined,
|
|
54442
54643
|
output: part.result,
|
|
54443
54644
|
providerExecuted: true,
|
|
54444
|
-
dynamic: part.dynamic
|
|
54645
|
+
dynamic: part.dynamic,
|
|
54646
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
|
|
54445
54647
|
});
|
|
54446
54648
|
}
|
|
54447
54649
|
break;
|
|
@@ -54454,7 +54656,8 @@ function asContent({
|
|
|
54454
54656
|
input: toolCall.input,
|
|
54455
54657
|
error: part.result,
|
|
54456
54658
|
providerExecuted: true,
|
|
54457
|
-
dynamic: toolCall.dynamic
|
|
54659
|
+
dynamic: toolCall.dynamic,
|
|
54660
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
|
|
54458
54661
|
});
|
|
54459
54662
|
} else {
|
|
54460
54663
|
contentParts.push({
|
|
@@ -54464,7 +54667,8 @@ function asContent({
|
|
|
54464
54667
|
input: toolCall.input,
|
|
54465
54668
|
output: part.result,
|
|
54466
54669
|
providerExecuted: true,
|
|
54467
|
-
dynamic: toolCall.dynamic
|
|
54670
|
+
dynamic: toolCall.dynamic,
|
|
54671
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
|
|
54468
54672
|
});
|
|
54469
54673
|
}
|
|
54470
54674
|
break;
|
|
@@ -54570,6 +54774,7 @@ var uiMessageChunkSchema = lazySchema(() => zodSchema(exports_external2.union([
|
|
|
54570
54774
|
toolCallId: exports_external2.string(),
|
|
54571
54775
|
output: exports_external2.unknown(),
|
|
54572
54776
|
providerExecuted: exports_external2.boolean().optional(),
|
|
54777
|
+
providerMetadata: providerMetadataSchema.optional(),
|
|
54573
54778
|
dynamic: exports_external2.boolean().optional(),
|
|
54574
54779
|
preliminary: exports_external2.boolean().optional()
|
|
54575
54780
|
}),
|
|
@@ -54578,6 +54783,7 @@ var uiMessageChunkSchema = lazySchema(() => zodSchema(exports_external2.union([
|
|
|
54578
54783
|
toolCallId: exports_external2.string(),
|
|
54579
54784
|
errorText: exports_external2.string(),
|
|
54580
54785
|
providerExecuted: exports_external2.boolean().optional(),
|
|
54786
|
+
providerMetadata: providerMetadataSchema.optional(),
|
|
54581
54787
|
dynamic: exports_external2.boolean().optional()
|
|
54582
54788
|
}),
|
|
54583
54789
|
exports_external2.strictObject({
|
|
@@ -54776,6 +54982,7 @@ var uiMessagesSchema = lazySchema(() => zodSchema(exports_external2.array(export
|
|
|
54776
54982
|
output: exports_external2.unknown(),
|
|
54777
54983
|
errorText: exports_external2.never().optional(),
|
|
54778
54984
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
54985
|
+
resultProviderMetadata: providerMetadataSchema.optional(),
|
|
54779
54986
|
preliminary: exports_external2.boolean().optional(),
|
|
54780
54987
|
approval: exports_external2.object({
|
|
54781
54988
|
id: exports_external2.string(),
|
|
@@ -54794,6 +55001,7 @@ var uiMessagesSchema = lazySchema(() => zodSchema(exports_external2.array(export
|
|
|
54794
55001
|
output: exports_external2.never().optional(),
|
|
54795
55002
|
errorText: exports_external2.string(),
|
|
54796
55003
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
55004
|
+
resultProviderMetadata: providerMetadataSchema.optional(),
|
|
54797
55005
|
approval: exports_external2.object({
|
|
54798
55006
|
id: exports_external2.string(),
|
|
54799
55007
|
approved: exports_external2.literal(true),
|
|
@@ -54877,6 +55085,7 @@ var uiMessagesSchema = lazySchema(() => zodSchema(exports_external2.array(export
|
|
|
54877
55085
|
output: exports_external2.unknown(),
|
|
54878
55086
|
errorText: exports_external2.never().optional(),
|
|
54879
55087
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
55088
|
+
resultProviderMetadata: providerMetadataSchema.optional(),
|
|
54880
55089
|
preliminary: exports_external2.boolean().optional(),
|
|
54881
55090
|
approval: exports_external2.object({
|
|
54882
55091
|
id: exports_external2.string(),
|
|
@@ -54894,6 +55103,7 @@ var uiMessagesSchema = lazySchema(() => zodSchema(exports_external2.array(export
|
|
|
54894
55103
|
output: exports_external2.never().optional(),
|
|
54895
55104
|
errorText: exports_external2.string(),
|
|
54896
55105
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
55106
|
+
resultProviderMetadata: providerMetadataSchema.optional(),
|
|
54897
55107
|
approval: exports_external2.object({
|
|
54898
55108
|
id: exports_external2.string(),
|
|
54899
55109
|
approved: exports_external2.literal(true),
|
|
@@ -55280,7 +55490,7 @@ var createTool = async (app2, message) => {
|
|
|
55280
55490
|
console.error(`未找到路径 ${message.path} 和 key ${message.key} 的路由`);
|
|
55281
55491
|
return null;
|
|
55282
55492
|
}
|
|
55283
|
-
const _tool =
|
|
55493
|
+
const _tool = tool({
|
|
55284
55494
|
description: route?.metadata?.summary || route?.description || "无描述",
|
|
55285
55495
|
inputSchema: zod_default.object({
|
|
55286
55496
|
...route.metadata?.args
|
|
@@ -55413,6 +55623,504 @@ app.route({
|
|
|
55413
55623
|
ctx.forward(res);
|
|
55414
55624
|
}).addTo(app);
|
|
55415
55625
|
|
|
55626
|
+
// agent/routes/labels/issue-label.ts
|
|
55627
|
+
app.route({
|
|
55628
|
+
path: "cnb",
|
|
55629
|
+
key: "list-issue-labels",
|
|
55630
|
+
description: "查询 Issue 的标签列表",
|
|
55631
|
+
middleware: ["auth"],
|
|
55632
|
+
metadata: {
|
|
55633
|
+
tags: ["opencode"],
|
|
55634
|
+
...createSkill({
|
|
55635
|
+
skill: "list-issue-labels",
|
|
55636
|
+
title: "查询 Issue 标签列表",
|
|
55637
|
+
summary: "查询 Issue 的标签列表",
|
|
55638
|
+
args: {
|
|
55639
|
+
repo: exports_external2.string().optional().describe("仓库路径, 如 my-user/my-repo"),
|
|
55640
|
+
issueNumber: exports_external2.number().describe("Issue 编号"),
|
|
55641
|
+
page: exports_external2.number().optional().describe("分页页码,默认 1"),
|
|
55642
|
+
pageSize: exports_external2.number().optional().describe("分页每页大小,默认 30")
|
|
55643
|
+
}
|
|
55644
|
+
})
|
|
55645
|
+
}
|
|
55646
|
+
}).define(async (ctx) => {
|
|
55647
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
55648
|
+
let repo2 = ctx.query?.repo || useKey("CNB_REPO_SLUG_LOWERCASE");
|
|
55649
|
+
const issueNumber = ctx.query?.issueNumber;
|
|
55650
|
+
const page = ctx.query?.page;
|
|
55651
|
+
const pageSize = ctx.query?.pageSize;
|
|
55652
|
+
if (!repo2) {
|
|
55653
|
+
ctx.throw(400, "缺少参数 repo");
|
|
55654
|
+
}
|
|
55655
|
+
if (!issueNumber) {
|
|
55656
|
+
ctx.throw(400, "缺少参数 issueNumber");
|
|
55657
|
+
}
|
|
55658
|
+
const res = await cnb.labels.issueLabel.list(repo2, issueNumber, {
|
|
55659
|
+
page,
|
|
55660
|
+
page_size: pageSize
|
|
55661
|
+
});
|
|
55662
|
+
ctx.forward(res);
|
|
55663
|
+
}).addTo(app);
|
|
55664
|
+
app.route({
|
|
55665
|
+
path: "cnb",
|
|
55666
|
+
key: "set-issue-labels",
|
|
55667
|
+
description: "设置 Issue 标签(完全替换现有标签)",
|
|
55668
|
+
middleware: ["auth"],
|
|
55669
|
+
metadata: {
|
|
55670
|
+
tags: ["opencode"],
|
|
55671
|
+
...createSkill({
|
|
55672
|
+
skill: "set-issue-labels",
|
|
55673
|
+
title: "设置 Issue 标签",
|
|
55674
|
+
summary: "设置 Issue 标签(完全替换现有标签)",
|
|
55675
|
+
args: {
|
|
55676
|
+
repo: exports_external2.string().optional().describe("仓库路径, 如 my-user/my-repo"),
|
|
55677
|
+
issueNumber: exports_external2.number().describe("Issue 编号"),
|
|
55678
|
+
labels: exports_external2.array(exports_external2.string()).describe("标签名称数组")
|
|
55679
|
+
}
|
|
55680
|
+
})
|
|
55681
|
+
}
|
|
55682
|
+
}).define(async (ctx) => {
|
|
55683
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
55684
|
+
let repo2 = ctx.query?.repo || useKey("CNB_REPO_SLUG_LOWERCASE");
|
|
55685
|
+
const issueNumber = ctx.query?.issueNumber;
|
|
55686
|
+
const labels2 = ctx.query?.labels;
|
|
55687
|
+
if (!repo2) {
|
|
55688
|
+
ctx.throw(400, "缺少参数 repo");
|
|
55689
|
+
}
|
|
55690
|
+
if (!issueNumber) {
|
|
55691
|
+
ctx.throw(400, "缺少参数 issueNumber");
|
|
55692
|
+
}
|
|
55693
|
+
if (!labels2 || !Array.isArray(labels2)) {
|
|
55694
|
+
ctx.throw(400, "缺少参数 labels");
|
|
55695
|
+
}
|
|
55696
|
+
const res = await cnb.labels.issueLabel.set(repo2, issueNumber, { labels: labels2 });
|
|
55697
|
+
ctx.forward(res);
|
|
55698
|
+
}).addTo(app);
|
|
55699
|
+
app.route({
|
|
55700
|
+
path: "cnb",
|
|
55701
|
+
key: "add-issue-labels",
|
|
55702
|
+
description: "新增 Issue 标签(追加到现有标签)",
|
|
55703
|
+
middleware: ["auth"],
|
|
55704
|
+
metadata: {
|
|
55705
|
+
tags: ["opencode"],
|
|
55706
|
+
...createSkill({
|
|
55707
|
+
skill: "add-issue-labels",
|
|
55708
|
+
title: "新增 Issue 标签",
|
|
55709
|
+
summary: "新增 Issue 标签(追加到现有标签)",
|
|
55710
|
+
args: {
|
|
55711
|
+
repo: exports_external2.string().optional().describe("仓库路径, 如 my-user/my-repo"),
|
|
55712
|
+
issueNumber: exports_external2.number().describe("Issue 编号"),
|
|
55713
|
+
labels: exports_external2.array(exports_external2.string()).describe("标签名称数组")
|
|
55714
|
+
}
|
|
55715
|
+
})
|
|
55716
|
+
}
|
|
55717
|
+
}).define(async (ctx) => {
|
|
55718
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
55719
|
+
let repo2 = ctx.query?.repo || useKey("CNB_REPO_SLUG_LOWERCASE");
|
|
55720
|
+
const issueNumber = ctx.query?.issueNumber;
|
|
55721
|
+
const labels2 = ctx.query?.labels;
|
|
55722
|
+
if (!repo2) {
|
|
55723
|
+
ctx.throw(400, "缺少参数 repo");
|
|
55724
|
+
}
|
|
55725
|
+
if (!issueNumber) {
|
|
55726
|
+
ctx.throw(400, "缺少参数 issueNumber");
|
|
55727
|
+
}
|
|
55728
|
+
if (!labels2 || !Array.isArray(labels2)) {
|
|
55729
|
+
ctx.throw(400, "缺少参数 labels");
|
|
55730
|
+
}
|
|
55731
|
+
const res = await cnb.labels.issueLabel.add(repo2, issueNumber, { labels: labels2 });
|
|
55732
|
+
ctx.forward(res);
|
|
55733
|
+
}).addTo(app);
|
|
55734
|
+
app.route({
|
|
55735
|
+
path: "cnb",
|
|
55736
|
+
key: "clear-issue-labels",
|
|
55737
|
+
description: "清空 Issue 标签(移除所有标签)",
|
|
55738
|
+
middleware: ["auth"],
|
|
55739
|
+
metadata: {
|
|
55740
|
+
tags: ["opencode"],
|
|
55741
|
+
...createSkill({
|
|
55742
|
+
skill: "clear-issue-labels",
|
|
55743
|
+
title: "清空 Issue 标签",
|
|
55744
|
+
summary: "清空 Issue 标签(移除所有标签)",
|
|
55745
|
+
args: {
|
|
55746
|
+
repo: exports_external2.string().optional().describe("仓库路径, 如 my-user/my-repo"),
|
|
55747
|
+
issueNumber: exports_external2.number().describe("Issue 编号")
|
|
55748
|
+
}
|
|
55749
|
+
})
|
|
55750
|
+
}
|
|
55751
|
+
}).define(async (ctx) => {
|
|
55752
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
55753
|
+
let repo2 = ctx.query?.repo || useKey("CNB_REPO_SLUG_LOWERCASE");
|
|
55754
|
+
const issueNumber = ctx.query?.issueNumber;
|
|
55755
|
+
if (!repo2) {
|
|
55756
|
+
ctx.throw(400, "缺少参数 repo");
|
|
55757
|
+
}
|
|
55758
|
+
if (!issueNumber) {
|
|
55759
|
+
ctx.throw(400, "缺少参数 issueNumber");
|
|
55760
|
+
}
|
|
55761
|
+
const res = await cnb.labels.issueLabel.clear(repo2, issueNumber);
|
|
55762
|
+
ctx.forward(res);
|
|
55763
|
+
}).addTo(app);
|
|
55764
|
+
app.route({
|
|
55765
|
+
path: "cnb",
|
|
55766
|
+
key: "remove-issue-label",
|
|
55767
|
+
description: "删除 Issue 指定标签",
|
|
55768
|
+
middleware: ["auth"],
|
|
55769
|
+
metadata: {
|
|
55770
|
+
tags: ["opencode"],
|
|
55771
|
+
...createSkill({
|
|
55772
|
+
skill: "remove-issue-label",
|
|
55773
|
+
title: "删除 Issue 标签",
|
|
55774
|
+
summary: "删除 Issue 指定标签",
|
|
55775
|
+
args: {
|
|
55776
|
+
repo: exports_external2.string().optional().describe("仓库路径, 如 my-user/my-repo"),
|
|
55777
|
+
issueNumber: exports_external2.number().describe("Issue 编号"),
|
|
55778
|
+
name: exports_external2.string().describe("标签名称")
|
|
55779
|
+
}
|
|
55780
|
+
})
|
|
55781
|
+
}
|
|
55782
|
+
}).define(async (ctx) => {
|
|
55783
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
55784
|
+
let repo2 = ctx.query?.repo || useKey("CNB_REPO_SLUG_LOWERCASE");
|
|
55785
|
+
const issueNumber = ctx.query?.issueNumber;
|
|
55786
|
+
const name21 = ctx.query?.name;
|
|
55787
|
+
if (!repo2) {
|
|
55788
|
+
ctx.throw(400, "缺少参数 repo");
|
|
55789
|
+
}
|
|
55790
|
+
if (!issueNumber) {
|
|
55791
|
+
ctx.throw(400, "缺少参数 issueNumber");
|
|
55792
|
+
}
|
|
55793
|
+
if (!name21) {
|
|
55794
|
+
ctx.throw(400, "缺少参数 name");
|
|
55795
|
+
}
|
|
55796
|
+
const res = await cnb.labels.issueLabel.remove(repo2, issueNumber, name21);
|
|
55797
|
+
ctx.forward(res);
|
|
55798
|
+
}).addTo(app);
|
|
55799
|
+
|
|
55800
|
+
// agent/routes/package/registry.ts
|
|
55801
|
+
app.route({
|
|
55802
|
+
path: "cnb",
|
|
55803
|
+
key: "list-group-registries",
|
|
55804
|
+
description: "查询组织下的制品库列表, 参数 slug",
|
|
55805
|
+
middleware: ["auth"],
|
|
55806
|
+
metadata: {
|
|
55807
|
+
tags: ["package"],
|
|
55808
|
+
...createSkill({
|
|
55809
|
+
skill: "list-group-registries",
|
|
55810
|
+
title: "查询制品库列表",
|
|
55811
|
+
args: {
|
|
55812
|
+
slug: exports_external2.string().describe("组织 slug, 如 my-org"),
|
|
55813
|
+
page: exports_external2.number().describe("页码").optional(),
|
|
55814
|
+
page_size: exports_external2.number().describe("每页数量").optional(),
|
|
55815
|
+
registry_type: exports_external2.string().describe("制品仓库类型: npm, maven, ohpm").optional(),
|
|
55816
|
+
filter_type: exports_external2.string().describe("制品仓库可见性: private, public").optional(),
|
|
55817
|
+
order_by: exports_external2.string().describe("排序字段: created_at, name").optional()
|
|
55818
|
+
},
|
|
55819
|
+
summary: "查询组织下的制品库列表"
|
|
55820
|
+
})
|
|
55821
|
+
}
|
|
55822
|
+
}).define(async (ctx) => {
|
|
55823
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
55824
|
+
const slug = ctx.query?.slug;
|
|
55825
|
+
const { page, page_size, registry_type, filter_type, order_by } = ctx.query || {};
|
|
55826
|
+
if (!slug) {
|
|
55827
|
+
ctx.throw(400, "缺少参数 slug");
|
|
55828
|
+
}
|
|
55829
|
+
const res = await cnb.packages.registry.listGroupRegistries(slug, {
|
|
55830
|
+
page,
|
|
55831
|
+
page_size,
|
|
55832
|
+
registry_type,
|
|
55833
|
+
filter_type,
|
|
55834
|
+
order_by
|
|
55835
|
+
});
|
|
55836
|
+
ctx.forward(res);
|
|
55837
|
+
}).addTo(app);
|
|
55838
|
+
app.route({
|
|
55839
|
+
path: "cnb",
|
|
55840
|
+
key: "set-registry-visibility",
|
|
55841
|
+
description: "设置制品库可见性, 参数 registry, visibility",
|
|
55842
|
+
middleware: ["auth"],
|
|
55843
|
+
metadata: {
|
|
55844
|
+
tags: ["package"],
|
|
55845
|
+
...createSkill({
|
|
55846
|
+
skill: "set-registry-visibility",
|
|
55847
|
+
title: "设置制品库可见性",
|
|
55848
|
+
args: {
|
|
55849
|
+
registry: exports_external2.string().describe("制品库路径, 如 my-org/my-registry"),
|
|
55850
|
+
visibility: exports_external2.string().describe("可见性: private 或 public")
|
|
55851
|
+
},
|
|
55852
|
+
summary: "设置制品库的可见性"
|
|
55853
|
+
})
|
|
55854
|
+
}
|
|
55855
|
+
}).define(async (ctx) => {
|
|
55856
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
55857
|
+
const registry4 = ctx.query?.registry;
|
|
55858
|
+
const visibility = ctx.query?.visibility;
|
|
55859
|
+
if (!registry4) {
|
|
55860
|
+
ctx.throw(400, "缺少参数 registry");
|
|
55861
|
+
}
|
|
55862
|
+
if (!visibility) {
|
|
55863
|
+
ctx.throw(400, "缺少参数 visibility");
|
|
55864
|
+
}
|
|
55865
|
+
const res = await cnb.packages.registry.setVisibility(registry4, { visibility });
|
|
55866
|
+
ctx.forward(res);
|
|
55867
|
+
}).addTo(app);
|
|
55868
|
+
app.route({
|
|
55869
|
+
path: "cnb",
|
|
55870
|
+
key: "delete-registry",
|
|
55871
|
+
description: "删除制品库, 参数 registry",
|
|
55872
|
+
middleware: ["auth"],
|
|
55873
|
+
metadata: {
|
|
55874
|
+
tags: ["package"],
|
|
55875
|
+
...createSkill({
|
|
55876
|
+
skill: "delete-registry",
|
|
55877
|
+
title: "删除制品库",
|
|
55878
|
+
args: {
|
|
55879
|
+
registry: exports_external2.string().describe("制品库路径, 如 my-org/my-registry")
|
|
55880
|
+
},
|
|
55881
|
+
summary: "删除指定的制品库"
|
|
55882
|
+
})
|
|
55883
|
+
}
|
|
55884
|
+
}).define(async (ctx) => {
|
|
55885
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
55886
|
+
const registry4 = ctx.query?.registry;
|
|
55887
|
+
if (!registry4) {
|
|
55888
|
+
ctx.throw(400, "缺少参数 registry");
|
|
55889
|
+
}
|
|
55890
|
+
const res = await cnb.packages.registry.remove(registry4);
|
|
55891
|
+
ctx.forward(res);
|
|
55892
|
+
}).addTo(app);
|
|
55893
|
+
|
|
55894
|
+
// agent/routes/package/package.ts
|
|
55895
|
+
app.route({
|
|
55896
|
+
path: "cnb",
|
|
55897
|
+
key: "list-packages",
|
|
55898
|
+
description: "查询制品列表, 参数 slug, type",
|
|
55899
|
+
middleware: ["auth"],
|
|
55900
|
+
metadata: {
|
|
55901
|
+
tags: ["package"],
|
|
55902
|
+
...createSkill({
|
|
55903
|
+
skill: "list-packages",
|
|
55904
|
+
title: "查询制品列表",
|
|
55905
|
+
args: {
|
|
55906
|
+
slug: exports_external2.string().describe("资源路径, 如 my-org/my-registry"),
|
|
55907
|
+
type: exports_external2.string().describe("制品类型: all, docker, helm, docker-model, maven, npm, ohpm, pypi, nuget, composer, conan, cargo"),
|
|
55908
|
+
ordering: exports_external2.string().describe("排序类型: pull_count, last_push_at, name_ascend, name_descend").optional(),
|
|
55909
|
+
name: exports_external2.string().describe("关键字,搜索制品名称").optional(),
|
|
55910
|
+
page: exports_external2.number().describe("页码").optional(),
|
|
55911
|
+
page_size: exports_external2.number().describe("每页数量").optional()
|
|
55912
|
+
},
|
|
55913
|
+
summary: "查询制品列表"
|
|
55914
|
+
})
|
|
55915
|
+
}
|
|
55916
|
+
}).define(async (ctx) => {
|
|
55917
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
55918
|
+
const slug = ctx.query?.slug;
|
|
55919
|
+
const type = ctx.query?.type;
|
|
55920
|
+
const { ordering, name: name21, page, page_size } = ctx.query || {};
|
|
55921
|
+
if (!slug) {
|
|
55922
|
+
ctx.throw(400, "缺少参数 slug");
|
|
55923
|
+
}
|
|
55924
|
+
if (!type) {
|
|
55925
|
+
ctx.throw(400, "缺少参数 type");
|
|
55926
|
+
}
|
|
55927
|
+
const res = await cnb.packages.package.list(slug, type, {
|
|
55928
|
+
ordering,
|
|
55929
|
+
name: name21,
|
|
55930
|
+
page,
|
|
55931
|
+
page_size
|
|
55932
|
+
});
|
|
55933
|
+
ctx.forward(res);
|
|
55934
|
+
}).addTo(app);
|
|
55935
|
+
app.route({
|
|
55936
|
+
path: "cnb",
|
|
55937
|
+
key: "get-package",
|
|
55938
|
+
description: "获取制品详情, 参数 slug, type, name",
|
|
55939
|
+
middleware: ["auth"],
|
|
55940
|
+
metadata: {
|
|
55941
|
+
tags: ["package"],
|
|
55942
|
+
...createSkill({
|
|
55943
|
+
skill: "get-package",
|
|
55944
|
+
title: "获取制品详情",
|
|
55945
|
+
args: {
|
|
55946
|
+
slug: exports_external2.string().describe("资源路径, 如 my-org/my-registry"),
|
|
55947
|
+
type: exports_external2.string().describe("制品类型"),
|
|
55948
|
+
name: exports_external2.string().describe("制品名称")
|
|
55949
|
+
},
|
|
55950
|
+
summary: "获取指定制品的详细信息"
|
|
55951
|
+
})
|
|
55952
|
+
}
|
|
55953
|
+
}).define(async (ctx) => {
|
|
55954
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
55955
|
+
const slug = ctx.query?.slug;
|
|
55956
|
+
const type = ctx.query?.type;
|
|
55957
|
+
const name21 = ctx.query?.name;
|
|
55958
|
+
if (!slug) {
|
|
55959
|
+
ctx.throw(400, "缺少参数 slug");
|
|
55960
|
+
}
|
|
55961
|
+
if (!type) {
|
|
55962
|
+
ctx.throw(400, "缺少参数 type");
|
|
55963
|
+
}
|
|
55964
|
+
if (!name21) {
|
|
55965
|
+
ctx.throw(400, "缺少参数 name");
|
|
55966
|
+
}
|
|
55967
|
+
const res = await cnb.packages.package.getOne(slug, type, name21);
|
|
55968
|
+
ctx.forward(res);
|
|
55969
|
+
}).addTo(app);
|
|
55970
|
+
app.route({
|
|
55971
|
+
path: "cnb",
|
|
55972
|
+
key: "delete-package",
|
|
55973
|
+
description: "删除制品, 参数 slug, type, name",
|
|
55974
|
+
middleware: ["auth"],
|
|
55975
|
+
metadata: {
|
|
55976
|
+
tags: ["package"],
|
|
55977
|
+
...createSkill({
|
|
55978
|
+
skill: "delete-package",
|
|
55979
|
+
title: "删除制品",
|
|
55980
|
+
args: {
|
|
55981
|
+
slug: exports_external2.string().describe("资源路径, 如 my-org/my-registry"),
|
|
55982
|
+
type: exports_external2.string().describe("制品类型"),
|
|
55983
|
+
name: exports_external2.string().describe("制品名称")
|
|
55984
|
+
},
|
|
55985
|
+
summary: "删除指定的制品"
|
|
55986
|
+
})
|
|
55987
|
+
}
|
|
55988
|
+
}).define(async (ctx) => {
|
|
55989
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
55990
|
+
const slug = ctx.query?.slug;
|
|
55991
|
+
const type = ctx.query?.type;
|
|
55992
|
+
const name21 = ctx.query?.name;
|
|
55993
|
+
if (!slug) {
|
|
55994
|
+
ctx.throw(400, "缺少参数 slug");
|
|
55995
|
+
}
|
|
55996
|
+
if (!type) {
|
|
55997
|
+
ctx.throw(400, "缺少参数 type");
|
|
55998
|
+
}
|
|
55999
|
+
if (!name21) {
|
|
56000
|
+
ctx.throw(400, "缺少参数 name");
|
|
56001
|
+
}
|
|
56002
|
+
const res = await cnb.packages.package.remove(slug, type, name21);
|
|
56003
|
+
ctx.forward(res);
|
|
56004
|
+
}).addTo(app);
|
|
56005
|
+
app.route({
|
|
56006
|
+
path: "cnb",
|
|
56007
|
+
key: "list-package-tags",
|
|
56008
|
+
description: "获取制品标签列表, 参数 slug, type, name",
|
|
56009
|
+
middleware: ["auth"],
|
|
56010
|
+
metadata: {
|
|
56011
|
+
tags: ["package"],
|
|
56012
|
+
...createSkill({
|
|
56013
|
+
skill: "list-package-tags",
|
|
56014
|
+
title: "获取制品标签列表",
|
|
56015
|
+
args: {
|
|
56016
|
+
slug: exports_external2.string().describe("资源路径, 如 my-org/my-registry"),
|
|
56017
|
+
type: exports_external2.string().describe("制品类型"),
|
|
56018
|
+
name: exports_external2.string().describe("制品名称"),
|
|
56019
|
+
page: exports_external2.number().describe("页码").optional(),
|
|
56020
|
+
page_size: exports_external2.number().describe("每页数量").optional()
|
|
56021
|
+
},
|
|
56022
|
+
summary: "获取制品的标签列表"
|
|
56023
|
+
})
|
|
56024
|
+
}
|
|
56025
|
+
}).define(async (ctx) => {
|
|
56026
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
56027
|
+
const slug = ctx.query?.slug;
|
|
56028
|
+
const type = ctx.query?.type;
|
|
56029
|
+
const name21 = ctx.query?.name;
|
|
56030
|
+
const { page, page_size } = ctx.query || {};
|
|
56031
|
+
if (!slug) {
|
|
56032
|
+
ctx.throw(400, "缺少参数 slug");
|
|
56033
|
+
}
|
|
56034
|
+
if (!type) {
|
|
56035
|
+
ctx.throw(400, "缺少参数 type");
|
|
56036
|
+
}
|
|
56037
|
+
if (!name21) {
|
|
56038
|
+
ctx.throw(400, "缺少参数 name");
|
|
56039
|
+
}
|
|
56040
|
+
const res = await cnb.packages.package.listTags(slug, type, name21, { page, page_size });
|
|
56041
|
+
ctx.forward(res);
|
|
56042
|
+
}).addTo(app);
|
|
56043
|
+
app.route({
|
|
56044
|
+
path: "cnb",
|
|
56045
|
+
key: "get-package-tag",
|
|
56046
|
+
description: "获取制品标签详情, 参数 slug, type, name, tag",
|
|
56047
|
+
middleware: ["auth"],
|
|
56048
|
+
metadata: {
|
|
56049
|
+
tags: ["package"],
|
|
56050
|
+
...createSkill({
|
|
56051
|
+
skill: "get-package-tag",
|
|
56052
|
+
title: "获取制品标签详情",
|
|
56053
|
+
args: {
|
|
56054
|
+
slug: exports_external2.string().describe("资源路径, 如 my-org/my-registry"),
|
|
56055
|
+
type: exports_external2.string().describe("制品类型"),
|
|
56056
|
+
name: exports_external2.string().describe("制品名称"),
|
|
56057
|
+
tag: exports_external2.string().describe("标签名称")
|
|
56058
|
+
},
|
|
56059
|
+
summary: "获取制品标签的详细信息"
|
|
56060
|
+
})
|
|
56061
|
+
}
|
|
56062
|
+
}).define(async (ctx) => {
|
|
56063
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
56064
|
+
const slug = ctx.query?.slug;
|
|
56065
|
+
const type = ctx.query?.type;
|
|
56066
|
+
const name21 = ctx.query?.name;
|
|
56067
|
+
const tag = ctx.query?.tag;
|
|
56068
|
+
if (!slug) {
|
|
56069
|
+
ctx.throw(400, "缺少参数 slug");
|
|
56070
|
+
}
|
|
56071
|
+
if (!type) {
|
|
56072
|
+
ctx.throw(400, "缺少参数 type");
|
|
56073
|
+
}
|
|
56074
|
+
if (!name21) {
|
|
56075
|
+
ctx.throw(400, "缺少参数 name");
|
|
56076
|
+
}
|
|
56077
|
+
if (!tag) {
|
|
56078
|
+
ctx.throw(400, "缺少参数 tag");
|
|
56079
|
+
}
|
|
56080
|
+
const res = await cnb.packages.package.getTag(slug, type, name21, tag);
|
|
56081
|
+
ctx.forward(res);
|
|
56082
|
+
}).addTo(app);
|
|
56083
|
+
app.route({
|
|
56084
|
+
path: "cnb",
|
|
56085
|
+
key: "delete-package-tag",
|
|
56086
|
+
description: "删除制品标签, 参数 slug, type, name, tag",
|
|
56087
|
+
middleware: ["auth"],
|
|
56088
|
+
metadata: {
|
|
56089
|
+
tags: ["package"],
|
|
56090
|
+
...createSkill({
|
|
56091
|
+
skill: "delete-package-tag",
|
|
56092
|
+
title: "删除制品标签",
|
|
56093
|
+
args: {
|
|
56094
|
+
slug: exports_external2.string().describe("资源路径, 如 my-org/my-registry"),
|
|
56095
|
+
type: exports_external2.string().describe("制品类型"),
|
|
56096
|
+
name: exports_external2.string().describe("制品名称"),
|
|
56097
|
+
tag: exports_external2.string().describe("标签名称")
|
|
56098
|
+
},
|
|
56099
|
+
summary: "删除制品的指定标签"
|
|
56100
|
+
})
|
|
56101
|
+
}
|
|
56102
|
+
}).define(async (ctx) => {
|
|
56103
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
56104
|
+
const slug = ctx.query?.slug;
|
|
56105
|
+
const type = ctx.query?.type;
|
|
56106
|
+
const name21 = ctx.query?.name;
|
|
56107
|
+
const tag = ctx.query?.tag;
|
|
56108
|
+
if (!slug) {
|
|
56109
|
+
ctx.throw(400, "缺少参数 slug");
|
|
56110
|
+
}
|
|
56111
|
+
if (!type) {
|
|
56112
|
+
ctx.throw(400, "缺少参数 type");
|
|
56113
|
+
}
|
|
56114
|
+
if (!name21) {
|
|
56115
|
+
ctx.throw(400, "缺少参数 name");
|
|
56116
|
+
}
|
|
56117
|
+
if (!tag) {
|
|
56118
|
+
ctx.throw(400, "缺少参数 tag");
|
|
56119
|
+
}
|
|
56120
|
+
const res = await cnb.packages.package.removeTag(slug, type, name21, tag);
|
|
56121
|
+
ctx.forward(res);
|
|
56122
|
+
}).addTo(app);
|
|
56123
|
+
|
|
55416
56124
|
// agent/routes/index.ts
|
|
55417
56125
|
var checkAppId = (ctx, appId) => {
|
|
55418
56126
|
const _appId = ctx?.app?.appId;
|
|
@@ -55464,7 +56172,7 @@ var {
|
|
|
55464
56172
|
Help
|
|
55465
56173
|
} = import__3.default;
|
|
55466
56174
|
|
|
55467
|
-
// ../../node_modules/.pnpm/@kevisual+remote-app@0.0.
|
|
56175
|
+
// ../../node_modules/.pnpm/@kevisual+remote-app@0.0.7/node_modules/@kevisual/remote-app/dist/app.js
|
|
55468
56176
|
var __create4 = Object.create;
|
|
55469
56177
|
var __getProtoOf4 = Object.getPrototypeOf;
|
|
55470
56178
|
var __defProp5 = Object.defineProperty;
|
|
@@ -55679,10 +56387,12 @@ class RemoteApp {
|
|
|
55679
56387
|
reconnectAttempts = 0;
|
|
55680
56388
|
reconnectTimer = null;
|
|
55681
56389
|
isManuallyClosed = false;
|
|
56390
|
+
isInitializing = false;
|
|
56391
|
+
initId = 0;
|
|
55682
56392
|
constructor(opts) {
|
|
55683
56393
|
this.mainApp = opts?.app;
|
|
55684
56394
|
const token2 = opts.token;
|
|
55685
|
-
const url4 = opts.url;
|
|
56395
|
+
const url4 = opts.url || "https://kevisual.cn/ws/proxy";
|
|
55686
56396
|
const id = opts.id;
|
|
55687
56397
|
const username = opts.username;
|
|
55688
56398
|
this.username = username;
|
|
@@ -55748,10 +56458,17 @@ class RemoteApp {
|
|
|
55748
56458
|
return wsURL;
|
|
55749
56459
|
}
|
|
55750
56460
|
async init() {
|
|
56461
|
+
if (this.isInitializing) {
|
|
56462
|
+
return;
|
|
56463
|
+
}
|
|
56464
|
+
this.isInitializing = true;
|
|
56465
|
+
const currentInitId = ++this.initId;
|
|
55751
56466
|
if (!this.url) {
|
|
56467
|
+
this.isInitializing = false;
|
|
55752
56468
|
throw new Error("No url provided for remote app");
|
|
55753
56469
|
}
|
|
55754
56470
|
if (!this.id) {
|
|
56471
|
+
this.isInitializing = false;
|
|
55755
56472
|
throw new Error("No id provided for remote app");
|
|
55756
56473
|
}
|
|
55757
56474
|
this.isError = false;
|
|
@@ -55761,11 +56478,20 @@ class RemoteApp {
|
|
|
55761
56478
|
const ws = new WebSocket(this.getWsURL(this.url));
|
|
55762
56479
|
const that = this;
|
|
55763
56480
|
ws.onopen = function() {
|
|
56481
|
+
if (currentInitId !== that.initId) {
|
|
56482
|
+
ws.close();
|
|
56483
|
+
return;
|
|
56484
|
+
}
|
|
55764
56485
|
that.isConnected = true;
|
|
56486
|
+
that.isInitializing = false;
|
|
55765
56487
|
that.onOpen();
|
|
55766
56488
|
console.log("[remote-app] WebSocket connection opened");
|
|
55767
56489
|
};
|
|
55768
56490
|
ws.onclose = function() {
|
|
56491
|
+
if (currentInitId !== that.initId) {
|
|
56492
|
+
return;
|
|
56493
|
+
}
|
|
56494
|
+
that.isInitializing = false;
|
|
55769
56495
|
that.isConnected = false;
|
|
55770
56496
|
that.onClose();
|
|
55771
56497
|
};
|
|
@@ -55773,6 +56499,10 @@ class RemoteApp {
|
|
|
55773
56499
|
that.onMessage(event.data);
|
|
55774
56500
|
};
|
|
55775
56501
|
ws.onerror = function(error49) {
|
|
56502
|
+
if (currentInitId !== that.initId) {
|
|
56503
|
+
return;
|
|
56504
|
+
}
|
|
56505
|
+
that.isInitializing = false;
|
|
55776
56506
|
that.onError(error49);
|
|
55777
56507
|
};
|
|
55778
56508
|
this.ws = ws;
|