linkque-cli-v2 1.6.11-alpha.0 → 1.6.12
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/linkquejs.js +145 -118
- package/package.json +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-NE7CUP5E.js → chunk-3J4AB676.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-H7TMASQH.js → chunk-DPHKD4SK.js} +633 -558
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-FA5CNADA.js → chunk-EHNI5TX3.js} +25 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-DNTEEBEH.js → chunk-SICWMO5Y.js} +1 -0
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{getMachineId-bsd-JGCLGHFY.js → getMachineId-bsd-NYGVHXGN.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{getMachineId-darwin-COHLFNXH.js → getMachineId-darwin-OPTJOAYC.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{getMachineId-linux-XV3Z5FQG.js → getMachineId-linux-5SQRYTUJ.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{getMachineId-unsupported-FCRKLIZL.js → getMachineId-unsupported-OJE7WPEH.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{getMachineId-win-A4WRNVV6.js → getMachineId-win-SLTTCNXU.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{mistral-conversations-ZYAKAOUL.js → mistral-conversations-XUDTCRDY.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{otel-BHGIWGIT.js → otel-3OUODIOB.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js +25 -18
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/clientCapability.js +3 -3
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/protocol.js +3 -3
- package/worker.js +740 -666
package/linkquejs.js
CHANGED
|
@@ -11827,6 +11827,110 @@ var require_dist = __commonJS({
|
|
|
11827
11827
|
}
|
|
11828
11828
|
});
|
|
11829
11829
|
|
|
11830
|
+
// ../../node_modules/content-type/index.js
|
|
11831
|
+
var require_content_type = __commonJS({
|
|
11832
|
+
"../../node_modules/content-type/index.js"(exports2) {
|
|
11833
|
+
"use strict";
|
|
11834
|
+
var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g;
|
|
11835
|
+
var TEXT_REGEXP = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/;
|
|
11836
|
+
var TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
11837
|
+
var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g;
|
|
11838
|
+
var QUOTE_REGEXP = /([\\"])/g;
|
|
11839
|
+
var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
11840
|
+
exports2.format = format;
|
|
11841
|
+
exports2.parse = parse3;
|
|
11842
|
+
function format(obj) {
|
|
11843
|
+
if (!obj || typeof obj !== "object") {
|
|
11844
|
+
throw new TypeError("argument obj is required");
|
|
11845
|
+
}
|
|
11846
|
+
var parameters = obj.parameters;
|
|
11847
|
+
var type = obj.type;
|
|
11848
|
+
if (!type || !TYPE_REGEXP.test(type)) {
|
|
11849
|
+
throw new TypeError("invalid type");
|
|
11850
|
+
}
|
|
11851
|
+
var string4 = type;
|
|
11852
|
+
if (parameters && typeof parameters === "object") {
|
|
11853
|
+
var param;
|
|
11854
|
+
var params = Object.keys(parameters).sort();
|
|
11855
|
+
for (var i = 0; i < params.length; i++) {
|
|
11856
|
+
param = params[i];
|
|
11857
|
+
if (!TOKEN_REGEXP.test(param)) {
|
|
11858
|
+
throw new TypeError("invalid parameter name");
|
|
11859
|
+
}
|
|
11860
|
+
string4 += "; " + param + "=" + qstring(parameters[param]);
|
|
11861
|
+
}
|
|
11862
|
+
}
|
|
11863
|
+
return string4;
|
|
11864
|
+
}
|
|
11865
|
+
function parse3(string4) {
|
|
11866
|
+
if (!string4) {
|
|
11867
|
+
throw new TypeError("argument string is required");
|
|
11868
|
+
}
|
|
11869
|
+
var header = typeof string4 === "object" ? getcontenttype(string4) : string4;
|
|
11870
|
+
if (typeof header !== "string") {
|
|
11871
|
+
throw new TypeError("argument string is required to be a string");
|
|
11872
|
+
}
|
|
11873
|
+
var index = header.indexOf(";");
|
|
11874
|
+
var type = index !== -1 ? header.slice(0, index).trim() : header.trim();
|
|
11875
|
+
if (!TYPE_REGEXP.test(type)) {
|
|
11876
|
+
throw new TypeError("invalid media type");
|
|
11877
|
+
}
|
|
11878
|
+
var obj = new ContentType(type.toLowerCase());
|
|
11879
|
+
if (index !== -1) {
|
|
11880
|
+
var key;
|
|
11881
|
+
var match;
|
|
11882
|
+
var value;
|
|
11883
|
+
PARAM_REGEXP.lastIndex = index;
|
|
11884
|
+
while (match = PARAM_REGEXP.exec(header)) {
|
|
11885
|
+
if (match.index !== index) {
|
|
11886
|
+
throw new TypeError("invalid parameter format");
|
|
11887
|
+
}
|
|
11888
|
+
index += match[0].length;
|
|
11889
|
+
key = match[1].toLowerCase();
|
|
11890
|
+
value = match[2];
|
|
11891
|
+
if (value.charCodeAt(0) === 34) {
|
|
11892
|
+
value = value.slice(1, -1);
|
|
11893
|
+
if (value.indexOf("\\") !== -1) {
|
|
11894
|
+
value = value.replace(QESC_REGEXP, "$1");
|
|
11895
|
+
}
|
|
11896
|
+
}
|
|
11897
|
+
obj.parameters[key] = value;
|
|
11898
|
+
}
|
|
11899
|
+
if (index !== header.length) {
|
|
11900
|
+
throw new TypeError("invalid parameter format");
|
|
11901
|
+
}
|
|
11902
|
+
}
|
|
11903
|
+
return obj;
|
|
11904
|
+
}
|
|
11905
|
+
function getcontenttype(obj) {
|
|
11906
|
+
var header;
|
|
11907
|
+
if (typeof obj.getHeader === "function") {
|
|
11908
|
+
header = obj.getHeader("content-type");
|
|
11909
|
+
} else if (typeof obj.headers === "object") {
|
|
11910
|
+
header = obj.headers && obj.headers["content-type"];
|
|
11911
|
+
}
|
|
11912
|
+
if (typeof header !== "string") {
|
|
11913
|
+
throw new TypeError("content-type header is missing from object");
|
|
11914
|
+
}
|
|
11915
|
+
return header;
|
|
11916
|
+
}
|
|
11917
|
+
function qstring(val) {
|
|
11918
|
+
var str = String(val);
|
|
11919
|
+
if (TOKEN_REGEXP.test(str)) {
|
|
11920
|
+
return str;
|
|
11921
|
+
}
|
|
11922
|
+
if (str.length > 0 && !TEXT_REGEXP.test(str)) {
|
|
11923
|
+
throw new TypeError("invalid parameter value");
|
|
11924
|
+
}
|
|
11925
|
+
return '"' + str.replace(QUOTE_REGEXP, "\\$1") + '"';
|
|
11926
|
+
}
|
|
11927
|
+
function ContentType(type) {
|
|
11928
|
+
this.parameters = /* @__PURE__ */ Object.create(null);
|
|
11929
|
+
this.type = type;
|
|
11930
|
+
}
|
|
11931
|
+
}
|
|
11932
|
+
});
|
|
11933
|
+
|
|
11830
11934
|
// src/errors/catalog.ts
|
|
11831
11935
|
var ERROR_CATALOG = {
|
|
11832
11936
|
// CLI usage
|
|
@@ -11838,11 +11942,6 @@ var ERROR_CATALOG = {
|
|
|
11838
11942
|
MCP_RESOURCE_NOT_CONFIGURED: { retryable: false, exitCode: 1 },
|
|
11839
11943
|
MCP_DETAIL_DISABLED: { retryable: false, exitCode: 1 },
|
|
11840
11944
|
MCP_DETAIL_CONFIG_INVALID: { retryable: false, exitCode: 1 },
|
|
11841
|
-
MCP_DETAIL_CONTEXT_REQUIRED: { retryable: false, exitCode: 1 },
|
|
11842
|
-
MCP_DETAIL_CONTEXT_INVALID: { retryable: false, exitCode: 1 },
|
|
11843
|
-
MCP_DETAIL_CONTEXT_MISMATCH: { retryable: false, exitCode: 1 },
|
|
11844
|
-
MCP_DETAIL_CONTEXT_EXPIRED: { retryable: false, exitCode: 1 },
|
|
11845
|
-
MCP_DETAIL_CONTEXT_REVOKED: { retryable: false, exitCode: 1 },
|
|
11846
11945
|
MCP_DETAIL_ENDPOINT_INVALID: { retryable: false, exitCode: 1 },
|
|
11847
11946
|
MCP_DETAIL_AUTH_REQUIRED: { retryable: false, exitCode: 1 },
|
|
11848
11947
|
MCP_DETAIL_FORBIDDEN: { retryable: false, exitCode: 1 },
|
|
@@ -17591,11 +17690,11 @@ function validateClientAction(body, path25, issues) {
|
|
|
17591
17690
|
issues.push(issue2(`${path25}.context`, "INVALID_CLIENT_ACTION_CONTEXT", "ui.surface.open requires context.surfaceId"));
|
|
17592
17691
|
return;
|
|
17593
17692
|
}
|
|
17594
|
-
if (body.name === "ui.page.open") {
|
|
17693
|
+
if (body.name === "ui.page.open" || body.name === "ui.miniprogram.embed") {
|
|
17595
17694
|
if (!isPlainRecord(body.context) || Object.keys(body.context).length !== 1 || typeof body.context.url !== "string" && !isStrictBinding(body.context.url))
|
|
17596
|
-
issues.push(issue2(`${path25}.context`, "INVALID_CLIENT_ACTION_CONTEXT",
|
|
17695
|
+
issues.push(issue2(`${path25}.context`, "INVALID_CLIENT_ACTION_CONTEXT", `${body.name} requires one literal or bound URL`));
|
|
17597
17696
|
else if (typeof body.context.url === "string" && !isSafePageUrl(body.context.url))
|
|
17598
|
-
issues.push(issue2(`${path25}.context.url`, "INVALID_PAGE_URL",
|
|
17697
|
+
issues.push(issue2(`${path25}.context.url`, "INVALID_PAGE_URL", `${body.name} URL must use https or the approved Alipay scheme`));
|
|
17599
17698
|
return;
|
|
17600
17699
|
}
|
|
17601
17700
|
issues.push(issue2(`${path25}.name`, "UNSUPPORTED_CLIENT_ACTION", `unsupported client action ${String(body.name)}`));
|
|
@@ -19551,7 +19650,7 @@ function getA2UICardAuthoringDiagnostics(bundle, partial2) {
|
|
|
19551
19650
|
const component = findComponent(bundle, group.surfaceId, group.componentId);
|
|
19552
19651
|
const action = isPlainRecord(component?.action) ? component.action : void 0;
|
|
19553
19652
|
const client = action && isPlainRecord(action.client) ? action.client : void 0;
|
|
19554
|
-
if (client?.name === "ui.page.open") {
|
|
19653
|
+
if (client?.name === "ui.page.open" || client?.name === "ui.miniprogram.embed") {
|
|
19555
19654
|
const context = isPlainRecord(client.context) ? client.context : void 0;
|
|
19556
19655
|
if (typeof context?.url === "string" && !isSafePageUrl2(context.url)) {
|
|
19557
19656
|
diagnostics.push({
|
|
@@ -19691,16 +19790,16 @@ function actionTargets(component, occurrenceId) {
|
|
|
19691
19790
|
];
|
|
19692
19791
|
}
|
|
19693
19792
|
const client = isPlainRecord(action.client) ? action.client : void 0;
|
|
19694
|
-
if (client?.name === "ui.page.open") {
|
|
19793
|
+
if (client?.name === "ui.page.open" || client?.name === "ui.miniprogram.embed") {
|
|
19695
19794
|
const context = isPlainRecord(client.context) ? client.context : void 0;
|
|
19696
19795
|
const url2 = context?.url;
|
|
19697
19796
|
return [
|
|
19698
19797
|
{
|
|
19699
|
-
kind: "page-open",
|
|
19798
|
+
kind: client.name === "ui.miniprogram.embed" ? "miniprogram-embed" : "page-open",
|
|
19700
19799
|
targetId: createA2UICardAuthoringTargetId(occurrenceId, "action"),
|
|
19701
19800
|
occurrenceId,
|
|
19702
19801
|
propertyPath: "action",
|
|
19703
|
-
label: "\u6253\u5F00\u9875\u9762",
|
|
19802
|
+
label: client.name === "ui.miniprogram.embed" ? "\u5C0F\u7A0B\u5E8F\u534A\u5C4F\u6253\u5F00" : "\u6253\u5F00\u9875\u9762",
|
|
19704
19803
|
...typeof url2 === "string" ? { url: url2 } : {},
|
|
19705
19804
|
dynamic: isPlainRecord(url2) && typeof url2.path === "string"
|
|
19706
19805
|
}
|
|
@@ -27219,6 +27318,9 @@ var STDIO_DEFAULT_MAX_BUFFER_SIZE = 10 * 1024 * 1024;
|
|
|
27219
27318
|
// ../linkque-agent-runtime/dist/esm/impl/mcp/alipay/remoteSignatureSigner.js
|
|
27220
27319
|
var DEFAULT_SIGN_ENDPOINT = RUNTIME_CONFIG_DEFAULTS.LINKQUEGW_MCP_SIGN_ENDPOINT;
|
|
27221
27320
|
|
|
27321
|
+
// ../../node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js
|
|
27322
|
+
var import_content_type = __toESM(require_content_type(), 1);
|
|
27323
|
+
|
|
27222
27324
|
// ../../node_modules/pkce-challenge/dist/index.node.js
|
|
27223
27325
|
var crypto2;
|
|
27224
27326
|
crypto2 = globalThis.crypto?.webcrypto ?? // Node.js [18-16] REPL
|
|
@@ -40366,7 +40468,6 @@ var import_promises15 = require("fs/promises");
|
|
|
40366
40468
|
var import_path22 = __toESM(require("path"));
|
|
40367
40469
|
var MCP_DETAIL_ENDPOINT_ENV = "LINKQUE_MCP_DETAIL_ENDPOINT";
|
|
40368
40470
|
var MCP_DETAIL_ENABLED_ENV = "LINKQUE_MCP_DETAIL_ENABLED";
|
|
40369
|
-
var MCP_DETAIL_CONTEXT_ENV = "LINKQUE_MCP_DETAIL_CONTEXT";
|
|
40370
40471
|
var TIMEOUT_MS = 15e3;
|
|
40371
40472
|
var MAX_RESPONSE_BYTES = 1024 * 1024;
|
|
40372
40473
|
var MAX_CONFIG_BYTES = 16 * 1024 * 1024;
|
|
@@ -40377,14 +40478,8 @@ async function describeMcp(cwd, resourceId, env = process.env) {
|
|
|
40377
40478
|
"resource-id \u5FC5\u987B\u4E3A\u975E\u7A7A\u6807\u8BC6"
|
|
40378
40479
|
);
|
|
40379
40480
|
}
|
|
40380
|
-
|
|
40481
|
+
requireEnabled(env);
|
|
40381
40482
|
const mounted = await readMountedMcp(cwd, resourceId);
|
|
40382
|
-
if (mounted.agentId !== context.agentId) {
|
|
40383
|
-
throw new LinkqueCliError(
|
|
40384
|
-
"MCP_DETAIL_CONTEXT_MISMATCH",
|
|
40385
|
-
"\u5F53\u524D\u5DE5\u4F5C\u533A\u4E0E MCP \u67E5\u8BE2\u59D4\u6258\u4E0D\u5339\u914D"
|
|
40386
|
-
);
|
|
40387
|
-
}
|
|
40388
40483
|
const endpoint = resolveEndpoint(env[MCP_DETAIL_ENDPOINT_ENV]);
|
|
40389
40484
|
const controller = new AbortController();
|
|
40390
40485
|
const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
@@ -40393,29 +40488,21 @@ async function describeMcp(cwd, resourceId, env = process.env) {
|
|
|
40393
40488
|
method: "POST",
|
|
40394
40489
|
headers: {
|
|
40395
40490
|
"content-type": "application/json",
|
|
40396
|
-
accept: "application/json"
|
|
40491
|
+
accept: "application/json"
|
|
40397
40492
|
// ARCA 身份只能由可信出口注入;不接受本地伪造或用户凭据降级。
|
|
40398
|
-
"x-linkque-sandbox-execution-id": context.executionId,
|
|
40399
|
-
"x-linkque-agent-id": mounted.agentId
|
|
40400
40493
|
},
|
|
40401
40494
|
redirect: "manual",
|
|
40402
40495
|
signal: controller.signal,
|
|
40403
40496
|
body: JSON.stringify({
|
|
40404
|
-
schemaVersion: "
|
|
40405
|
-
|
|
40406
|
-
workspaceId: context.workspaceId,
|
|
40407
|
-
sprintId: context.sprintId,
|
|
40408
|
-
sessionId: context.sessionId,
|
|
40409
|
-
resourceId: mounted.resourceId,
|
|
40410
|
-
resourceType: mounted.resourceType,
|
|
40411
|
-
serverName: mounted.serverName
|
|
40497
|
+
schemaVersion: "3",
|
|
40498
|
+
abilityCode: mounted.abilityCode
|
|
40412
40499
|
})
|
|
40413
40500
|
});
|
|
40414
40501
|
if (!response.ok) {
|
|
40415
40502
|
throw await readHttpError(response);
|
|
40416
40503
|
}
|
|
40417
40504
|
const value = await readResponse(response);
|
|
40418
|
-
return parseDetail(value, mounted
|
|
40505
|
+
return parseDetail(value, mounted);
|
|
40419
40506
|
} catch (cause) {
|
|
40420
40507
|
if (cause instanceof LinkqueCliError) throw cause;
|
|
40421
40508
|
if (controller.signal.aborted) {
|
|
@@ -40429,7 +40516,7 @@ async function describeMcp(cwd, resourceId, env = process.env) {
|
|
|
40429
40516
|
clearTimeout(timer);
|
|
40430
40517
|
}
|
|
40431
40518
|
}
|
|
40432
|
-
function
|
|
40519
|
+
function requireEnabled(env) {
|
|
40433
40520
|
const enabled = env[MCP_DETAIL_ENABLED_ENV]?.trim();
|
|
40434
40521
|
if (!enabled || enabled === "false") {
|
|
40435
40522
|
throw new LinkqueCliError(
|
|
@@ -40443,57 +40530,6 @@ function readExecutionContext(env) {
|
|
|
40443
40530
|
"MCP \u8BE6\u60C5\u67E5\u8BE2\u5F00\u5173\u914D\u7F6E\u65E0\u6548"
|
|
40444
40531
|
);
|
|
40445
40532
|
}
|
|
40446
|
-
const raw = env[MCP_DETAIL_CONTEXT_ENV];
|
|
40447
|
-
if (!raw?.trim()) {
|
|
40448
|
-
throw new LinkqueCliError(
|
|
40449
|
-
"MCP_DETAIL_CONTEXT_REQUIRED",
|
|
40450
|
-
"\u7F3A\u5C11\u5E73\u53F0\u4E0B\u53D1\u7684 MCP \u67E5\u8BE2\u59D4\u6258"
|
|
40451
|
-
);
|
|
40452
|
-
}
|
|
40453
|
-
let value;
|
|
40454
|
-
try {
|
|
40455
|
-
if (Buffer.byteLength(raw, "utf8") > 8192) throw new Error();
|
|
40456
|
-
value = JSON.parse(raw);
|
|
40457
|
-
} catch {
|
|
40458
|
-
throw contextError();
|
|
40459
|
-
}
|
|
40460
|
-
const keys = [
|
|
40461
|
-
"schemaVersion",
|
|
40462
|
-
"scope",
|
|
40463
|
-
"executionId",
|
|
40464
|
-
"agentId",
|
|
40465
|
-
"workspaceId",
|
|
40466
|
-
"sprintId",
|
|
40467
|
-
"sessionId",
|
|
40468
|
-
"expiresAt"
|
|
40469
|
-
];
|
|
40470
|
-
if (!object2(value) || Object.keys(value).length !== keys.length || !Object.keys(value).every((key) => keys.includes(key)) || value.schemaVersion !== "1" || value.scope !== "mcp:describe" || typeof value.executionId !== "string" || !/^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/u.test(
|
|
40471
|
-
value.executionId
|
|
40472
|
-
) || !identifier(value.agentId) || !identifier(value.workspaceId) || !identifier(value.sprintId) || !identifier(value.sessionId) || typeof value.expiresAt !== "number" || !Number.isSafeInteger(value.expiresAt) || value.expiresAt <= 0) {
|
|
40473
|
-
throw contextError();
|
|
40474
|
-
}
|
|
40475
|
-
if (value.expiresAt <= Date.now()) {
|
|
40476
|
-
throw new LinkqueCliError(
|
|
40477
|
-
"MCP_DETAIL_CONTEXT_EXPIRED",
|
|
40478
|
-
"MCP \u67E5\u8BE2\u59D4\u6258\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u7531\u5E73\u53F0\u91CD\u65B0\u7B7E\u53D1"
|
|
40479
|
-
);
|
|
40480
|
-
}
|
|
40481
|
-
return {
|
|
40482
|
-
schemaVersion: "1",
|
|
40483
|
-
scope: "mcp:describe",
|
|
40484
|
-
executionId: value.executionId,
|
|
40485
|
-
agentId: value.agentId,
|
|
40486
|
-
workspaceId: value.workspaceId,
|
|
40487
|
-
sprintId: value.sprintId,
|
|
40488
|
-
sessionId: value.sessionId,
|
|
40489
|
-
expiresAt: value.expiresAt
|
|
40490
|
-
};
|
|
40491
|
-
}
|
|
40492
|
-
function contextError() {
|
|
40493
|
-
return new LinkqueCliError(
|
|
40494
|
-
"MCP_DETAIL_CONTEXT_INVALID",
|
|
40495
|
-
"\u5E73\u53F0\u4E0B\u53D1\u7684 MCP \u67E5\u8BE2\u59D4\u6258\u683C\u5F0F\u65E0\u6548"
|
|
40496
|
-
);
|
|
40497
40533
|
}
|
|
40498
40534
|
async function readMountedMcp(cwd, resourceId) {
|
|
40499
40535
|
let content;
|
|
@@ -40538,7 +40574,25 @@ async function readMountedMcp(cwd, resourceId) {
|
|
|
40538
40574
|
if (config3.allowedTools.length > 0)
|
|
40539
40575
|
allowedTools = [...new Set(config3.allowedTools)];
|
|
40540
40576
|
}
|
|
40577
|
+
let abilityCode = resourceId;
|
|
40578
|
+
if (resource.resourceType === "MCP_TOOL") {
|
|
40579
|
+
if (config3.mcpCode !== void 0) {
|
|
40580
|
+
if (!identifier(config3.mcpCode)) throw configError();
|
|
40581
|
+
abilityCode = config3.mcpCode;
|
|
40582
|
+
} else {
|
|
40583
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
40584
|
+
for (const item of value.agent.resources) {
|
|
40585
|
+
if (object2(item) && item.resourceType === "MCP" && item.providerType === "ALIPAY_OPEN" && object2(item.config) && item.config.serverName === config3.serverName) {
|
|
40586
|
+
if (!identifier(item.resourceId)) throw configError();
|
|
40587
|
+
candidates.add(item.resourceId);
|
|
40588
|
+
}
|
|
40589
|
+
}
|
|
40590
|
+
if (candidates.size !== 1) throw configError();
|
|
40591
|
+
abilityCode = [...candidates][0];
|
|
40592
|
+
}
|
|
40593
|
+
}
|
|
40541
40594
|
return {
|
|
40595
|
+
abilityCode,
|
|
40542
40596
|
agentId: value.agentId,
|
|
40543
40597
|
resourceId,
|
|
40544
40598
|
resourceType: resource.resourceType,
|
|
@@ -40562,8 +40616,8 @@ function resolveEndpoint(value) {
|
|
|
40562
40616
|
}
|
|
40563
40617
|
}
|
|
40564
40618
|
async function readResponse(response) {
|
|
40565
|
-
const
|
|
40566
|
-
if (
|
|
40619
|
+
const contentType2 = response.headers.get("content-type")?.split(";")[0].trim();
|
|
40620
|
+
if (contentType2 !== "application/json" || !response.body) {
|
|
40567
40621
|
await response.body?.cancel();
|
|
40568
40622
|
throw responseError();
|
|
40569
40623
|
}
|
|
@@ -40590,7 +40644,7 @@ async function readResponse(response) {
|
|
|
40590
40644
|
throw responseError();
|
|
40591
40645
|
}
|
|
40592
40646
|
}
|
|
40593
|
-
function parseDetail(value, mounted
|
|
40647
|
+
function parseDetail(value, mounted) {
|
|
40594
40648
|
if (!object2(value)) throw responseError();
|
|
40595
40649
|
if (value.success === false) {
|
|
40596
40650
|
throw businessError(value) ?? new LinkqueCliError(
|
|
@@ -40599,7 +40653,7 @@ function parseDetail(value, mounted, context) {
|
|
|
40599
40653
|
);
|
|
40600
40654
|
}
|
|
40601
40655
|
const data = value.data;
|
|
40602
|
-
if (value.success !== true || !object2(data) || data.schemaVersion !== "
|
|
40656
|
+
if (value.success !== true || !object2(data) || data.schemaVersion !== "3" || data.abilityCode !== mounted.abilityCode || !Array.isArray(data.tools) || data.tools.length > 256)
|
|
40603
40657
|
throw responseError();
|
|
40604
40658
|
const names = /* @__PURE__ */ new Set();
|
|
40605
40659
|
const tools = data.tools.map((tool) => {
|
|
@@ -40620,17 +40674,15 @@ function parseDetail(value, mounted, context) {
|
|
|
40620
40674
|
};
|
|
40621
40675
|
});
|
|
40622
40676
|
return {
|
|
40623
|
-
schemaVersion: "
|
|
40677
|
+
schemaVersion: "3",
|
|
40678
|
+
abilityCode: mounted.abilityCode,
|
|
40624
40679
|
agentId: mounted.agentId,
|
|
40625
|
-
workspaceId: context.workspaceId,
|
|
40626
|
-
sprintId: context.sprintId,
|
|
40627
|
-
sessionId: context.sessionId,
|
|
40628
40680
|
resourceId: mounted.resourceId,
|
|
40629
40681
|
resourceType: mounted.resourceType,
|
|
40630
40682
|
serverName: mounted.serverName,
|
|
40631
40683
|
...optionalText(data, "abilityName"),
|
|
40632
40684
|
...optionalText(data, "abilityVersion"),
|
|
40633
|
-
//
|
|
40685
|
+
// 按当前本地资源过滤展示工具;这是调用方选择,不是服务端授权。
|
|
40634
40686
|
tools: tools.filter(
|
|
40635
40687
|
(tool) => !mounted.allowedTools || mounted.allowedTools.includes(tool.toolName)
|
|
40636
40688
|
)
|
|
@@ -40675,26 +40727,6 @@ function businessError(value, status2) {
|
|
|
40675
40727
|
status: 503,
|
|
40676
40728
|
message: "\u5F53\u524D\u4F1A\u8BDD\u672A\u542F\u7528 MCP \u8BE6\u60C5\u67E5\u8BE2\uFF0C\u65E0\u6CD5\u5B8C\u6210\u6570\u636E\u7ED1\u5B9A"
|
|
40677
40729
|
},
|
|
40678
|
-
EXECUTION_INVALID: {
|
|
40679
|
-
code: "MCP_DETAIL_CONTEXT_INVALID",
|
|
40680
|
-
status: 403,
|
|
40681
|
-
message: "Mng \u62D2\u7EDD MCP \u67E5\u8BE2\u59D4\u6258"
|
|
40682
|
-
},
|
|
40683
|
-
EXECUTION_CONTEXT_MISMATCH: {
|
|
40684
|
-
code: "MCP_DETAIL_CONTEXT_MISMATCH",
|
|
40685
|
-
status: 403,
|
|
40686
|
-
message: "MCP \u67E5\u8BE2\u59D4\u6258\u4E0E\u5F53\u524D\u4F1A\u8BDD\u4E0D\u5339\u914D"
|
|
40687
|
-
},
|
|
40688
|
-
EXECUTION_EXPIRED: {
|
|
40689
|
-
code: "MCP_DETAIL_CONTEXT_EXPIRED",
|
|
40690
|
-
status: 410,
|
|
40691
|
-
message: "MCP \u67E5\u8BE2\u59D4\u6258\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u7531\u5E73\u53F0\u91CD\u65B0\u7B7E\u53D1"
|
|
40692
|
-
},
|
|
40693
|
-
EXECUTION_REVOKED: {
|
|
40694
|
-
code: "MCP_DETAIL_CONTEXT_REVOKED",
|
|
40695
|
-
status: 410,
|
|
40696
|
-
message: "MCP \u67E5\u8BE2\u59D4\u6258\u5DF2\u64A4\u9500"
|
|
40697
|
-
},
|
|
40698
40730
|
AUTH_REQUIRED: {
|
|
40699
40731
|
code: "MCP_DETAIL_AUTH_REQUIRED",
|
|
40700
40732
|
status: 401,
|
|
@@ -43953,11 +43985,6 @@ var mcpDescribe = {
|
|
|
43953
43985
|
name: MCP_DETAIL_ENDPOINT_ENV,
|
|
43954
43986
|
description: "\u542F\u7528\u65F6\u5FC5\u586B\u7684\u5E73\u53F0\u5B8C\u6574\u8BE6\u60C5\u67E5\u8BE2\u7AEF\u70B9\uFF0C\u65E0\u751F\u4EA7\u9ED8\u8BA4\u503C",
|
|
43955
43987
|
required: true
|
|
43956
|
-
},
|
|
43957
|
-
{
|
|
43958
|
-
name: MCP_DETAIL_CONTEXT_ENV,
|
|
43959
|
-
description: "\u542F\u7528\u65F6\u5FC5\u586B\u7684\u5E73\u53F0 MCP \u67E5\u8BE2\u59D4\u6258 JSON\uFF0C\u4E0D\u63A5\u53D7\u7528\u6237 token \u6216 AAK \u964D\u7EA7",
|
|
43960
|
-
required: true
|
|
43961
43988
|
}
|
|
43962
43989
|
],
|
|
43963
43990
|
summarize: ({ serverName, tools }) => `${serverName}\uFF1A\u5DF2\u8BFB\u53D6 ${tools.length} \u4E2A\u5DE5\u5177\u8BE6\u60C5\u3002\u4F7F\u7528 --json \u83B7\u53D6\u5B8C\u6574 Schema\u3002
|
package/package.json
CHANGED