linkque-cli-v2 1.6.24 → 1.6.25
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 +1792 -1216
- package/package.json +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-X2R6PIPU.js → chunk-AK4WBETU.js} +2 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-HC6DKXYK.js → chunk-GX2YWAMV.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-2D6TBUEQ.js → chunk-IMRER6VX.js} +292 -34
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js +21697 -6948
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/clientCapability.js +2 -2
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/protocol.js +2 -2
- package/worker.js +17169 -1388
package/linkquejs.js
CHANGED
|
@@ -10376,7 +10376,7 @@ var require_jmespath = __commonJS({
|
|
|
10376
10376
|
return false;
|
|
10377
10377
|
}
|
|
10378
10378
|
}
|
|
10379
|
-
function
|
|
10379
|
+
function isObject3(obj) {
|
|
10380
10380
|
if (obj !== null) {
|
|
10381
10381
|
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
10382
10382
|
} else {
|
|
@@ -10402,7 +10402,7 @@ var require_jmespath = __commonJS({
|
|
|
10402
10402
|
}
|
|
10403
10403
|
return true;
|
|
10404
10404
|
}
|
|
10405
|
-
if (
|
|
10405
|
+
if (isObject3(first) === true) {
|
|
10406
10406
|
var keysSeen = {};
|
|
10407
10407
|
for (var key in first) {
|
|
10408
10408
|
if (hasOwnProperty.call(first, key)) {
|
|
@@ -10428,7 +10428,7 @@ var require_jmespath = __commonJS({
|
|
|
10428
10428
|
return true;
|
|
10429
10429
|
} else if (isArray(obj) && obj.length === 0) {
|
|
10430
10430
|
return true;
|
|
10431
|
-
} else if (
|
|
10431
|
+
} else if (isObject3(obj)) {
|
|
10432
10432
|
for (var key in obj) {
|
|
10433
10433
|
if (obj.hasOwnProperty(key)) {
|
|
10434
10434
|
return false;
|
|
@@ -11145,7 +11145,7 @@ var require_jmespath = __commonJS({
|
|
|
11145
11145
|
var matched, current, result, first, second, field, left, right, collected, i;
|
|
11146
11146
|
switch (node.type) {
|
|
11147
11147
|
case "Field":
|
|
11148
|
-
if (value !== null &&
|
|
11148
|
+
if (value !== null && isObject3(value)) {
|
|
11149
11149
|
field = value[node.name];
|
|
11150
11150
|
if (field === void 0) {
|
|
11151
11151
|
return null;
|
|
@@ -11215,7 +11215,7 @@ var require_jmespath = __commonJS({
|
|
|
11215
11215
|
return collected;
|
|
11216
11216
|
case "ValueProjection":
|
|
11217
11217
|
base = this.visit(node.children[0], value);
|
|
11218
|
-
if (!
|
|
11218
|
+
if (!isObject3(base)) {
|
|
11219
11219
|
return null;
|
|
11220
11220
|
}
|
|
11221
11221
|
collected = [];
|
|
@@ -11612,7 +11612,7 @@ var require_jmespath = __commonJS({
|
|
|
11612
11612
|
return Math.floor(resolvedArgs[0]);
|
|
11613
11613
|
},
|
|
11614
11614
|
_functionLength: function(resolvedArgs) {
|
|
11615
|
-
if (!
|
|
11615
|
+
if (!isObject3(resolvedArgs[0])) {
|
|
11616
11616
|
return resolvedArgs[0].length;
|
|
11617
11617
|
} else {
|
|
11618
11618
|
return Object.keys(resolvedArgs[0]).length;
|
|
@@ -31988,10 +31988,10 @@ var init_codec_pool = __esm({
|
|
|
31988
31988
|
});
|
|
31989
31989
|
|
|
31990
31990
|
// ../../node_modules/@zip.js/zip.js/lib/core/util/decode-cp437.js
|
|
31991
|
-
function decodeCP437(
|
|
31991
|
+
function decodeCP437(stringValue2) {
|
|
31992
31992
|
let result = "";
|
|
31993
|
-
for (let indexCharacter = 0; indexCharacter <
|
|
31994
|
-
result += CP437[
|
|
31993
|
+
for (let indexCharacter = 0; indexCharacter < stringValue2.length; indexCharacter++) {
|
|
31994
|
+
result += CP437[stringValue2[indexCharacter]];
|
|
31995
31995
|
}
|
|
31996
31996
|
return result;
|
|
31997
31997
|
}
|
|
@@ -37810,820 +37810,232 @@ var withWorkspaceLock = async (options, operation) => {
|
|
|
37810
37810
|
|
|
37811
37811
|
// src/commands/agentbuild/bundlerRoller.ts
|
|
37812
37812
|
var import_esbuild = require("esbuild");
|
|
37813
|
-
|
|
37814
|
-
|
|
37815
|
-
var
|
|
37816
|
-
|
|
37817
|
-
|
|
37818
|
-
|
|
37819
|
-
}
|
|
37820
|
-
var
|
|
37821
|
-
|
|
37822
|
-
"
|
|
37823
|
-
|
|
37824
|
-
|
|
37825
|
-
|
|
37826
|
-
|
|
37827
|
-
|
|
37828
|
-
|
|
37829
|
-
|
|
37830
|
-
|
|
37831
|
-
|
|
37832
|
-
|
|
37833
|
-
|
|
37834
|
-
|
|
37835
|
-
|
|
37836
|
-
|
|
37837
|
-
|
|
37838
|
-
|
|
37839
|
-
|
|
37840
|
-
|
|
37841
|
-
|
|
37842
|
-
|
|
37843
|
-
|
|
37844
|
-
|
|
37845
|
-
|
|
37846
|
-
|
|
37847
|
-
|
|
37848
|
-
|
|
37849
|
-
|
|
37850
|
-
|
|
37851
|
-
|
|
37852
|
-
|
|
37853
|
-
|
|
37854
|
-
|
|
37855
|
-
|
|
37856
|
-
|
|
37857
|
-
|
|
37858
|
-
|
|
37859
|
-
|
|
37860
|
-
|
|
37861
|
-
|
|
37862
|
-
|
|
37863
|
-
|
|
37864
|
-
|
|
37865
|
-
|
|
37866
|
-
|
|
37867
|
-
|
|
37868
|
-
|
|
37869
|
-
|
|
37870
|
-
|
|
37871
|
-
|
|
37872
|
-
|
|
37873
|
-
|
|
37874
|
-
|
|
37875
|
-
|
|
37876
|
-
|
|
37877
|
-
|
|
37878
|
-
|
|
37879
|
-
|
|
37880
|
-
|
|
37881
|
-
|
|
37882
|
-
|
|
37883
|
-
|
|
37884
|
-
|
|
37885
|
-
packages: {}
|
|
37886
|
-
})}
|
|
37887
|
-
`,
|
|
37888
|
-
"utf8"
|
|
37889
|
-
);
|
|
37890
|
-
const bytes = (0, import_node_fs7.statSync)(outputPath).size;
|
|
37891
|
-
const gzipBytes = (0, import_node_zlib.gzipSync)(Buffer.from(outputFile.text, "utf8")).length;
|
|
37892
|
-
return { outputPath, bytes, gzipBytes, durationMs: Date.now() - startedAt };
|
|
37893
|
-
} finally {
|
|
37894
|
-
(0, import_node_fs7.rmSync)(bakeDir, { recursive: true, force: true });
|
|
37813
|
+
|
|
37814
|
+
// ../linkque-agent-protocol/dist/esm/agentProtocol.js
|
|
37815
|
+
var EModelProvider;
|
|
37816
|
+
(function(EModelProvider2) {
|
|
37817
|
+
EModelProvider2["LINKQUE"] = "LINKQUE";
|
|
37818
|
+
EModelProvider2["TEST"] = "TEST";
|
|
37819
|
+
})(EModelProvider || (EModelProvider = {}));
|
|
37820
|
+
var EResourceType;
|
|
37821
|
+
(function(EResourceType2) {
|
|
37822
|
+
EResourceType2["SKILL"] = "SKILL";
|
|
37823
|
+
EResourceType2["MCP"] = "MCP";
|
|
37824
|
+
EResourceType2["MCP_TOOL"] = "MCP_TOOL";
|
|
37825
|
+
EResourceType2["REMOTE_AGENT"] = "REMOTE_AGENT";
|
|
37826
|
+
EResourceType2["KNOWLEDGE"] = "KNOWLEDGE";
|
|
37827
|
+
EResourceType2["CARD"] = "CARD";
|
|
37828
|
+
EResourceType2["TOOL"] = "TOOL";
|
|
37829
|
+
EResourceType2["WEB_SEARCH"] = "WEB_SEARCH";
|
|
37830
|
+
EResourceType2["MEMORY"] = "MEMORY";
|
|
37831
|
+
EResourceType2["FOLLOW_UP_QUESTIONS"] = "FOLLOW_UP_QUESTIONS";
|
|
37832
|
+
EResourceType2["CLIENT_CAPABILITY"] = "CLIENT_CAPABILITY";
|
|
37833
|
+
EResourceType2["HOOK"] = "HOOK";
|
|
37834
|
+
})(EResourceType || (EResourceType = {}));
|
|
37835
|
+
var EResourceProviderType;
|
|
37836
|
+
(function(EResourceProviderType2) {
|
|
37837
|
+
EResourceProviderType2["ALIPAY_OPEN"] = "ALIPAY_OPEN";
|
|
37838
|
+
EResourceProviderType2["LINK_QUE"] = "LINK_QUE";
|
|
37839
|
+
EResourceProviderType2["BUILTIN"] = "BUILTIN";
|
|
37840
|
+
})(EResourceProviderType || (EResourceProviderType = {}));
|
|
37841
|
+
var EArgsMappingValueType;
|
|
37842
|
+
(function(EArgsMappingValueType2) {
|
|
37843
|
+
EArgsMappingValueType2["DEFAULT"] = "DEFAULT";
|
|
37844
|
+
EArgsMappingValueType2["CONST"] = "CONST";
|
|
37845
|
+
EArgsMappingValueType2["SYSTEM_VARIABLE"] = "SYSTEM_VARIABLE";
|
|
37846
|
+
})(EArgsMappingValueType || (EArgsMappingValueType = {}));
|
|
37847
|
+
var EHookStage;
|
|
37848
|
+
(function(EHookStage2) {
|
|
37849
|
+
EHookStage2["PREPARE_AGENT_LOOP"] = "PREPARE_AGENT_LOOP";
|
|
37850
|
+
EHookStage2["RUN_STARTED"] = "RUN_STARTED";
|
|
37851
|
+
EHookStage2["RUN_COMPLETED"] = "RUN_COMPLETED";
|
|
37852
|
+
EHookStage2["RUN_FAILED"] = "RUN_FAILED";
|
|
37853
|
+
EHookStage2["RUN_READ"] = "RUN_READ";
|
|
37854
|
+
EHookStage2["AFTER_MODEL_CALL"] = "AFTER_MODEL_CALL";
|
|
37855
|
+
EHookStage2["MODEL_RESPONSE_RECEIVED"] = "MODEL_RESPONSE_RECEIVED";
|
|
37856
|
+
EHookStage2["BEFORE_TOOL_CALL"] = "BEFORE_TOOL_CALL";
|
|
37857
|
+
EHookStage2["AFTER_TOOL_CALL"] = "AFTER_TOOL_CALL";
|
|
37858
|
+
EHookStage2["TOOL_CALL_FAILED"] = "TOOL_CALL_FAILED";
|
|
37859
|
+
})(EHookStage || (EHookStage = {}));
|
|
37860
|
+
var EHookExecutorName;
|
|
37861
|
+
(function(EHookExecutorName2) {
|
|
37862
|
+
EHookExecutorName2["LinkquegwEventHookExecutor"] = "LinkquegwEventHookExecutor";
|
|
37863
|
+
EHookExecutorName2["SecurityAnswerHookExecutor"] = "SecurityAnswerHookExecutor";
|
|
37864
|
+
EHookExecutorName2["ImageUnderstandingHookExecutor"] = "ImageUnderstandingHookExecutor";
|
|
37865
|
+
EHookExecutorName2["McpDiscoveryHookExecutor"] = "McpDiscoveryHookExecutor";
|
|
37866
|
+
EHookExecutorName2["BusinessDataPromptHookExecutor"] = "BusinessDataPromptHookExecutor";
|
|
37867
|
+
EHookExecutorName2["CurrentTimeHookExecutor"] = "CurrentTimeHookExecutor";
|
|
37868
|
+
EHookExecutorName2["A2aHookExecutor"] = "A2aHookExecutor";
|
|
37869
|
+
EHookExecutorName2["MemoryHookExecutor"] = "MemoryHookExecutor";
|
|
37870
|
+
})(EHookExecutorName || (EHookExecutorName = {}));
|
|
37871
|
+
|
|
37872
|
+
// ../linkque-agent-protocol/dist/esm/validator/api/validationRuleExecutionError.js
|
|
37873
|
+
var ValidationRuleExecutionError = class extends Error {
|
|
37874
|
+
ruleId;
|
|
37875
|
+
/**
|
|
37876
|
+
* 构造规则执行异常,供调用方区分实现故障与数据校验失败。
|
|
37877
|
+
*
|
|
37878
|
+
* @param ruleId 执行失败的规则标识。
|
|
37879
|
+
* @param cause 原始异常,保留在 Error.cause 中,不要求其为 Error 实例。
|
|
37880
|
+
*/
|
|
37881
|
+
constructor(ruleId, cause) {
|
|
37882
|
+
super(`\u6821\u9A8C\u89C4\u5219 ${ruleId} \u6267\u884C\u5931\u8D25`, { cause });
|
|
37883
|
+
this.ruleId = ruleId;
|
|
37884
|
+
this.name = "ValidationRuleExecutionError";
|
|
37895
37885
|
}
|
|
37886
|
+
};
|
|
37887
|
+
|
|
37888
|
+
// ../agent-a2ui-card-contract/dist/esm/protocol.js
|
|
37889
|
+
var LINKQUE_A2UI_V4_CATALOG_ID = "urn:linkque:a2ui:runtime:4";
|
|
37890
|
+
|
|
37891
|
+
// ../linkque-agent-data-binding-contract/dist/esm/json.js
|
|
37892
|
+
var BLOCKED_PATH_SEGMENTS = /* @__PURE__ */ new Set([
|
|
37893
|
+
"__proto__",
|
|
37894
|
+
"constructor",
|
|
37895
|
+
"prototype"
|
|
37896
|
+
]);
|
|
37897
|
+
function isPlainRecord(value) {
|
|
37898
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
37899
|
+
return false;
|
|
37900
|
+
const prototype = Object.getPrototypeOf(value);
|
|
37901
|
+
if (prototype === Object.prototype || prototype === null)
|
|
37902
|
+
return true;
|
|
37903
|
+
const constructor = Object.getOwnPropertyDescriptor(prototype, "constructor")?.value;
|
|
37904
|
+
return Object.getPrototypeOf(prototype) === null && typeof constructor === "function" && Function.prototype.toString.call(constructor) === Function.prototype.toString.call(Object);
|
|
37896
37905
|
}
|
|
37897
|
-
|
|
37898
|
-
|
|
37899
|
-
|
|
37900
|
-
const portableWasm = (0, import_node_path10.join)(portableRoot, "emscripten-module.wasm");
|
|
37901
|
-
if ((0, import_node_fs7.existsSync)(portableWorker) && (0, import_node_fs7.existsSync)(portableWasm)) {
|
|
37902
|
-
(0, import_node_fs7.copyFileSync)(portableWorker, (0, import_node_path10.join)(outDir, "dataTransformWorker.js"));
|
|
37903
|
-
(0, import_node_fs7.copyFileSync)(portableWasm, (0, import_node_path10.join)(outDir, "emscripten-module.wasm"));
|
|
37904
|
-
return;
|
|
37906
|
+
function isJsonValue(value) {
|
|
37907
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
37908
|
+
return true;
|
|
37905
37909
|
}
|
|
37906
|
-
|
|
37907
|
-
|
|
37908
|
-
|
|
37909
|
-
|
|
37910
|
-
|
|
37911
|
-
resolver.resolve("@jitl/quickjs-wasmfile-release-sync/package.json")
|
|
37912
|
-
);
|
|
37913
|
-
const workerEntry = (0, import_node_path10.join)(runtimeRoot, "dist/esm/core/dataTransformWorker.js");
|
|
37914
|
-
const variantCjs = (0, import_node_path10.join)(quickJsRoot, "dist/index.js");
|
|
37915
|
-
const emscriptenCjs = (0, import_node_path10.join)(quickJsRoot, "dist/emscripten-module.cjs");
|
|
37916
|
-
await (0, import_esbuild.build)({
|
|
37917
|
-
entryPoints: [workerEntry],
|
|
37918
|
-
bundle: true,
|
|
37919
|
-
format: "cjs",
|
|
37920
|
-
platform: "node",
|
|
37921
|
-
target: "node22",
|
|
37922
|
-
outfile: (0, import_node_path10.join)(outDir, "dataTransformWorker.js"),
|
|
37923
|
-
minify,
|
|
37924
|
-
sourcemap: false,
|
|
37925
|
-
treeShaking: true,
|
|
37926
|
-
legalComments: "none",
|
|
37927
|
-
logLevel: "warning",
|
|
37928
|
-
plugins: [
|
|
37929
|
-
{
|
|
37930
|
-
name: "quickjs-node-cjs",
|
|
37931
|
-
setup(api) {
|
|
37932
|
-
api.onResolve(
|
|
37933
|
-
{ filter: /^@jitl\/quickjs-wasmfile-release-sync$/u },
|
|
37934
|
-
() => ({ path: variantCjs })
|
|
37935
|
-
);
|
|
37936
|
-
api.onResolve(
|
|
37937
|
-
{
|
|
37938
|
-
filter: /^@jitl\/quickjs-wasmfile-release-sync\/emscripten-module$/u
|
|
37939
|
-
},
|
|
37940
|
-
() => ({ path: emscriptenCjs })
|
|
37941
|
-
);
|
|
37942
|
-
}
|
|
37943
|
-
}
|
|
37944
|
-
]
|
|
37945
|
-
});
|
|
37946
|
-
(0, import_node_fs7.copyFileSync)(
|
|
37947
|
-
(0, import_node_path10.join)(quickJsRoot, "dist/emscripten-module.wasm"),
|
|
37948
|
-
(0, import_node_path10.join)(outDir, "emscripten-module.wasm")
|
|
37949
|
-
);
|
|
37950
|
-
}
|
|
37951
|
-
function prepareBakeDir(bakeDir) {
|
|
37952
|
-
(0, import_node_fs7.rmSync)(bakeDir, { recursive: true, force: true });
|
|
37953
|
-
(0, import_node_fs7.mkdirSync)(bakeDir, { recursive: true });
|
|
37910
|
+
if (typeof value === "number")
|
|
37911
|
+
return Number.isFinite(value);
|
|
37912
|
+
if (Array.isArray(value))
|
|
37913
|
+
return value.every(isJsonValue);
|
|
37914
|
+
return isPlainRecord(value) && Object.values(value).every(isJsonValue);
|
|
37954
37915
|
}
|
|
37955
|
-
function
|
|
37956
|
-
|
|
37957
|
-
const code = `import { setBakedProtocol } from '${distModulePath(pkgRoot, PROTOCOL_DIST_PATH)}';
|
|
37958
|
-
setBakedProtocol(${protocolJson});
|
|
37959
|
-
`;
|
|
37960
|
-
(0, import_node_fs7.writeFileSync)((0, import_node_path10.join)(bakeDir, "protocol.generated.js"), code, "utf8");
|
|
37916
|
+
function cloneJsonValue(value) {
|
|
37917
|
+
return isJsonValue(value) ? JSON.parse(JSON.stringify(value)) : void 0;
|
|
37961
37918
|
}
|
|
37962
|
-
function
|
|
37963
|
-
|
|
37964
|
-
|
|
37965
|
-
|
|
37966
|
-
`;
|
|
37967
|
-
const entryPath = (0, import_node_path10.join)(bakeDir, "entry.js");
|
|
37968
|
-
(0, import_node_fs7.writeFileSync)(entryPath, code, "utf8");
|
|
37969
|
-
return entryPath;
|
|
37919
|
+
function cloneJsonObject(value) {
|
|
37920
|
+
if (!isPlainRecord(value) || !isJsonValue(value))
|
|
37921
|
+
return void 0;
|
|
37922
|
+
return JSON.parse(JSON.stringify(value));
|
|
37970
37923
|
}
|
|
37971
|
-
|
|
37972
|
-
|
|
37973
|
-
|
|
37974
|
-
|
|
37975
|
-
|
|
37976
|
-
if (!protocol.name) issues.push("name \u5FC5\u586B");
|
|
37977
|
-
if (!protocol.version) issues.push("version \u5FC5\u586B");
|
|
37978
|
-
if (!protocol.agent?.model) issues.push("agent.model \u5FC5\u586B");
|
|
37979
|
-
if (!protocol.agent?.systemPrompt) issues.push("agent.systemPrompt \u5FC5\u586B");
|
|
37980
|
-
if (issues.length) {
|
|
37981
|
-
throw new Error(`IAgentProtocol \u6821\u9A8C\u5931\u8D25: ${issues.join("; ")}`);
|
|
37924
|
+
function stableJsonStringify(value) {
|
|
37925
|
+
if (value === null || typeof value !== "object")
|
|
37926
|
+
return JSON.stringify(value);
|
|
37927
|
+
if (Array.isArray(value)) {
|
|
37928
|
+
return `[${value.map(stableJsonStringify).join(",")}]`;
|
|
37982
37929
|
}
|
|
37930
|
+
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${stableJsonStringify(value[key])}`).join(",")}}`;
|
|
37983
37931
|
}
|
|
37984
|
-
|
|
37985
|
-
|
|
37986
|
-
|
|
37932
|
+
function isSafeIdentifier(value) {
|
|
37933
|
+
return typeof value === "string" && value.length > 0 && value.length <= 128 && /^[A-Za-z0-9][A-Za-z0-9._:-]*$/u.test(value);
|
|
37934
|
+
}
|
|
37935
|
+
function isSafeJsonPointer(value, allowWildcard = false) {
|
|
37936
|
+
if (typeof value !== "string" || !value.startsWith("/"))
|
|
37937
|
+
return false;
|
|
37938
|
+
if (value === "/")
|
|
37939
|
+
return true;
|
|
37940
|
+
const segments = value.slice(1).split("/");
|
|
37941
|
+
if (segments.some((segment) => segment === ""))
|
|
37942
|
+
return false;
|
|
37943
|
+
return segments.every((encoded) => {
|
|
37944
|
+
if (!/^(?:[^~]|~[01])*$/u.test(encoded))
|
|
37945
|
+
return false;
|
|
37946
|
+
const segment = decodePointerSegment(encoded);
|
|
37947
|
+
return !BLOCKED_PATH_SEGMENTS.has(segment) && (allowWildcard || segment !== "*");
|
|
37948
|
+
});
|
|
37949
|
+
}
|
|
37950
|
+
function decodePointerSegment(value) {
|
|
37951
|
+
return value.replace(/~1/gu, "/").replace(/~0/gu, "~");
|
|
37987
37952
|
}
|
|
37988
37953
|
|
|
37989
|
-
//
|
|
37990
|
-
var
|
|
37991
|
-
|
|
37992
|
-
|
|
37993
|
-
|
|
37994
|
-
|
|
37995
|
-
|
|
37996
|
-
|
|
37997
|
-
var DEFAULT_ARCHIVE_DIR = ".linkque/artifacts";
|
|
37998
|
-
var AGENTBUILD_LOCK = ".linkque/runtime/agentbuild.lock";
|
|
37999
|
-
var LOCK_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
38000
|
-
var LOCK_RETRY_MS = 100;
|
|
38001
|
-
var DEFAULT_CONFIG_NAME = "agent_config.json";
|
|
38002
|
-
|
|
38003
|
-
// src/commands/agentbuild/configLoader.ts
|
|
38004
|
-
var loadAgentProtocol = async (rawConfigPath, cwd) => {
|
|
38005
|
-
const configPath = import_path7.default.resolve(
|
|
38006
|
-
cwd,
|
|
38007
|
-
rawConfigPath === "" ? DEFAULT_CONFIG_NAME : rawConfigPath
|
|
38008
|
-
);
|
|
38009
|
-
if (!await pathHasKind(configPath, "file")) {
|
|
38010
|
-
throw new LinkqueCliError(
|
|
38011
|
-
"AGENTBUILD_CONFIG_NOT_FOUND",
|
|
38012
|
-
`agent config not found at ${configPath}`
|
|
38013
|
-
);
|
|
38014
|
-
}
|
|
38015
|
-
const content = await readUtf8IfExists(configPath);
|
|
38016
|
-
if (content === null) {
|
|
38017
|
-
throw new LinkqueCliError(
|
|
38018
|
-
"AGENTBUILD_CONFIG_INVALID",
|
|
38019
|
-
`agent config could not be read at ${configPath}`
|
|
38020
|
-
);
|
|
38021
|
-
}
|
|
38022
|
-
const root = parseJsonObject(
|
|
38023
|
-
content,
|
|
38024
|
-
"AGENTBUILD_CONFIG_INVALID",
|
|
38025
|
-
`agent config at ${configPath} is not a JSON object`
|
|
38026
|
-
);
|
|
38027
|
-
if (Object.prototype.hasOwnProperty.call(root, "apiKey")) {
|
|
38028
|
-
throw new LinkqueCliError(
|
|
38029
|
-
"AGENTBUILD_API_KEY_IN_CONFIG",
|
|
38030
|
-
`agent config at ${configPath} must not carry an 'apiKey' field (use env LINKQUE_API_KEY instead)`
|
|
38031
|
-
);
|
|
38032
|
-
}
|
|
38033
|
-
return root;
|
|
38034
|
-
};
|
|
38035
|
-
|
|
38036
|
-
// ../linkque-agent-runtime/dist/esm/core/executionScene.js
|
|
38037
|
-
var EExecutionScene;
|
|
38038
|
-
(function(EExecutionScene2) {
|
|
38039
|
-
EExecutionScene2["DEVICE_PREVIEW"] = "DEVICE_PREVIEW";
|
|
38040
|
-
EExecutionScene2["SANDBOX_PREVIEW"] = "SANDBOX_PREVIEW";
|
|
38041
|
-
EExecutionScene2["LIVE"] = "LIVE";
|
|
38042
|
-
EExecutionScene2["UNKNOWN"] = "UNKNOWN";
|
|
38043
|
-
})(EExecutionScene || (EExecutionScene = {}));
|
|
38044
|
-
|
|
38045
|
-
// ../linkque-agent-runtime/dist/esm/core/mcpExecutionResult.js
|
|
38046
|
-
var EMcpErrorCode;
|
|
38047
|
-
(function(EMcpErrorCode2) {
|
|
38048
|
-
EMcpErrorCode2["ERR_UNKOWN"] = "ERR_UNKOWN";
|
|
38049
|
-
EMcpErrorCode2["ERR_AUTH"] = "ERR_AUTH";
|
|
38050
|
-
})(EMcpErrorCode || (EMcpErrorCode = {}));
|
|
38051
|
-
|
|
38052
|
-
// ../linkque-agent-runtime/dist/esm/core/modelRequestSource.js
|
|
38053
|
-
var EModelRequestSource;
|
|
38054
|
-
(function(EModelRequestSource2) {
|
|
38055
|
-
EModelRequestSource2["LINKQUE_EDITOR"] = "LINKQUE_EDITOR";
|
|
38056
|
-
EModelRequestSource2["APPBASE_FUNCTION"] = "APPBASE_FUNCTION";
|
|
38057
|
-
})(EModelRequestSource || (EModelRequestSource = {}));
|
|
37954
|
+
// ../linkque-agent-data-binding-contract/dist/esm/schema.js
|
|
37955
|
+
var import_ajv = __toESM(require_ajv(), 1);
|
|
37956
|
+
var AjvConstructor = import_ajv.default;
|
|
37957
|
+
var ajv = new AjvConstructor({
|
|
37958
|
+
allErrors: true,
|
|
37959
|
+
strict: false,
|
|
37960
|
+
validateSchema: true
|
|
37961
|
+
});
|
|
38058
37962
|
|
|
38059
|
-
// ../linkque-agent-
|
|
38060
|
-
var
|
|
38061
|
-
var import_node_worker_threads = require("node:worker_threads");
|
|
37963
|
+
// ../linkque-agent-data-binding-contract/dist/esm/structural.js
|
|
37964
|
+
var import_jmespath = __toESM(require_jmespath(), 1);
|
|
38062
37965
|
|
|
38063
|
-
// ../
|
|
38064
|
-
|
|
38065
|
-
|
|
38066
|
-
|
|
38067
|
-
|
|
38068
|
-
if (
|
|
38069
|
-
|
|
37966
|
+
// ../agent-a2ui-card-contract/dist/esm/json.js
|
|
37967
|
+
function canonicalizeBindingPath(rawPath, listRoot) {
|
|
37968
|
+
let candidate = rawPath.trim();
|
|
37969
|
+
if (candidate === "")
|
|
37970
|
+
return void 0;
|
|
37971
|
+
if (candidate.startsWith("./")) {
|
|
37972
|
+
if (!listRoot || !isSafeJsonPointer(listRoot, true))
|
|
37973
|
+
return void 0;
|
|
37974
|
+
candidate = `${listRoot === "/" ? "" : listRoot}/*/${candidate.slice(2)}`;
|
|
37975
|
+
} else if (candidate === ".") {
|
|
37976
|
+
if (!listRoot || !isSafeJsonPointer(listRoot, true))
|
|
37977
|
+
return void 0;
|
|
37978
|
+
candidate = `${listRoot === "/" ? "" : listRoot}/*`;
|
|
37979
|
+
} else if (!candidate.startsWith("/")) {
|
|
37980
|
+
candidate = `/${candidate}`;
|
|
38070
37981
|
}
|
|
38071
|
-
return
|
|
37982
|
+
return isSafeJsonPointer(candidate, true) ? candidate : void 0;
|
|
38072
37983
|
}
|
|
38073
|
-
|
|
38074
|
-
|
|
38075
|
-
|
|
38076
|
-
|
|
38077
|
-
throw new TypeError("AI \u7B5B\u9009\u7ED3\u679C\u5FC5\u987B\u662F\u8303\u56F4\u5408\u6CD5\u4E14\u4E0D\u91CD\u590D\u7684\u6574\u6570\u4E0B\u6807\u6570\u7EC4");
|
|
38078
|
-
}
|
|
38079
|
-
return value;
|
|
37984
|
+
function issue2(path28, code, message) {
|
|
37985
|
+
return { path: path28, code, message };
|
|
37986
|
+
}
|
|
37987
|
+
function exactKeys(value, allowed, path28, issues) {
|
|
38080
37988
|
}
|
|
38081
37989
|
|
|
38082
|
-
// ../
|
|
38083
|
-
|
|
38084
|
-
|
|
38085
|
-
|
|
38086
|
-
|
|
38087
|
-
|
|
38088
|
-
memoryBytes: 32 * 1024 * 1024,
|
|
38089
|
-
stackBytes: 512 * 1024,
|
|
38090
|
-
executionMs: 100,
|
|
38091
|
-
watchdogMs: 500,
|
|
38092
|
-
initializationMs: 5e3,
|
|
38093
|
-
maxConcurrent: 4,
|
|
38094
|
-
maxQueued: 32
|
|
38095
|
-
});
|
|
38096
|
-
var DataTransformError = class extends Error {
|
|
38097
|
-
code;
|
|
38098
|
-
sourceHash;
|
|
38099
|
-
constructor(code, message, sourceHash) {
|
|
38100
|
-
super(message);
|
|
38101
|
-
this.code = code;
|
|
38102
|
-
this.sourceHash = sourceHash;
|
|
38103
|
-
this.name = "DataTransformError";
|
|
38104
|
-
}
|
|
38105
|
-
};
|
|
38106
|
-
var DataTransformExecutor = class {
|
|
38107
|
-
workerUrl;
|
|
38108
|
-
queue = [];
|
|
38109
|
-
slots = [];
|
|
38110
|
-
nextRequestId = 1;
|
|
38111
|
-
disposed = false;
|
|
38112
|
-
constructor(workerUrl = defaultDataTransformWorkerUrl()) {
|
|
38113
|
-
this.workerUrl = workerUrl;
|
|
37990
|
+
// ../agent-a2ui-card-contract/dist/esm/digest.js
|
|
37991
|
+
function sha256Hex(value) {
|
|
37992
|
+
const bytes = new TextEncoder().encode(value);
|
|
37993
|
+
const words = [];
|
|
37994
|
+
for (let index = 0; index < bytes.length; index += 1) {
|
|
37995
|
+
words[index >> 2] = (words[index >> 2] ?? 0) | bytes[index] << 24 - index % 4 * 8;
|
|
38114
37996
|
}
|
|
38115
|
-
|
|
38116
|
-
|
|
38117
|
-
|
|
38118
|
-
|
|
38119
|
-
|
|
38120
|
-
|
|
38121
|
-
|
|
38122
|
-
|
|
38123
|
-
|
|
38124
|
-
|
|
38125
|
-
|
|
38126
|
-
|
|
38127
|
-
|
|
38128
|
-
|
|
38129
|
-
|
|
38130
|
-
const
|
|
38131
|
-
|
|
38132
|
-
|
|
37997
|
+
const bitLength = bytes.length * 8;
|
|
37998
|
+
words[bitLength >> 5] = (words[bitLength >> 5] ?? 0) | 128 << 24 - bitLength % 32;
|
|
37999
|
+
words[(bitLength + 64 >> 9 << 4) + 15] = bitLength;
|
|
38000
|
+
const constants2 = SHA256_CONSTANTS;
|
|
38001
|
+
let state = [
|
|
38002
|
+
1779033703,
|
|
38003
|
+
3144134277,
|
|
38004
|
+
1013904242,
|
|
38005
|
+
2773480762,
|
|
38006
|
+
1359893119,
|
|
38007
|
+
2600822924,
|
|
38008
|
+
528734635,
|
|
38009
|
+
1541459225
|
|
38010
|
+
];
|
|
38011
|
+
for (let offset = 0; offset < words.length; offset += 16) {
|
|
38012
|
+
const schedule = Array.from({ length: 64 }, () => 0);
|
|
38013
|
+
for (let index = 0; index < 16; index += 1) {
|
|
38014
|
+
schedule[index] = words[offset + index] ?? 0;
|
|
38133
38015
|
}
|
|
38134
|
-
|
|
38135
|
-
|
|
38136
|
-
|
|
38016
|
+
for (let index = 16; index < 64; index += 1) {
|
|
38017
|
+
const left = schedule[index - 15];
|
|
38018
|
+
const right = schedule[index - 2];
|
|
38019
|
+
const s0 = rotateRight(left, 7) ^ rotateRight(left, 18) ^ left >>> 3;
|
|
38020
|
+
const s1 = rotateRight(right, 17) ^ rotateRight(right, 19) ^ right >>> 10;
|
|
38021
|
+
schedule[index] = add(schedule[index - 16], s0, schedule[index - 7], s1);
|
|
38137
38022
|
}
|
|
38138
|
-
|
|
38139
|
-
|
|
38140
|
-
|
|
38141
|
-
|
|
38142
|
-
const
|
|
38143
|
-
|
|
38144
|
-
|
|
38145
|
-
|
|
38146
|
-
|
|
38147
|
-
|
|
38148
|
-
|
|
38149
|
-
|
|
38150
|
-
|
|
38151
|
-
|
|
38152
|
-
|
|
38153
|
-
|
|
38154
|
-
inputBytes,
|
|
38155
|
-
signal,
|
|
38156
|
-
options,
|
|
38157
|
-
resolve: (value) => {
|
|
38158
|
-
signal?.removeEventListener("abort", abortQueued);
|
|
38159
|
-
resolve2(value);
|
|
38160
|
-
},
|
|
38161
|
-
reject: (reason) => {
|
|
38162
|
-
signal?.removeEventListener("abort", abortQueued);
|
|
38163
|
-
reject(reason);
|
|
38164
|
-
}
|
|
38165
|
-
};
|
|
38166
|
-
this.queue.push(queued);
|
|
38167
|
-
signal?.addEventListener("abort", abortQueued, { once: true });
|
|
38168
|
-
this.drain();
|
|
38169
|
-
});
|
|
38170
|
-
}
|
|
38171
|
-
validateSource(source, profile) {
|
|
38172
|
-
const sourceBytes = Buffer.byteLength(source, "utf8");
|
|
38173
|
-
const sourceHash = (0, import_node_crypto3.createHash)("sha256").update(source).digest("hex");
|
|
38174
|
-
if (!source.trim() || sourceBytes > DATA_TRANSFORM_LIMITS.sourceBytes) {
|
|
38175
|
-
return Promise.reject(new DataTransformError("CARD_TRANSFORM_SOURCE_INVALID", `\u6570\u636E\u8F6C\u6362\u6E90\u7801\u4E3A\u7A7A\u6216\u8D85\u8FC7 ${DATA_TRANSFORM_LIMITS.sourceBytes} \u5B57\u8282`, sourceHash));
|
|
38176
|
-
}
|
|
38177
|
-
if (this.disposed) {
|
|
38178
|
-
return Promise.reject(new DataTransformError("CARD_TRANSFORM_FAILED", "\u6570\u636E\u8F6C\u6362\u6267\u884C\u5668\u5DF2\u5173\u95ED", sourceHash));
|
|
38179
|
-
}
|
|
38180
|
-
const active = this.slots.filter((slot) => slot.busy).length;
|
|
38181
|
-
if (active >= DATA_TRANSFORM_LIMITS.maxConcurrent && this.queue.length >= DATA_TRANSFORM_LIMITS.maxQueued) {
|
|
38182
|
-
return Promise.reject(new DataTransformError("CARD_TRANSFORM_BUSY", "\u6570\u636E\u8F6C\u6362\u6267\u884C\u961F\u5217\u5DF2\u6EE1", sourceHash));
|
|
38183
|
-
}
|
|
38184
|
-
return new Promise((resolve2, reject) => {
|
|
38185
|
-
this.queue.push({
|
|
38186
|
-
mode: "validate",
|
|
38187
|
-
source,
|
|
38188
|
-
sourceHash,
|
|
38189
|
-
inputJson: "[]",
|
|
38190
|
-
inputBytes: 2,
|
|
38191
|
-
options: { profile },
|
|
38192
|
-
resolve: () => resolve2(),
|
|
38193
|
-
reject
|
|
38194
|
-
});
|
|
38195
|
-
this.drain();
|
|
38196
|
-
});
|
|
38197
|
-
}
|
|
38198
|
-
async close() {
|
|
38199
|
-
this.disposed = true;
|
|
38200
|
-
for (const queued of this.queue.splice(0)) {
|
|
38201
|
-
queued.reject(new DataTransformError("CARD_TRANSFORM_FAILED", "\u6570\u636E\u8F6C\u6362\u6267\u884C\u5668\u5DF2\u5173\u95ED", queued.sourceHash));
|
|
38202
|
-
}
|
|
38203
|
-
await Promise.all(this.slots.splice(0).map(async (slot) => {
|
|
38204
|
-
slot.cancel?.();
|
|
38205
|
-
slot.disposed = true;
|
|
38206
|
-
await slot.worker.terminate();
|
|
38207
|
-
}));
|
|
38208
|
-
}
|
|
38209
|
-
drain() {
|
|
38210
|
-
if (this.disposed)
|
|
38211
|
-
return;
|
|
38212
|
-
while (this.queue.length > 0) {
|
|
38213
|
-
let slot = this.slots.find((candidate) => !candidate.busy);
|
|
38214
|
-
if (!slot && this.slots.length < DATA_TRANSFORM_LIMITS.maxConcurrent) {
|
|
38215
|
-
slot = this.createSlot();
|
|
38216
|
-
this.slots.push(slot);
|
|
38217
|
-
}
|
|
38218
|
-
if (!slot)
|
|
38219
|
-
return;
|
|
38220
|
-
const queued = this.queue.shift();
|
|
38221
|
-
if (!queued)
|
|
38222
|
-
return;
|
|
38223
|
-
if (queued.signal?.aborted) {
|
|
38224
|
-
queued.reject(queued.signal.reason ?? new Error("\u64CD\u4F5C\u5DF2\u53D6\u6D88"));
|
|
38225
|
-
continue;
|
|
38226
|
-
}
|
|
38227
|
-
slot.busy = true;
|
|
38228
|
-
void this.run(slot, queued).finally(() => {
|
|
38229
|
-
if (!slot.disposed)
|
|
38230
|
-
slot.busy = false;
|
|
38231
|
-
this.drain();
|
|
38232
|
-
});
|
|
38233
|
-
}
|
|
38234
|
-
}
|
|
38235
|
-
createSlot() {
|
|
38236
|
-
const worker = new import_node_worker_threads.Worker(this.workerUrl);
|
|
38237
|
-
const slot = {
|
|
38238
|
-
worker,
|
|
38239
|
-
busy: false,
|
|
38240
|
-
disposed: false,
|
|
38241
|
-
ready: Promise.resolve()
|
|
38242
|
-
};
|
|
38243
|
-
slot.ready = new Promise((resolve2, reject) => {
|
|
38244
|
-
const timeout = setTimeout(() => {
|
|
38245
|
-
reject(new DataTransformError("CARD_TRANSFORM_TIMEOUT", "\u6570\u636E\u8F6C\u6362\u5F15\u64CE\u521D\u59CB\u5316\u8D85\u65F6"));
|
|
38246
|
-
this.discardSlot(slot);
|
|
38247
|
-
}, DATA_TRANSFORM_LIMITS.initializationMs);
|
|
38248
|
-
worker.once("message", (message) => {
|
|
38249
|
-
if (message?.type !== "ready")
|
|
38250
|
-
return;
|
|
38251
|
-
clearTimeout(timeout);
|
|
38252
|
-
resolve2();
|
|
38253
|
-
});
|
|
38254
|
-
worker.once("error", (error2) => {
|
|
38255
|
-
clearTimeout(timeout);
|
|
38256
|
-
reject(error2);
|
|
38257
|
-
});
|
|
38258
|
-
worker.once("exit", () => {
|
|
38259
|
-
clearTimeout(timeout);
|
|
38260
|
-
reject(new Error("\u6570\u636E\u8F6C\u6362 Worker \u5DF2\u9000\u51FA"));
|
|
38261
|
-
});
|
|
38262
|
-
});
|
|
38263
|
-
return slot;
|
|
38264
|
-
}
|
|
38265
|
-
async run(slot, queued) {
|
|
38266
|
-
try {
|
|
38267
|
-
await slot.ready;
|
|
38268
|
-
} catch (error2) {
|
|
38269
|
-
queued.reject(error2 instanceof DataTransformError ? error2 : new DataTransformError("CARD_TRANSFORM_FAILED", error2 instanceof Error ? error2.message : "\u6570\u636E\u8F6C\u6362\u5F15\u64CE\u521D\u59CB\u5316\u5931\u8D25", queued.sourceHash));
|
|
38270
|
-
this.discardSlot(slot);
|
|
38271
|
-
return;
|
|
38272
|
-
}
|
|
38273
|
-
if (queued.signal?.aborted) {
|
|
38274
|
-
queued.reject(queued.signal.reason ?? new Error("\u64CD\u4F5C\u5DF2\u53D6\u6D88"));
|
|
38275
|
-
return;
|
|
38276
|
-
}
|
|
38277
|
-
const requestId = this.nextRequestId++;
|
|
38278
|
-
await new Promise((resolve2) => {
|
|
38279
|
-
let settled = false;
|
|
38280
|
-
let watchdog;
|
|
38281
|
-
const scope = new AbortController();
|
|
38282
|
-
const finish = (callback) => {
|
|
38283
|
-
if (settled)
|
|
38284
|
-
return;
|
|
38285
|
-
settled = true;
|
|
38286
|
-
clearTimeout(watchdog);
|
|
38287
|
-
scope.abort();
|
|
38288
|
-
slot.cancel = void 0;
|
|
38289
|
-
queued.signal?.removeEventListener("abort", abort2);
|
|
38290
|
-
slot.worker.off("message", onMessage2);
|
|
38291
|
-
slot.worker.off("error", onError);
|
|
38292
|
-
callback();
|
|
38293
|
-
resolve2();
|
|
38294
|
-
};
|
|
38295
|
-
const abort2 = () => {
|
|
38296
|
-
finish(() => {
|
|
38297
|
-
queued.reject(queued.signal?.reason ?? new Error("\u64CD\u4F5C\u5DF2\u53D6\u6D88"));
|
|
38298
|
-
this.discardSlot(slot);
|
|
38299
|
-
});
|
|
38300
|
-
};
|
|
38301
|
-
const onError = (error2) => {
|
|
38302
|
-
finish(() => {
|
|
38303
|
-
queued.reject(new DataTransformError("CARD_TRANSFORM_FAILED", error2.message, queued.sourceHash));
|
|
38304
|
-
this.discardSlot(slot);
|
|
38305
|
-
});
|
|
38306
|
-
};
|
|
38307
|
-
const armWatchdog = () => {
|
|
38308
|
-
clearTimeout(watchdog);
|
|
38309
|
-
watchdog = setTimeout(() => {
|
|
38310
|
-
finish(() => {
|
|
38311
|
-
queued.reject(new DataTransformError("CARD_TRANSFORM_TIMEOUT", "\u6570\u636E\u8F6C\u6362\u8D85\u8FC7\u5BBF\u4E3B\u6267\u884C\u671F\u9650", queued.sourceHash));
|
|
38312
|
-
this.discardSlot(slot);
|
|
38313
|
-
});
|
|
38314
|
-
}, DATA_TRANSFORM_LIMITS.watchdogMs);
|
|
38315
|
-
};
|
|
38316
|
-
const onMessage2 = (message) => {
|
|
38317
|
-
if (message?.requestId !== requestId || settled)
|
|
38318
|
-
return;
|
|
38319
|
-
if (message.type === "waiting") {
|
|
38320
|
-
clearTimeout(watchdog);
|
|
38321
|
-
} else if (message.type === "running") {
|
|
38322
|
-
armWatchdog();
|
|
38323
|
-
} else if (message.type === "filter") {
|
|
38324
|
-
const reply = (result) => {
|
|
38325
|
-
if (settled)
|
|
38326
|
-
return;
|
|
38327
|
-
armWatchdog();
|
|
38328
|
-
slot.worker.postMessage({
|
|
38329
|
-
type: "filter-result",
|
|
38330
|
-
requestId,
|
|
38331
|
-
callId: message.callId,
|
|
38332
|
-
...result
|
|
38333
|
-
});
|
|
38334
|
-
};
|
|
38335
|
-
void Promise.resolve().then(async () => {
|
|
38336
|
-
if (!queued.options?.aiFilter)
|
|
38337
|
-
throw new Error("\u5F53\u524D\u5DE5\u5177\u672A\u63D0\u4F9B AI \u7B5B\u9009\u80FD\u529B");
|
|
38338
|
-
const indices = await queued.options.aiFilter.select(message.modelList, message.prompt, scope.signal);
|
|
38339
|
-
return validateAIFilterIndices(indices, message.modelList.length);
|
|
38340
|
-
}).then((indices) => reply({ indices }), () => reply({ error: "AI \u7B5B\u9009\u6267\u884C\u5931\u8D25" }));
|
|
38341
|
-
} else if (message.type === "result") {
|
|
38342
|
-
finish(() => this.acceptWorkerResult(queued, message));
|
|
38343
|
-
}
|
|
38344
|
-
};
|
|
38345
|
-
slot.cancel = () => finish(() => queued.reject(new DataTransformError("CARD_TRANSFORM_FAILED", "\u6570\u636E\u8F6C\u6362\u6267\u884C\u5668\u5DF2\u5173\u95ED", queued.sourceHash)));
|
|
38346
|
-
armWatchdog();
|
|
38347
|
-
queued.signal?.addEventListener("abort", abort2, { once: true });
|
|
38348
|
-
slot.worker.on("message", onMessage2);
|
|
38349
|
-
slot.worker.once("error", onError);
|
|
38350
|
-
slot.worker.postMessage({
|
|
38351
|
-
type: "execute",
|
|
38352
|
-
mode: queued.mode,
|
|
38353
|
-
requestId,
|
|
38354
|
-
source: queued.source,
|
|
38355
|
-
inputJson: queued.inputJson,
|
|
38356
|
-
limits: DATA_TRANSFORM_LIMITS,
|
|
38357
|
-
profile: queued.options?.profile,
|
|
38358
|
-
preview: queued.options?.preview === true
|
|
38359
|
-
});
|
|
38360
|
-
});
|
|
38361
|
-
}
|
|
38362
|
-
acceptWorkerResult(queued, message) {
|
|
38363
|
-
if (!message.ok || typeof message.resultJson !== "string") {
|
|
38364
|
-
queued.reject(new DataTransformError(message.code ?? "CARD_TRANSFORM_FAILED", message.message ?? "\u6570\u636E\u8F6C\u6362\u6267\u884C\u5931\u8D25", queued.sourceHash));
|
|
38365
|
-
return;
|
|
38366
|
-
}
|
|
38367
|
-
const outputBytes = Buffer.byteLength(message.resultJson, "utf8");
|
|
38368
|
-
if (outputBytes > DATA_TRANSFORM_LIMITS.outputBytes) {
|
|
38369
|
-
queued.reject(new DataTransformError("CARD_TRANSFORM_OUTPUT_TOO_LARGE", "\u6570\u636E\u8F6C\u6362\u7ED3\u679C\u8D85\u8FC7\u5927\u5C0F\u9650\u5236", queued.sourceHash));
|
|
38370
|
-
return;
|
|
38371
|
-
}
|
|
38372
|
-
try {
|
|
38373
|
-
const data = JSON.parse(message.resultJson);
|
|
38374
|
-
if (data !== null && (typeof data !== "object" || Array.isArray(data) || jsonDepth(data) > DATA_TRANSFORM_LIMITS.maxDepth)) {
|
|
38375
|
-
throw new DataTransformError("CARD_TRANSFORM_OUTPUT_INVALID", "\u6570\u636E\u8F6C\u6362\u7ED3\u679C\u5FC5\u987B\u662F JSON \u5BF9\u8C61\u6216 null", queued.sourceHash);
|
|
38376
|
-
}
|
|
38377
|
-
queued.resolve({
|
|
38378
|
-
data,
|
|
38379
|
-
durationMs: message.durationMs ?? 0,
|
|
38380
|
-
inputBytes: queued.inputBytes,
|
|
38381
|
-
outputBytes,
|
|
38382
|
-
sourceHash: queued.sourceHash
|
|
38383
|
-
});
|
|
38384
|
-
} catch (error2) {
|
|
38385
|
-
queued.reject(error2 instanceof DataTransformError ? error2 : new DataTransformError("CARD_TRANSFORM_OUTPUT_INVALID", "\u6570\u636E\u8F6C\u6362\u7ED3\u679C\u4E0D\u662F\u6709\u6548 JSON", queued.sourceHash));
|
|
38386
|
-
}
|
|
38387
|
-
}
|
|
38388
|
-
discardSlot(slot) {
|
|
38389
|
-
if (slot.disposed)
|
|
38390
|
-
return;
|
|
38391
|
-
slot.disposed = true;
|
|
38392
|
-
const index = this.slots.indexOf(slot);
|
|
38393
|
-
if (index >= 0)
|
|
38394
|
-
this.slots.splice(index, 1);
|
|
38395
|
-
void slot.worker.terminate();
|
|
38396
|
-
}
|
|
38397
|
-
};
|
|
38398
|
-
function jsonDepth(value, depth = 0) {
|
|
38399
|
-
if (value === null || typeof value !== "object")
|
|
38400
|
-
return depth;
|
|
38401
|
-
if (depth > DATA_TRANSFORM_LIMITS.maxDepth)
|
|
38402
|
-
return depth;
|
|
38403
|
-
const children = Array.isArray(value) ? value : Object.values(value);
|
|
38404
|
-
return children.reduce((maximum, child) => Math.max(maximum, jsonDepth(child, depth + 1)), depth);
|
|
38405
|
-
}
|
|
38406
|
-
|
|
38407
|
-
// ../linkque-agent-runtime/dist/esm/core/types.js
|
|
38408
|
-
var EDebugLogScope;
|
|
38409
|
-
(function(EDebugLogScope2) {
|
|
38410
|
-
EDebugLogScope2["A2UI_ACTION"] = "A2UI_ACTION";
|
|
38411
|
-
EDebugLogScope2["CONFIG"] = "CONFIG";
|
|
38412
|
-
EDebugLogScope2["LLM"] = "LLM";
|
|
38413
|
-
EDebugLogScope2["PI_EVENT"] = "PI_EVENT";
|
|
38414
|
-
EDebugLogScope2["MCP"] = "MCP";
|
|
38415
|
-
EDebugLogScope2["SKILL"] = "SKILL";
|
|
38416
|
-
EDebugLogScope2["HTTP"] = "HTTP";
|
|
38417
|
-
EDebugLogScope2["HOOK"] = "HOOK";
|
|
38418
|
-
})(EDebugLogScope || (EDebugLogScope = {}));
|
|
38419
|
-
|
|
38420
|
-
// ../linkque-agent-protocol/dist/esm/agentProtocol.js
|
|
38421
|
-
var EModelProvider;
|
|
38422
|
-
(function(EModelProvider2) {
|
|
38423
|
-
EModelProvider2["LINKQUE"] = "LINKQUE";
|
|
38424
|
-
EModelProvider2["TEST"] = "TEST";
|
|
38425
|
-
})(EModelProvider || (EModelProvider = {}));
|
|
38426
|
-
var EResourceType;
|
|
38427
|
-
(function(EResourceType2) {
|
|
38428
|
-
EResourceType2["SKILL"] = "SKILL";
|
|
38429
|
-
EResourceType2["MCP"] = "MCP";
|
|
38430
|
-
EResourceType2["MCP_TOOL"] = "MCP_TOOL";
|
|
38431
|
-
EResourceType2["KNOWLEDGE"] = "KNOWLEDGE";
|
|
38432
|
-
EResourceType2["CARD"] = "CARD";
|
|
38433
|
-
EResourceType2["TOOL"] = "TOOL";
|
|
38434
|
-
EResourceType2["WEB_SEARCH"] = "WEB_SEARCH";
|
|
38435
|
-
EResourceType2["MEMORY"] = "MEMORY";
|
|
38436
|
-
EResourceType2["FOLLOW_UP_QUESTIONS"] = "FOLLOW_UP_QUESTIONS";
|
|
38437
|
-
EResourceType2["CLIENT_CAPABILITY"] = "CLIENT_CAPABILITY";
|
|
38438
|
-
EResourceType2["HOOK"] = "HOOK";
|
|
38439
|
-
})(EResourceType || (EResourceType = {}));
|
|
38440
|
-
var EResourceProviderType;
|
|
38441
|
-
(function(EResourceProviderType2) {
|
|
38442
|
-
EResourceProviderType2["ALIPAY_OPEN"] = "ALIPAY_OPEN";
|
|
38443
|
-
EResourceProviderType2["LINK_QUE"] = "LINK_QUE";
|
|
38444
|
-
EResourceProviderType2["BUILTIN"] = "BUILTIN";
|
|
38445
|
-
})(EResourceProviderType || (EResourceProviderType = {}));
|
|
38446
|
-
var EArgsMappingValueType;
|
|
38447
|
-
(function(EArgsMappingValueType2) {
|
|
38448
|
-
EArgsMappingValueType2["DEFAULT"] = "DEFAULT";
|
|
38449
|
-
EArgsMappingValueType2["CONST"] = "CONST";
|
|
38450
|
-
EArgsMappingValueType2["SYSTEM_VARIABLE"] = "SYSTEM_VARIABLE";
|
|
38451
|
-
})(EArgsMappingValueType || (EArgsMappingValueType = {}));
|
|
38452
|
-
var EHookStage;
|
|
38453
|
-
(function(EHookStage2) {
|
|
38454
|
-
EHookStage2["PREPARE_AGENT_LOOP"] = "PREPARE_AGENT_LOOP";
|
|
38455
|
-
EHookStage2["RUN_STARTED"] = "RUN_STARTED";
|
|
38456
|
-
EHookStage2["RUN_COMPLETED"] = "RUN_COMPLETED";
|
|
38457
|
-
EHookStage2["RUN_FAILED"] = "RUN_FAILED";
|
|
38458
|
-
EHookStage2["RUN_READ"] = "RUN_READ";
|
|
38459
|
-
EHookStage2["AFTER_MODEL_CALL"] = "AFTER_MODEL_CALL";
|
|
38460
|
-
EHookStage2["MODEL_RESPONSE_RECEIVED"] = "MODEL_RESPONSE_RECEIVED";
|
|
38461
|
-
EHookStage2["BEFORE_TOOL_CALL"] = "BEFORE_TOOL_CALL";
|
|
38462
|
-
EHookStage2["AFTER_TOOL_CALL"] = "AFTER_TOOL_CALL";
|
|
38463
|
-
EHookStage2["TOOL_CALL_FAILED"] = "TOOL_CALL_FAILED";
|
|
38464
|
-
})(EHookStage || (EHookStage = {}));
|
|
38465
|
-
var EHookExecutorName;
|
|
38466
|
-
(function(EHookExecutorName2) {
|
|
38467
|
-
EHookExecutorName2["LinkquegwEventHookExecutor"] = "LinkquegwEventHookExecutor";
|
|
38468
|
-
EHookExecutorName2["SecurityAnswerHookExecutor"] = "SecurityAnswerHookExecutor";
|
|
38469
|
-
EHookExecutorName2["ImageUnderstandingHookExecutor"] = "ImageUnderstandingHookExecutor";
|
|
38470
|
-
EHookExecutorName2["McpDiscoveryHookExecutor"] = "McpDiscoveryHookExecutor";
|
|
38471
|
-
EHookExecutorName2["BusinessDataPromptHookExecutor"] = "BusinessDataPromptHookExecutor";
|
|
38472
|
-
EHookExecutorName2["CurrentTimeHookExecutor"] = "CurrentTimeHookExecutor";
|
|
38473
|
-
EHookExecutorName2["MemoryHookExecutor"] = "MemoryHookExecutor";
|
|
38474
|
-
})(EHookExecutorName || (EHookExecutorName = {}));
|
|
38475
|
-
|
|
38476
|
-
// ../agent-a2ui-card-contract/dist/esm/protocol.js
|
|
38477
|
-
var LINKQUE_A2UI_V4_CATALOG_ID = "urn:linkque:a2ui:runtime:4";
|
|
38478
|
-
|
|
38479
|
-
// ../linkque-agent-data-binding-contract/dist/esm/json.js
|
|
38480
|
-
var BLOCKED_PATH_SEGMENTS = /* @__PURE__ */ new Set([
|
|
38481
|
-
"__proto__",
|
|
38482
|
-
"constructor",
|
|
38483
|
-
"prototype"
|
|
38484
|
-
]);
|
|
38485
|
-
function isPlainRecord(value) {
|
|
38486
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
38487
|
-
return false;
|
|
38488
|
-
const prototype = Object.getPrototypeOf(value);
|
|
38489
|
-
if (prototype === Object.prototype || prototype === null)
|
|
38490
|
-
return true;
|
|
38491
|
-
const constructor = Object.getOwnPropertyDescriptor(prototype, "constructor")?.value;
|
|
38492
|
-
return Object.getPrototypeOf(prototype) === null && typeof constructor === "function" && Function.prototype.toString.call(constructor) === Function.prototype.toString.call(Object);
|
|
38493
|
-
}
|
|
38494
|
-
function isJsonValue(value) {
|
|
38495
|
-
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
38496
|
-
return true;
|
|
38497
|
-
}
|
|
38498
|
-
if (typeof value === "number")
|
|
38499
|
-
return Number.isFinite(value);
|
|
38500
|
-
if (Array.isArray(value))
|
|
38501
|
-
return value.every(isJsonValue);
|
|
38502
|
-
return isPlainRecord(value) && Object.values(value).every(isJsonValue);
|
|
38503
|
-
}
|
|
38504
|
-
function cloneJsonValue(value) {
|
|
38505
|
-
return isJsonValue(value) ? JSON.parse(JSON.stringify(value)) : void 0;
|
|
38506
|
-
}
|
|
38507
|
-
function cloneJsonObject(value) {
|
|
38508
|
-
if (!isPlainRecord(value) || !isJsonValue(value))
|
|
38509
|
-
return void 0;
|
|
38510
|
-
return JSON.parse(JSON.stringify(value));
|
|
38511
|
-
}
|
|
38512
|
-
function stableJsonStringify(value) {
|
|
38513
|
-
if (value === null || typeof value !== "object")
|
|
38514
|
-
return JSON.stringify(value);
|
|
38515
|
-
if (Array.isArray(value)) {
|
|
38516
|
-
return `[${value.map(stableJsonStringify).join(",")}]`;
|
|
38517
|
-
}
|
|
38518
|
-
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${stableJsonStringify(value[key])}`).join(",")}}`;
|
|
38519
|
-
}
|
|
38520
|
-
function isSafeIdentifier(value) {
|
|
38521
|
-
return typeof value === "string" && value.length > 0 && value.length <= 128 && /^[A-Za-z0-9][A-Za-z0-9._:-]*$/u.test(value);
|
|
38522
|
-
}
|
|
38523
|
-
function isSafeJsonPointer(value, allowWildcard = false) {
|
|
38524
|
-
if (typeof value !== "string" || !value.startsWith("/"))
|
|
38525
|
-
return false;
|
|
38526
|
-
if (value === "/")
|
|
38527
|
-
return true;
|
|
38528
|
-
const segments = value.slice(1).split("/");
|
|
38529
|
-
if (segments.some((segment) => segment === ""))
|
|
38530
|
-
return false;
|
|
38531
|
-
return segments.every((encoded) => {
|
|
38532
|
-
if (!/^(?:[^~]|~[01])*$/u.test(encoded))
|
|
38533
|
-
return false;
|
|
38534
|
-
const segment = decodePointerSegment(encoded);
|
|
38535
|
-
return !BLOCKED_PATH_SEGMENTS.has(segment) && (allowWildcard || segment !== "*");
|
|
38536
|
-
});
|
|
38537
|
-
}
|
|
38538
|
-
function decodePointerSegment(value) {
|
|
38539
|
-
return value.replace(/~1/gu, "/").replace(/~0/gu, "~");
|
|
38540
|
-
}
|
|
38541
|
-
|
|
38542
|
-
// ../linkque-agent-data-binding-contract/dist/esm/schema.js
|
|
38543
|
-
var import_ajv = __toESM(require_ajv(), 1);
|
|
38544
|
-
var AjvConstructor = import_ajv.default;
|
|
38545
|
-
var ajv = new AjvConstructor({
|
|
38546
|
-
allErrors: true,
|
|
38547
|
-
strict: false,
|
|
38548
|
-
validateSchema: true
|
|
38549
|
-
});
|
|
38550
|
-
|
|
38551
|
-
// ../linkque-agent-data-binding-contract/dist/esm/structural.js
|
|
38552
|
-
var import_jmespath = __toESM(require_jmespath(), 1);
|
|
38553
|
-
|
|
38554
|
-
// ../agent-a2ui-card-contract/dist/esm/json.js
|
|
38555
|
-
function canonicalizeBindingPath(rawPath, listRoot) {
|
|
38556
|
-
let candidate = rawPath.trim();
|
|
38557
|
-
if (candidate === "")
|
|
38558
|
-
return void 0;
|
|
38559
|
-
if (candidate.startsWith("./")) {
|
|
38560
|
-
if (!listRoot || !isSafeJsonPointer(listRoot, true))
|
|
38561
|
-
return void 0;
|
|
38562
|
-
candidate = `${listRoot === "/" ? "" : listRoot}/*/${candidate.slice(2)}`;
|
|
38563
|
-
} else if (candidate === ".") {
|
|
38564
|
-
if (!listRoot || !isSafeJsonPointer(listRoot, true))
|
|
38565
|
-
return void 0;
|
|
38566
|
-
candidate = `${listRoot === "/" ? "" : listRoot}/*`;
|
|
38567
|
-
} else if (!candidate.startsWith("/")) {
|
|
38568
|
-
candidate = `/${candidate}`;
|
|
38569
|
-
}
|
|
38570
|
-
return isSafeJsonPointer(candidate, true) ? candidate : void 0;
|
|
38571
|
-
}
|
|
38572
|
-
function issue2(path28, code, message) {
|
|
38573
|
-
return { path: path28, code, message };
|
|
38574
|
-
}
|
|
38575
|
-
function exactKeys(value, allowed, path28, issues) {
|
|
38576
|
-
}
|
|
38577
|
-
|
|
38578
|
-
// ../agent-a2ui-card-contract/dist/esm/digest.js
|
|
38579
|
-
function sha256Hex(value) {
|
|
38580
|
-
const bytes = new TextEncoder().encode(value);
|
|
38581
|
-
const words = [];
|
|
38582
|
-
for (let index = 0; index < bytes.length; index += 1) {
|
|
38583
|
-
words[index >> 2] = (words[index >> 2] ?? 0) | bytes[index] << 24 - index % 4 * 8;
|
|
38584
|
-
}
|
|
38585
|
-
const bitLength = bytes.length * 8;
|
|
38586
|
-
words[bitLength >> 5] = (words[bitLength >> 5] ?? 0) | 128 << 24 - bitLength % 32;
|
|
38587
|
-
words[(bitLength + 64 >> 9 << 4) + 15] = bitLength;
|
|
38588
|
-
const constants2 = SHA256_CONSTANTS;
|
|
38589
|
-
let state = [
|
|
38590
|
-
1779033703,
|
|
38591
|
-
3144134277,
|
|
38592
|
-
1013904242,
|
|
38593
|
-
2773480762,
|
|
38594
|
-
1359893119,
|
|
38595
|
-
2600822924,
|
|
38596
|
-
528734635,
|
|
38597
|
-
1541459225
|
|
38598
|
-
];
|
|
38599
|
-
for (let offset = 0; offset < words.length; offset += 16) {
|
|
38600
|
-
const schedule = Array.from({ length: 64 }, () => 0);
|
|
38601
|
-
for (let index = 0; index < 16; index += 1) {
|
|
38602
|
-
schedule[index] = words[offset + index] ?? 0;
|
|
38603
|
-
}
|
|
38604
|
-
for (let index = 16; index < 64; index += 1) {
|
|
38605
|
-
const left = schedule[index - 15];
|
|
38606
|
-
const right = schedule[index - 2];
|
|
38607
|
-
const s0 = rotateRight(left, 7) ^ rotateRight(left, 18) ^ left >>> 3;
|
|
38608
|
-
const s1 = rotateRight(right, 17) ^ rotateRight(right, 19) ^ right >>> 10;
|
|
38609
|
-
schedule[index] = add(schedule[index - 16], s0, schedule[index - 7], s1);
|
|
38610
|
-
}
|
|
38611
|
-
let [a, b3, c, d, e3, f3, g2, h] = state;
|
|
38612
|
-
for (let index = 0; index < 64; index += 1) {
|
|
38613
|
-
const sum1 = rotateRight(e3, 6) ^ rotateRight(e3, 11) ^ rotateRight(e3, 25);
|
|
38614
|
-
const choice = e3 & f3 ^ ~e3 & g2;
|
|
38615
|
-
const temporary1 = add(h, sum1, choice, constants2[index], schedule[index]);
|
|
38616
|
-
const sum0 = rotateRight(a, 2) ^ rotateRight(a, 13) ^ rotateRight(a, 22);
|
|
38617
|
-
const majority = a & b3 ^ a & c ^ b3 & c;
|
|
38618
|
-
const temporary2 = add(sum0, majority);
|
|
38619
|
-
h = g2;
|
|
38620
|
-
g2 = f3;
|
|
38621
|
-
f3 = e3;
|
|
38622
|
-
e3 = add(d, temporary1);
|
|
38623
|
-
d = c;
|
|
38624
|
-
c = b3;
|
|
38625
|
-
b3 = a;
|
|
38626
|
-
a = add(temporary1, temporary2);
|
|
38023
|
+
let [a, b3, c, d, e3, f3, g2, h] = state;
|
|
38024
|
+
for (let index = 0; index < 64; index += 1) {
|
|
38025
|
+
const sum1 = rotateRight(e3, 6) ^ rotateRight(e3, 11) ^ rotateRight(e3, 25);
|
|
38026
|
+
const choice = e3 & f3 ^ ~e3 & g2;
|
|
38027
|
+
const temporary1 = add(h, sum1, choice, constants2[index], schedule[index]);
|
|
38028
|
+
const sum0 = rotateRight(a, 2) ^ rotateRight(a, 13) ^ rotateRight(a, 22);
|
|
38029
|
+
const majority = a & b3 ^ a & c ^ b3 & c;
|
|
38030
|
+
const temporary2 = add(sum0, majority);
|
|
38031
|
+
h = g2;
|
|
38032
|
+
g2 = f3;
|
|
38033
|
+
f3 = e3;
|
|
38034
|
+
e3 = add(d, temporary1);
|
|
38035
|
+
d = c;
|
|
38036
|
+
c = b3;
|
|
38037
|
+
b3 = a;
|
|
38038
|
+
a = add(temporary1, temporary2);
|
|
38627
38039
|
}
|
|
38628
38040
|
state = state.map((v2, index) => add(v2, [a, b3, c, d, e3, f3, g2, h][index]));
|
|
38629
38041
|
}
|
|
@@ -38754,13 +38166,17 @@ function validateJsonSchemaValue2(schema2, value, path28 = "$") {
|
|
|
38754
38166
|
validateValue(schema2, value, path28, issues);
|
|
38755
38167
|
return issues;
|
|
38756
38168
|
}
|
|
38757
|
-
function normalizeCardDataValue(schema2, value, required2 = true) {
|
|
38169
|
+
function normalizeCardDataValue(schema2, value, required2 = true, coerceOptionalScalars = true) {
|
|
38170
|
+
return normalizeCardDataNode(schema2, value, required2, coerceOptionalScalars, true);
|
|
38171
|
+
}
|
|
38172
|
+
function normalizeCardDataNode(schema2, value, required2, coerceOptionalScalars, parentAllowsCoercion) {
|
|
38173
|
+
const coerce2 = parentAllowsCoercion && (required2 || coerceOptionalScalars);
|
|
38758
38174
|
if (value === void 0 || value === null)
|
|
38759
38175
|
return required2 ? value : void 0;
|
|
38760
38176
|
let normalized = value;
|
|
38761
|
-
if (schema2.type === "string" && (typeof value === "boolean" || typeof value === "number" && Number.isFinite(value))) {
|
|
38177
|
+
if (coerce2 && schema2.type === "string" && (typeof value === "boolean" || typeof value === "number" && Number.isFinite(value))) {
|
|
38762
38178
|
normalized = String(value);
|
|
38763
|
-
} else if ((schema2.type === "number" || schema2.type === "integer") && typeof value === "string") {
|
|
38179
|
+
} else if (coerce2 && (schema2.type === "number" || schema2.type === "integer") && typeof value === "string") {
|
|
38764
38180
|
const text = value.trim();
|
|
38765
38181
|
if (/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/u.test(text)) {
|
|
38766
38182
|
const number4 = Number(text);
|
|
@@ -38773,11 +38189,11 @@ function normalizeCardDataValue(schema2, value, required2 = true) {
|
|
|
38773
38189
|
const requiredKeys = new Set(Array.isArray(schema2.required) ? schema2.required : []);
|
|
38774
38190
|
normalized = Object.fromEntries(Object.entries(value).flatMap(([key, child]) => {
|
|
38775
38191
|
const childSchema = properties[key];
|
|
38776
|
-
const next = isPlainRecord(childSchema) ?
|
|
38192
|
+
const next = isPlainRecord(childSchema) ? normalizeCardDataNode(childSchema, child, requiredKeys.has(key), coerceOptionalScalars, coerce2) : child;
|
|
38777
38193
|
return next === void 0 ? [] : [[key, next]];
|
|
38778
38194
|
}));
|
|
38779
38195
|
} else if (schema2.type === "array" && Array.isArray(value) && isPlainRecord(schema2.items)) {
|
|
38780
|
-
normalized = value.map((child) =>
|
|
38196
|
+
normalized = value.map((child) => normalizeCardDataNode(schema2.items, child, true, coerceOptionalScalars, coerce2));
|
|
38781
38197
|
}
|
|
38782
38198
|
return !required2 && validateJsonSchemaValue2(schema2, normalized).length > 0 ? void 0 : normalized;
|
|
38783
38199
|
}
|
|
@@ -38791,9 +38207,9 @@ function generateJsonSchemaSample(schema2) {
|
|
|
38791
38207
|
return example;
|
|
38792
38208
|
}
|
|
38793
38209
|
if (Array.isArray(schema2.enum) && schema2.enum.length > 0) {
|
|
38794
|
-
const
|
|
38795
|
-
if (
|
|
38796
|
-
return
|
|
38210
|
+
const enumValue2 = cloneJsonValue(schema2.enum[0]);
|
|
38211
|
+
if (enumValue2 !== void 0)
|
|
38212
|
+
return enumValue2;
|
|
38797
38213
|
}
|
|
38798
38214
|
const constValue = cloneJsonValue(schema2.const);
|
|
38799
38215
|
if (constValue !== void 0)
|
|
@@ -38972,7 +38388,7 @@ function validateValue(schema2, value, path28, issues) {
|
|
|
38972
38388
|
}
|
|
38973
38389
|
if (schema2.additionalProperties === false) {
|
|
38974
38390
|
for (const key of Object.keys(value)) {
|
|
38975
|
-
if (!(key
|
|
38391
|
+
if (!Object.prototype.hasOwnProperty.call(properties, key)) {
|
|
38976
38392
|
issues.push(issue2(`${path28}/${key}`, "SCHEMA_ADDITIONAL_PROPERTY", `property ${key} is not allowed`));
|
|
38977
38393
|
}
|
|
38978
38394
|
}
|
|
@@ -39158,8 +38574,8 @@ function analyzeA2UIBindings(protocol) {
|
|
|
39158
38574
|
issues
|
|
39159
38575
|
};
|
|
39160
38576
|
}
|
|
39161
|
-
function collectReferencedA2UICardBusinessFieldIds(protocol,
|
|
39162
|
-
const businessFields =
|
|
38577
|
+
function collectReferencedA2UICardBusinessFieldIds(protocol, fields2) {
|
|
38578
|
+
const businessFields = fields2.filter((field) => field.source === "business").slice().sort((left, right) => right.path.length - left.path.length);
|
|
39163
38579
|
const result = /* @__PURE__ */ new Set();
|
|
39164
38580
|
for (const occurrence of analyzeA2UIBindings(protocol).occurrences) {
|
|
39165
38581
|
const field = businessFields.find((candidate) => occurrence.canonicalPath === candidate.path || occurrence.canonicalPath.startsWith(`${candidate.path}/*/`) || occurrence.canonicalPath.startsWith(`${candidate.path}/`));
|
|
@@ -39496,12 +38912,12 @@ function getA2UICardBindingContextIssues(value, path28 = "bindingContext") {
|
|
|
39496
38912
|
validatePreferences(value.preferredTools, `${path28}.preferredTools`, issues);
|
|
39497
38913
|
return issues;
|
|
39498
38914
|
}
|
|
39499
|
-
function getA2UICardBindingSelectionIssues(value, path28 = "bindings",
|
|
38915
|
+
function getA2UICardBindingSelectionIssues(value, path28 = "bindings", fields2) {
|
|
39500
38916
|
const issues = [];
|
|
39501
38917
|
if (!Array.isArray(value)) {
|
|
39502
38918
|
return [issue2(path28, "CARD_BINDING_INVALID", "bindings must be an array")];
|
|
39503
38919
|
}
|
|
39504
|
-
const fieldById = new Map(
|
|
38920
|
+
const fieldById = new Map(fields2?.map((field) => [field.fieldId, field]) ?? []);
|
|
39505
38921
|
const seen = /* @__PURE__ */ new Set();
|
|
39506
38922
|
value.forEach((candidate, index) => {
|
|
39507
38923
|
const itemPath = `${path28}[${index}]`;
|
|
@@ -39533,7 +38949,7 @@ function getA2UICardBindingSelectionIssues(value, path28 = "bindings", fields) {
|
|
|
39533
38949
|
} else {
|
|
39534
38950
|
seen.add(candidate.fieldId);
|
|
39535
38951
|
const field = fieldById.get(candidate.fieldId);
|
|
39536
|
-
if (
|
|
38952
|
+
if (fields2 && (!field || field.source !== "business")) {
|
|
39537
38953
|
issues.push(issue2(`${itemPath}.fieldId`, "CARD_BINDING_INVALID", "only declared business fields may be bound"));
|
|
39538
38954
|
}
|
|
39539
38955
|
}
|
|
@@ -39715,7 +39131,7 @@ function validatePreferences(value, path28, issues) {
|
|
|
39715
39131
|
issues.push(issue2(path28, "CARD_BINDING_CONTEXT_INVALID", "preferredTools must be an array"));
|
|
39716
39132
|
return;
|
|
39717
39133
|
}
|
|
39718
|
-
const
|
|
39134
|
+
const fields2 = /* @__PURE__ */ new Set();
|
|
39719
39135
|
value.forEach((preference, index) => {
|
|
39720
39136
|
const itemPath = `${path28}[${index}]`;
|
|
39721
39137
|
if (!isPlainRecord(preference)) {
|
|
@@ -39731,10 +39147,10 @@ function validatePreferences(value, path28, issues) {
|
|
|
39731
39147
|
if (typeof preference.toolName !== "string" || !preference.toolName.trim()) {
|
|
39732
39148
|
issues.push(issue2(`${itemPath}.toolName`, "CARD_BINDING_CONTEXT_INVALID", "toolName is required"));
|
|
39733
39149
|
}
|
|
39734
|
-
if (typeof preference.fieldId === "string" &&
|
|
39150
|
+
if (typeof preference.fieldId === "string" && fields2.has(preference.fieldId)) {
|
|
39735
39151
|
issues.push(issue2(`${itemPath}.fieldId`, "CARD_BINDING_CONTEXT_INVALID", "field preference is duplicated"));
|
|
39736
39152
|
} else if (typeof preference.fieldId === "string")
|
|
39737
|
-
|
|
39153
|
+
fields2.add(preference.fieldId);
|
|
39738
39154
|
});
|
|
39739
39155
|
}
|
|
39740
39156
|
function validateInputBindings(value, path28, issues) {
|
|
@@ -39805,11 +39221,11 @@ function requiredLeafInputs(schema2, basePath = "", parentRequired = true) {
|
|
|
39805
39221
|
return isRequired ? [{ path: path28, schema: child }] : [];
|
|
39806
39222
|
});
|
|
39807
39223
|
}
|
|
39808
|
-
function validateConsistencyGroups(
|
|
39224
|
+
function validateConsistencyGroups(fields2, bindings, issues, selectedFields) {
|
|
39809
39225
|
const byField = new Map(bindings.map((binding) => [binding.fieldId, binding]));
|
|
39810
39226
|
const groups = /* @__PURE__ */ new Map();
|
|
39811
|
-
const selectedGroups = selectedFields ? new Set(
|
|
39812
|
-
for (const field of
|
|
39227
|
+
const selectedGroups = selectedFields ? new Set(fields2.filter((candidate) => selectedFields.has(candidate.fieldId)).map((candidate) => candidate.consistencyGroup).filter((group) => Boolean(group))) : void 0;
|
|
39228
|
+
for (const field of fields2) {
|
|
39813
39229
|
if (!field.consistencyGroup)
|
|
39814
39230
|
continue;
|
|
39815
39231
|
if (selectedGroups && !selectedGroups.has(field.consistencyGroup))
|
|
@@ -40706,12 +40122,12 @@ function getPersistedV4ProtocolIssues(card, path28) {
|
|
|
40706
40122
|
}
|
|
40707
40123
|
return issues;
|
|
40708
40124
|
}
|
|
40709
|
-
function validateV4Fixture(value,
|
|
40125
|
+
function validateV4Fixture(value, fields2, path28, issues) {
|
|
40710
40126
|
if (!isPlainRecord(value)) {
|
|
40711
40127
|
issues.push(issue2(path28, "INVALID_FIXTURE", "fixture must be a JSON object"));
|
|
40712
40128
|
return;
|
|
40713
40129
|
}
|
|
40714
|
-
for (const field of
|
|
40130
|
+
for (const field of fields2) {
|
|
40715
40131
|
if (field.source === "runtime-context")
|
|
40716
40132
|
continue;
|
|
40717
40133
|
const resolved = getFixtureValue(value, field.path);
|
|
@@ -40723,8 +40139,8 @@ function validateV4Fixture(value, fields, path28, issues) {
|
|
|
40723
40139
|
issues.push(...validateJsonSchemaValue2(field.valueSchema, resolved.value, `${path28}${field.path}`));
|
|
40724
40140
|
}
|
|
40725
40141
|
}
|
|
40726
|
-
function validateV4BindingContracts(card, occurrences,
|
|
40727
|
-
const ordered =
|
|
40142
|
+
function validateV4BindingContracts(card, occurrences, fields2, path28, issues, dataModelSchema) {
|
|
40143
|
+
const ordered = fields2.slice().sort((left, right) => right.path.length - left.path.length);
|
|
40728
40144
|
for (const occurrence of occurrences) {
|
|
40729
40145
|
const field = ordered.find((candidate) => occurrence.canonicalPath === candidate.path || occurrence.canonicalPath.startsWith(`${candidate.path}/*/`) || occurrence.canonicalPath.startsWith(`${candidate.path}/`));
|
|
40730
40146
|
const issuePath = `${path28}.surfaces.${occurrence.surfaceId ?? "unknown"}.components.${occurrence.componentId}.${occurrence.propertyPath}`;
|
|
@@ -40834,11 +40250,11 @@ function getA2UICardResourceConfigIssues(value) {
|
|
|
40834
40250
|
requiredString(value.whenToUse, "config.whenToUse", issues);
|
|
40835
40251
|
optionalString(value.whenNotToUse, "config.whenNotToUse", issues);
|
|
40836
40252
|
validateLooseJsonSchema(value.presentationInputSchema, "config.presentationInputSchema", issues);
|
|
40837
|
-
const
|
|
40253
|
+
const fields2 = validateFields(value.fields, "config.fields", issues);
|
|
40838
40254
|
const resolver = validateResolver(value.resolver, "config.resolver", issues);
|
|
40839
|
-
const card = validateTemplate(value.a2uiTemplate,
|
|
40840
|
-
if (
|
|
40841
|
-
validateResolverCoverage(
|
|
40255
|
+
const card = validateTemplate(value.a2uiTemplate, fields2, issues);
|
|
40256
|
+
if (fields2 && resolver)
|
|
40257
|
+
validateResolverCoverage(fields2, resolver, issues, card);
|
|
40842
40258
|
return issues;
|
|
40843
40259
|
}
|
|
40844
40260
|
function getA2UICardResourceConfigV4PipelineIssues(value, standard = false) {
|
|
@@ -40873,19 +40289,19 @@ function getA2UICardResourceConfigV4PipelineIssues(value, standard = false) {
|
|
|
40873
40289
|
requiredString(value.whenToUse, "config.whenToUse", issues);
|
|
40874
40290
|
optionalString(value.whenNotToUse, "config.whenNotToUse", issues);
|
|
40875
40291
|
validateLooseJsonSchema(value.presentationInputSchema, "config.presentationInputSchema", issues);
|
|
40876
|
-
const
|
|
40292
|
+
const fields2 = validateFields(value.fields, "config.fields", issues);
|
|
40877
40293
|
const pipelineSources = validatePipelineDataSources(value.dataSources, "config.dataSources", issues);
|
|
40878
40294
|
if (value.argumentMode === "model" && pipelineSources) {
|
|
40879
40295
|
validateModelPipelineArguments(value, pipelineSources, "config", issues);
|
|
40880
40296
|
}
|
|
40881
40297
|
validateDataTransform(value.dataTransform, "config.dataTransform", issues);
|
|
40882
40298
|
const dataModelSchema = validateLooseJsonSchema(value.dataModelSchema, "config.dataModelSchema", issues);
|
|
40883
|
-
const card = standard ? void 0 : validateTemplate(value.a2uiTemplate,
|
|
40299
|
+
const card = standard ? void 0 : validateTemplate(value.a2uiTemplate, fields2, issues);
|
|
40884
40300
|
if (card) {
|
|
40885
40301
|
issues.push(...getA2UIV4ProtocolIssues(card, "config.a2uiTemplate.content"), ...getPersistedV4ProtocolIssues(card, "config.a2uiTemplate.content"));
|
|
40886
40302
|
}
|
|
40887
|
-
if (
|
|
40888
|
-
validatePipelineFieldSchemas(
|
|
40303
|
+
if (fields2 && dataModelSchema) {
|
|
40304
|
+
validatePipelineFieldSchemas(fields2, value.dataModelSchema, issues);
|
|
40889
40305
|
}
|
|
40890
40306
|
if (dataModelSchema && isPlainRecord(value.a2uiTemplate) && stableJsonStringify(value.a2uiTemplate.argsSchema) !== stableJsonStringify(value.dataModelSchema)) {
|
|
40891
40307
|
issues.push(issue2("config.a2uiTemplate.argsSchema", "DATA_MODEL_SCHEMA_MISMATCH", "a2uiTemplate.argsSchema must equal dataModelSchema"));
|
|
@@ -40919,19 +40335,24 @@ function getA2UICardResourceConfigV3Issues(value, standard = false) {
|
|
|
40919
40335
|
requiredString(value.description, "config.description", issues);
|
|
40920
40336
|
requiredString(value.whenToUse, "config.whenToUse", issues);
|
|
40921
40337
|
optionalString(value.whenNotToUse, "config.whenNotToUse", issues);
|
|
40922
|
-
const
|
|
40923
|
-
if (
|
|
40338
|
+
const fields2 = validateFields(value.fields, "config.fields", issues);
|
|
40339
|
+
if (value.schemaVersion === "4") {
|
|
40340
|
+
validateBindingOutputSchemas(value.bindingOutputSchemas, fields2, "config.bindingOutputSchemas", issues);
|
|
40341
|
+
}
|
|
40342
|
+
if (fields2?.some((field) => field.source === "invocation")) {
|
|
40924
40343
|
issues.push(issue2("config.fields", "INVOCATION_FIELD_UNSUPPORTED", `schema v${String(value.schemaVersion)} does not support invocation fields`));
|
|
40925
40344
|
}
|
|
40926
40345
|
const dataSources = validateDataSources(value.dataSources, "config.dataSources", issues);
|
|
40927
40346
|
const bindings = validateV3OutputBindings(value.bindings, "config.bindings", issues);
|
|
40928
|
-
const card = standard ? void 0 : validateTemplate(value.a2uiTemplate,
|
|
40347
|
+
const card = standard ? void 0 : validateTemplate(value.a2uiTemplate, fields2, issues);
|
|
40929
40348
|
if (value.schemaVersion === "4" && card) {
|
|
40930
40349
|
issues.push(...getA2UIV4ProtocolIssues(card, "config.a2uiTemplate.content"));
|
|
40931
40350
|
issues.push(...getPersistedV4ProtocolIssues(card, "config.a2uiTemplate.content"));
|
|
40932
40351
|
}
|
|
40933
|
-
if (
|
|
40934
|
-
|
|
40352
|
+
if (value.schemaVersion === "4" && value.dataMode === "model") {
|
|
40353
|
+
validateLooseJsonSchema(value.modelInputSchema, "config.modelInputSchema", issues);
|
|
40354
|
+
} else if (fields2 && dataSources && bindings) {
|
|
40355
|
+
validateV3Coverage(fields2, dataSources, bindings, issues, { card });
|
|
40935
40356
|
}
|
|
40936
40357
|
return issues;
|
|
40937
40358
|
}
|
|
@@ -41083,8 +40504,8 @@ function validateDataTransform(value, path28, issues) {
|
|
|
41083
40504
|
issues.push(issue2(`${path28}.source`, "DATA_TRANSFORM_SOURCE_TOO_LARGE", `source exceeds ${A2UI_CARD_DATA_TRANSFORM_MAX_SOURCE_BYTES} bytes`));
|
|
41084
40505
|
}
|
|
41085
40506
|
}
|
|
41086
|
-
function validatePipelineFieldSchemas(
|
|
41087
|
-
|
|
40507
|
+
function validatePipelineFieldSchemas(fields2, dataModelSchema, issues) {
|
|
40508
|
+
fields2.forEach((field, index) => {
|
|
41088
40509
|
if (field.source !== "business")
|
|
41089
40510
|
return;
|
|
41090
40511
|
const schema2 = getJsonSchemaAtDataPointer(dataModelSchema, field.path);
|
|
@@ -41098,7 +40519,7 @@ function validateV3OutputBindings(value, path28, issues) {
|
|
|
41098
40519
|
issues.push(issue2(path28, "INVALID_OUTPUT_BINDINGS", "bindings must be an array"));
|
|
41099
40520
|
return void 0;
|
|
41100
40521
|
}
|
|
41101
|
-
const
|
|
40522
|
+
const fields2 = /* @__PURE__ */ new Set();
|
|
41102
40523
|
value.forEach((candidate, index) => {
|
|
41103
40524
|
const itemPath = `${path28}[${index}]`;
|
|
41104
40525
|
if (!isPlainRecord(candidate)) {
|
|
@@ -41108,34 +40529,34 @@ function validateV3OutputBindings(value, path28, issues) {
|
|
|
41108
40529
|
exactKeys(candidate, ["fieldId", "sourceId", "transform"], itemPath, issues);
|
|
41109
40530
|
if (!isSafeIdentifier(candidate.fieldId))
|
|
41110
40531
|
issues.push(issue2(`${itemPath}.fieldId`, "INVALID_FIELD_ID", "fieldId is invalid"));
|
|
41111
|
-
else if (
|
|
40532
|
+
else if (fields2.has(candidate.fieldId))
|
|
41112
40533
|
issues.push(issue2(`${itemPath}.fieldId`, "DUPLICATE_FIELD_BINDING", `field ${candidate.fieldId} has multiple output bindings`));
|
|
41113
40534
|
else
|
|
41114
|
-
|
|
40535
|
+
fields2.add(candidate.fieldId);
|
|
41115
40536
|
if (!isSafeIdentifier(candidate.sourceId))
|
|
41116
40537
|
issues.push(issue2(`${itemPath}.sourceId`, "INVALID_SOURCE_ID", "sourceId is invalid"));
|
|
41117
40538
|
validateTransformShape(candidate.transform, `${itemPath}.transform`, issues);
|
|
41118
40539
|
});
|
|
41119
40540
|
return value;
|
|
41120
40541
|
}
|
|
41121
|
-
function validateV3Coverage(
|
|
40542
|
+
function validateV3Coverage(fields2, dataSources, bindings, issues, options = {}) {
|
|
41122
40543
|
const sourceIds = new Set(dataSources.map((source) => source.sourceId));
|
|
41123
40544
|
const sourceById = new Map(dataSources.map((source) => [source.sourceId, source]));
|
|
41124
|
-
const businessFields = new Set(
|
|
40545
|
+
const businessFields = new Set(fields2.filter((field) => field.source === "business").map((field) => field.fieldId));
|
|
41125
40546
|
const bound = /* @__PURE__ */ new Set();
|
|
41126
40547
|
bindings.forEach((binding, index) => {
|
|
41127
40548
|
if (!sourceIds.has(binding.sourceId))
|
|
41128
40549
|
issues.push(issue2(`config.bindings[${index}].sourceId`, "UNKNOWN_DATA_SOURCE", `Unknown data source ${binding.sourceId}`));
|
|
41129
40550
|
if (!businessFields.has(binding.fieldId))
|
|
41130
40551
|
issues.push(issue2(`config.bindings[${index}].fieldId`, "INVALID_BUSINESS_BINDING", `field ${binding.fieldId} is not a declared business field`));
|
|
41131
|
-
const field =
|
|
40552
|
+
const field = fields2.find((candidate) => candidate.fieldId === binding.fieldId);
|
|
41132
40553
|
if (field?.required && sourceById.get(binding.sourceId)?.required === false) {
|
|
41133
40554
|
issues.push(issue2(`config.bindings[${index}].sourceId`, "REQUIRED_FIELD_OPTIONAL_SOURCE", `required field ${binding.fieldId} must use a required data source`));
|
|
41134
40555
|
}
|
|
41135
40556
|
bound.add(binding.fieldId);
|
|
41136
40557
|
});
|
|
41137
40558
|
if (options.requireComplete !== false) {
|
|
41138
|
-
const requiredFields = options.card ? collectReferencedA2UICardBusinessFieldIds(options.card,
|
|
40559
|
+
const requiredFields = options.card ? collectReferencedA2UICardBusinessFieldIds(options.card, fields2.filter((field) => field.required)) : new Set(fields2.filter((field) => field.source === "business" && field.required).map((field) => field.fieldId));
|
|
41139
40560
|
for (const fieldId of requiredFields) {
|
|
41140
40561
|
if (bound.has(fieldId))
|
|
41141
40562
|
continue;
|
|
@@ -41143,7 +40564,7 @@ function validateV3Coverage(fields, dataSources, bindings, issues, options = {})
|
|
|
41143
40564
|
}
|
|
41144
40565
|
}
|
|
41145
40566
|
}
|
|
41146
|
-
function validateV3BindingSelections(value, path28,
|
|
40567
|
+
function validateV3BindingSelections(value, path28, fields2, issues) {
|
|
41147
40568
|
if (!Array.isArray(value)) {
|
|
41148
40569
|
issues.push(issue2(path28, "INVALID_BINDINGS", "bindings must be an array"));
|
|
41149
40570
|
return;
|
|
@@ -41203,8 +40624,8 @@ function validateV3BindingSelections(value, path28, fields, issues) {
|
|
|
41203
40624
|
validateOutputSchema: false
|
|
41204
40625
|
});
|
|
41205
40626
|
validateV3OutputBindings(outputBindings, `${path28}.outputs`, issues);
|
|
41206
|
-
if (
|
|
41207
|
-
validateV3Coverage(
|
|
40627
|
+
if (fields2) {
|
|
40628
|
+
validateV3Coverage(fields2, dataSources, outputBindings, issues, {
|
|
41208
40629
|
requireComplete: false
|
|
41209
40630
|
});
|
|
41210
40631
|
}
|
|
@@ -41247,15 +40668,15 @@ function validateManifest(value, path28, issues) {
|
|
|
41247
40668
|
requiredString(value.whenToUse, `${path28}.whenToUse`, issues);
|
|
41248
40669
|
optionalString(value.whenNotToUse, `${path28}.whenNotToUse`, issues);
|
|
41249
40670
|
validateLooseJsonSchema(value.presentationInputSchema, `${path28}.presentationInputSchema`, issues);
|
|
41250
|
-
const
|
|
40671
|
+
const fields3 = validateFields(value.fields, `${path28}.fields`, issues);
|
|
41251
40672
|
const pipelineSources = validatePipelineDataSources(value.dataSources, `${path28}.dataSources`, issues);
|
|
41252
40673
|
if (value.argumentMode === "model" && pipelineSources) {
|
|
41253
40674
|
validateModelPipelineArguments(value, pipelineSources, path28, issues);
|
|
41254
40675
|
}
|
|
41255
40676
|
validateDataTransform(value.dataTransform, `${path28}.dataTransform`, issues);
|
|
41256
40677
|
const dataModelSchema = validateLooseJsonSchema(value.dataModelSchema, `${path28}.dataModelSchema`, issues);
|
|
41257
|
-
if (
|
|
41258
|
-
|
|
40678
|
+
if (fields3 && dataModelSchema) {
|
|
40679
|
+
fields3.forEach((field, index) => {
|
|
41259
40680
|
if (field.source !== "business")
|
|
41260
40681
|
return;
|
|
41261
40682
|
if (!getJsonSchemaAtDataPointer(value.dataModelSchema, field.path)) {
|
|
@@ -41263,11 +40684,11 @@ function validateManifest(value, path28, issues) {
|
|
|
41263
40684
|
}
|
|
41264
40685
|
});
|
|
41265
40686
|
}
|
|
41266
|
-
return
|
|
40687
|
+
return fields3 ? value : void 0;
|
|
41267
40688
|
}
|
|
41268
40689
|
if (value.schemaVersion === "3" || value.schemaVersion === "4") {
|
|
41269
|
-
if (value.dataMode !== void 0 && (value.schemaVersion !== "4" || value.dataMode !== "bindings")) {
|
|
41270
|
-
issues.push(issue2(`${path28}.dataMode`, "INVALID_DATA_MODE", "
|
|
40690
|
+
if (value.dataMode !== void 0 && (value.schemaVersion !== "4" || value.dataMode !== "bindings" && value.dataMode !== "model")) {
|
|
40691
|
+
issues.push(issue2(`${path28}.dataMode`, "INVALID_DATA_MODE", "unsupported dataMode for this schemaVersion"));
|
|
41271
40692
|
}
|
|
41272
40693
|
if (value.actionBindings !== void 0) {
|
|
41273
40694
|
issues.push(issue2(`${path28}.actionBindings`, "LEGACY_PAYMENT_ACTION_BINDINGS_UNSUPPORTED", "payment actions must be defined inline in card JSON"));
|
|
@@ -41296,14 +40717,17 @@ function validateManifest(value, path28, issues) {
|
|
|
41296
40717
|
requiredString(value.description, `${path28}.description`, issues);
|
|
41297
40718
|
requiredString(value.whenToUse, `${path28}.whenToUse`, issues);
|
|
41298
40719
|
optionalString(value.whenNotToUse, `${path28}.whenNotToUse`, issues);
|
|
41299
|
-
const
|
|
41300
|
-
if (
|
|
40720
|
+
const fields3 = validateFields(value.fields, `${path28}.fields`, issues);
|
|
40721
|
+
if (value.schemaVersion === "4") {
|
|
40722
|
+
validateBindingOutputSchemas(value.bindingOutputSchemas, fields3, `${path28}.bindingOutputSchemas`, issues);
|
|
40723
|
+
}
|
|
40724
|
+
if (fields3?.some((field) => field.source === "invocation")) {
|
|
41301
40725
|
issues.push(issue2(`${path28}.fields`, "INVOCATION_FIELD_UNSUPPORTED", `schema v${value.schemaVersion} does not support invocation fields`));
|
|
41302
40726
|
}
|
|
41303
40727
|
if (value.bindings !== void 0) {
|
|
41304
|
-
validateV3BindingSelections(value.bindings, `${path28}.bindings`,
|
|
40728
|
+
validateV3BindingSelections(value.bindings, `${path28}.bindings`, fields3, issues);
|
|
41305
40729
|
}
|
|
41306
|
-
return
|
|
40730
|
+
return fields3 ? value : void 0;
|
|
41307
40731
|
}
|
|
41308
40732
|
exactKeys(value, [
|
|
41309
40733
|
"schemaVersion",
|
|
@@ -41333,11 +40757,11 @@ function validateManifest(value, path28, issues) {
|
|
|
41333
40757
|
requiredString(value.whenToUse, `${path28}.whenToUse`, issues);
|
|
41334
40758
|
optionalString(value.whenNotToUse, `${path28}.whenNotToUse`, issues);
|
|
41335
40759
|
const schema2 = validateLooseJsonSchema(value.presentationInputSchema, `${path28}.presentationInputSchema`, issues);
|
|
41336
|
-
const
|
|
40760
|
+
const fields2 = validateFields(value.fields, `${path28}.fields`, issues);
|
|
41337
40761
|
if (value.bindings !== void 0) {
|
|
41338
|
-
issues.push(...getA2UICardBindingSelectionIssues(value.bindings, `${path28}.bindings`,
|
|
40762
|
+
issues.push(...getA2UICardBindingSelectionIssues(value.bindings, `${path28}.bindings`, fields2));
|
|
41339
40763
|
}
|
|
41340
|
-
return schema2 &&
|
|
40764
|
+
return schema2 && fields2 ? value : void 0;
|
|
41341
40765
|
}
|
|
41342
40766
|
function hasOverlappingJsonPointer(fixedInput, inputPath) {
|
|
41343
40767
|
const fixedPaths = [];
|
|
@@ -41558,7 +40982,7 @@ function validateOutputBindings(value, path28, issues) {
|
|
|
41558
40982
|
issues.push(issue2(path28, "INVALID_OUTPUT_BINDINGS", "outputBindings must be an array"));
|
|
41559
40983
|
return void 0;
|
|
41560
40984
|
}
|
|
41561
|
-
const
|
|
40985
|
+
const fields2 = /* @__PURE__ */ new Set();
|
|
41562
40986
|
value.forEach((candidate, index) => {
|
|
41563
40987
|
const itemPath = `${path28}[${index}]`;
|
|
41564
40988
|
if (!isPlainRecord(candidate)) {
|
|
@@ -41568,10 +40992,10 @@ function validateOutputBindings(value, path28, issues) {
|
|
|
41568
40992
|
exactKeys(candidate, ["fieldId", "callId", "transform"], itemPath, issues);
|
|
41569
40993
|
if (!isSafeIdentifier(candidate.fieldId)) {
|
|
41570
40994
|
issues.push(issue2(`${itemPath}.fieldId`, "INVALID_FIELD_ID", "fieldId is invalid"));
|
|
41571
|
-
} else if (
|
|
40995
|
+
} else if (fields2.has(candidate.fieldId)) {
|
|
41572
40996
|
issues.push(issue2(`${itemPath}.fieldId`, "DUPLICATE_FIELD_BINDING", `field ${candidate.fieldId} has multiple output bindings`));
|
|
41573
40997
|
} else {
|
|
41574
|
-
|
|
40998
|
+
fields2.add(candidate.fieldId);
|
|
41575
40999
|
}
|
|
41576
41000
|
if (!isSafeIdentifier(candidate.callId)) {
|
|
41577
41001
|
issues.push(issue2(`${itemPath}.callId`, "INVALID_CALL_ID", "callId is invalid"));
|
|
@@ -41671,7 +41095,7 @@ function validateInstructionShape(instruction, path28, issues) {
|
|
|
41671
41095
|
issues.push(issue2(`${path28}.${operation}.componentId`, "INVALID_COMPONENT_ID", "componentId must be a non-empty safe identifier"));
|
|
41672
41096
|
}
|
|
41673
41097
|
}
|
|
41674
|
-
function validateTemplate(value,
|
|
41098
|
+
function validateTemplate(value, fields2, issues) {
|
|
41675
41099
|
if (!isPlainRecord(value)) {
|
|
41676
41100
|
issues.push(issue2("config.a2uiTemplate", "INVALID_A2UI_TEMPLATE", "a2uiTemplate must be an object"));
|
|
41677
41101
|
return void 0;
|
|
@@ -41684,7 +41108,7 @@ function validateTemplate(value, fields, issues) {
|
|
|
41684
41108
|
}
|
|
41685
41109
|
try {
|
|
41686
41110
|
const card = validateProtocol(JSON.parse(value.content), "config.a2uiTemplate.content", issues);
|
|
41687
|
-
if (card &&
|
|
41111
|
+
if (card && fields2) {
|
|
41688
41112
|
const analysis = analyzeA2UIBindings(card);
|
|
41689
41113
|
issues.push(...analysis.issues);
|
|
41690
41114
|
}
|
|
@@ -41694,6 +41118,21 @@ function validateTemplate(value, fields, issues) {
|
|
|
41694
41118
|
}
|
|
41695
41119
|
return void 0;
|
|
41696
41120
|
}
|
|
41121
|
+
function validateBindingOutputSchemas(value, fields2, path28, issues) {
|
|
41122
|
+
if (value === void 0)
|
|
41123
|
+
return;
|
|
41124
|
+
if (!isPlainRecord(value)) {
|
|
41125
|
+
issues.push(issue2(path28, "INVALID_BINDING_OUTPUT_SCHEMA", "Expected a field schema map"));
|
|
41126
|
+
return;
|
|
41127
|
+
}
|
|
41128
|
+
for (const [fieldId, schema2] of Object.entries(value)) {
|
|
41129
|
+
if (!fields2?.some((field) => field.fieldId === fieldId && field.source === "business")) {
|
|
41130
|
+
issues.push(issue2(path28, "INVALID_BINDING_OUTPUT_SCHEMA", `Unknown business field ${fieldId}`));
|
|
41131
|
+
continue;
|
|
41132
|
+
}
|
|
41133
|
+
validateLooseJsonSchema(schema2, `${path28}.${fieldId}`, issues);
|
|
41134
|
+
}
|
|
41135
|
+
}
|
|
41697
41136
|
function validateLooseJsonSchema(value, path28, issues) {
|
|
41698
41137
|
const schemaIssues = getJsonSchemaIssues(value, path28, {
|
|
41699
41138
|
allowMissingType: true
|
|
@@ -41701,8 +41140,8 @@ function validateLooseJsonSchema(value, path28, issues) {
|
|
|
41701
41140
|
issues.push(...schemaIssues);
|
|
41702
41141
|
return schemaIssues.length === 0;
|
|
41703
41142
|
}
|
|
41704
|
-
function validateResolverCoverage(
|
|
41705
|
-
const businessFields = new Set(
|
|
41143
|
+
function validateResolverCoverage(fields2, resolver, issues, card) {
|
|
41144
|
+
const businessFields = new Set(fields2.filter((field) => field.source === "business").map((field) => field.fieldId));
|
|
41706
41145
|
const bound = /* @__PURE__ */ new Set();
|
|
41707
41146
|
resolver.outputBindings.forEach((binding, index) => {
|
|
41708
41147
|
if (!businessFields.has(binding.fieldId)) {
|
|
@@ -41710,7 +41149,7 @@ function validateResolverCoverage(fields, resolver, issues, card) {
|
|
|
41710
41149
|
}
|
|
41711
41150
|
bound.add(binding.fieldId);
|
|
41712
41151
|
});
|
|
41713
|
-
const requiredFields = card ? collectReferencedA2UICardBusinessFieldIds(card,
|
|
41152
|
+
const requiredFields = card ? collectReferencedA2UICardBusinessFieldIds(card, fields2.filter((field) => field.required)) : new Set(fields2.filter((field) => field.source === "business" && field.required).map((field) => field.fieldId));
|
|
41714
41153
|
for (const fieldId of requiredFields) {
|
|
41715
41154
|
if (!bound.has(fieldId)) {
|
|
41716
41155
|
issues.push(issue2("config.resolver.outputBindings", "CARD_BINDING_INCOMPLETE", `business field ${fieldId} is not bound`));
|
|
@@ -41751,6 +41190,31 @@ function compileA2UICardResource(input) {
|
|
|
41751
41190
|
throw new A2UICardCompileError("CARD_REVISION_INVALID", "CARD revision must be a stable safe identifier");
|
|
41752
41191
|
}
|
|
41753
41192
|
const draft = draftResult.data;
|
|
41193
|
+
const { manifest } = draft;
|
|
41194
|
+
if (manifest.schemaVersion === "4" && manifest.dataMode === "model") {
|
|
41195
|
+
const { displayName, description, whenToUse, whenNotToUse, fields: fields2 } = manifest;
|
|
41196
|
+
return {
|
|
41197
|
+
schemaVersion: "4",
|
|
41198
|
+
dataMode: "model",
|
|
41199
|
+
revision: input.revision,
|
|
41200
|
+
displayName,
|
|
41201
|
+
description,
|
|
41202
|
+
whenToUse,
|
|
41203
|
+
...whenNotToUse ? { whenNotToUse } : {},
|
|
41204
|
+
...manifest.allowPartialModel ? { allowPartialModel: true } : {},
|
|
41205
|
+
fields: fields2,
|
|
41206
|
+
bindings: [],
|
|
41207
|
+
dataSources: [],
|
|
41208
|
+
modelInputSchema: createModelCardInputSchema(createA2UICardViewModelSchema(fields2.filter((field) => field.source === "business").map((field) => ({
|
|
41209
|
+
...field,
|
|
41210
|
+
valueSchema: { description: field.label, ...field.valueSchema }
|
|
41211
|
+
})))),
|
|
41212
|
+
a2uiTemplate: {
|
|
41213
|
+
argsSchema: createA2UICardViewModelSchema(fields2),
|
|
41214
|
+
content: stableJsonStringify(draft.card)
|
|
41215
|
+
}
|
|
41216
|
+
};
|
|
41217
|
+
}
|
|
41754
41218
|
if (draft.manifest.schemaVersion === "4" && draft.manifest.dataMode === "pipeline") {
|
|
41755
41219
|
return compilePipelineResource(draft, input.revision);
|
|
41756
41220
|
}
|
|
@@ -41808,6 +41272,7 @@ function compilePipelineResource(draft, revision) {
|
|
|
41808
41272
|
const resource = {
|
|
41809
41273
|
schemaVersion: "4",
|
|
41810
41274
|
dataMode: "pipeline",
|
|
41275
|
+
...draft.manifest.allowPartialModel ? { allowPartialModel: true } : {},
|
|
41811
41276
|
...draft.manifest.argumentMode ? { argumentMode: draft.manifest.argumentMode } : {},
|
|
41812
41277
|
revision,
|
|
41813
41278
|
displayName: draft.manifest.displayName,
|
|
@@ -41855,9 +41320,9 @@ function compileLegacyDraftAsV3(draft, revision, bindings, tools, targetSchemaVe
|
|
|
41855
41320
|
[...groups.entries()].sort(([left], [right]) => left.localeCompare(right)).forEach(([, group], index) => {
|
|
41856
41321
|
const sourceId = `source-${index + 1}`;
|
|
41857
41322
|
const tool = toolByKey.get(`${group.mcpResourceId}\0${group.toolName}`);
|
|
41858
|
-
const
|
|
41859
|
-
const purpose = tool?.description?.trim() || `\u83B7\u53D6${
|
|
41860
|
-
const required2 =
|
|
41323
|
+
const fields2 = group.bindings.map((binding) => fieldById.get(binding.fieldId)).filter((field) => field !== void 0);
|
|
41324
|
+
const purpose = tool?.description?.trim() || `\u83B7\u53D6${fields2.map((field) => field.label).join("\u3001") || group.toolName}`;
|
|
41325
|
+
const required2 = fields2.some((field) => field.required);
|
|
41861
41326
|
for (const binding of group.bindings) {
|
|
41862
41327
|
v3Bindings.push({
|
|
41863
41328
|
fieldId: binding.fieldId,
|
|
@@ -41929,8 +41394,12 @@ function compileModernResource(draft, revision, bindings, tools) {
|
|
|
41929
41394
|
throw new A2UICardCompileError("CARD_BINDING_INCOMPLETE", `Required referenced business field ${fieldId} has not been bound`);
|
|
41930
41395
|
}
|
|
41931
41396
|
}
|
|
41397
|
+
const previousProjections = draft.manifest.schemaVersion === "4" && draft.manifest.dataMode !== "pipeline" ? draft.manifest.bindingOutputSchemas : void 0;
|
|
41398
|
+
const bindingOutputSchemas = Object.fromEntries(outputBindings.flatMap(({ fieldId }) => previousProjections && Object.prototype.hasOwnProperty.call(previousProjections, fieldId) ? [[fieldId, previousProjections[fieldId]]] : []));
|
|
41932
41399
|
const resource = {
|
|
41933
41400
|
schemaVersion: draft.manifest.schemaVersion,
|
|
41401
|
+
...draft.manifest.schemaVersion === "4" && draft.manifest.allowPartialModel ? { allowPartialModel: true } : {},
|
|
41402
|
+
...Object.keys(bindingOutputSchemas).length ? { bindingOutputSchemas } : {},
|
|
41934
41403
|
revision,
|
|
41935
41404
|
displayName: draft.manifest.displayName,
|
|
41936
41405
|
description: draft.manifest.description,
|
|
@@ -41950,14 +41419,22 @@ function compileModernResource(draft, revision, bindings, tools) {
|
|
|
41950
41419
|
}
|
|
41951
41420
|
return parsed.data;
|
|
41952
41421
|
}
|
|
41953
|
-
function
|
|
41422
|
+
function createModelCardInputSchema(dataModel) {
|
|
41423
|
+
return {
|
|
41424
|
+
type: "object",
|
|
41425
|
+
properties: { dataModel },
|
|
41426
|
+
required: ["dataModel"],
|
|
41427
|
+
additionalProperties: false
|
|
41428
|
+
};
|
|
41429
|
+
}
|
|
41430
|
+
function createA2UICardViewModelSchema(fields2) {
|
|
41954
41431
|
const root = {
|
|
41955
41432
|
type: "object",
|
|
41956
41433
|
additionalProperties: false,
|
|
41957
41434
|
properties: {},
|
|
41958
41435
|
required: /* @__PURE__ */ new Set()
|
|
41959
41436
|
};
|
|
41960
|
-
for (const field of
|
|
41437
|
+
for (const field of fields2) {
|
|
41961
41438
|
const canonicalPath = canonicalizeBindingPath(field.path);
|
|
41962
41439
|
if (!canonicalPath || canonicalPath === "/" || !isSafeJsonPointer(canonicalPath)) {
|
|
41963
41440
|
throw new A2UICardCompileError("CARD_FIELD_PATH_INVALID", `Field ${field.fieldId} does not have a writable object path`);
|
|
@@ -42032,10 +41509,10 @@ function compileResolver(selections) {
|
|
|
42032
41509
|
})))
|
|
42033
41510
|
};
|
|
42034
41511
|
}
|
|
42035
|
-
function validateConsistencyGroups2(
|
|
41512
|
+
function validateConsistencyGroups2(fields2, resolver) {
|
|
42036
41513
|
const bindingByField = new Map(resolver.outputBindings.map((binding) => [binding.fieldId, binding]));
|
|
42037
41514
|
const groups = /* @__PURE__ */ new Map();
|
|
42038
|
-
for (const field of
|
|
41515
|
+
for (const field of fields2) {
|
|
42039
41516
|
if (!field.consistencyGroup)
|
|
42040
41517
|
continue;
|
|
42041
41518
|
const binding = bindingByField.get(field.fieldId);
|
|
@@ -42107,18 +41584,18 @@ function extractA2UICardAuthoringModel(bundle, options = {}) {
|
|
|
42107
41584
|
binding.fieldId,
|
|
42108
41585
|
binding
|
|
42109
41586
|
]));
|
|
42110
|
-
const
|
|
41587
|
+
const fields2 = bundle.manifest.fields.filter((field) => field.source === "business");
|
|
42111
41588
|
if (bundle.manifest.schemaVersion === "4" && bundle.manifest.dataMode === "pipeline") {
|
|
42112
41589
|
for (const [key, schema2] of Object.entries(bundle.manifest.dataModelSchema.properties ?? {})) {
|
|
42113
41590
|
const path28 = `/${key.replace(/~/g, "~0").replace(/\//g, "~1")}`;
|
|
42114
|
-
if (!isPlainRecord(schema2) ||
|
|
41591
|
+
if (!isPlainRecord(schema2) || fields2.some((field) => field.path === path28))
|
|
42115
41592
|
continue;
|
|
42116
41593
|
if (!["string", "number", "integer", "boolean", "object", "array"].includes(String(schema2.type)))
|
|
42117
41594
|
continue;
|
|
42118
|
-
let idIndex =
|
|
42119
|
-
while (
|
|
41595
|
+
let idIndex = fields2.length;
|
|
41596
|
+
while (fields2.some((field) => field.fieldId === `pipeline-field-${idIndex}`))
|
|
42120
41597
|
idIndex += 1;
|
|
42121
|
-
|
|
41598
|
+
fields2.push({
|
|
42122
41599
|
fieldId: `pipeline-field-${idIndex}`,
|
|
42123
41600
|
path: path28,
|
|
42124
41601
|
label: key,
|
|
@@ -42141,8 +41618,8 @@ function extractA2UICardAuthoringModel(bundle, options = {}) {
|
|
|
42141
41618
|
const projection = componentAuthoringProjection(component);
|
|
42142
41619
|
const componentOccurrences = occurrencesByComponent.get(componentKey(surfaceId, component.id)) ?? [];
|
|
42143
41620
|
discoverComponentTargets(component, occurrenceId, projection, targets);
|
|
42144
|
-
allFieldOccurrenceTargets.push(...fieldTargets(component, occurrenceId,
|
|
42145
|
-
targets.push(...fieldTargets(component, occurrenceId,
|
|
41621
|
+
allFieldOccurrenceTargets.push(...fieldTargets(component, occurrenceId, fields2, componentOccurrences, false));
|
|
41622
|
+
targets.push(...fieldTargets(component, occurrenceId, fields2, componentOccurrences, true));
|
|
42146
41623
|
targets.push(...actionTargets(component, occurrenceId));
|
|
42147
41624
|
}
|
|
42148
41625
|
if (targets.length === 0) {
|
|
@@ -42165,7 +41642,7 @@ function extractA2UICardAuthoringModel(bundle, options = {}) {
|
|
|
42165
41642
|
agentOnly: targets.every((target) => target.kind === "agent-only")
|
|
42166
41643
|
});
|
|
42167
41644
|
}
|
|
42168
|
-
const fieldStates =
|
|
41645
|
+
const fieldStates = fields2.map((field) => {
|
|
42169
41646
|
const occurrences = allFieldOccurrenceTargets.filter((target) => target.fieldId === field.fieldId);
|
|
42170
41647
|
const binding = bindingByField.get(field.fieldId);
|
|
42171
41648
|
const pipelineBound = bundle.manifest.schemaVersion === "4" && bundle.manifest.dataMode === "pipeline" && getJsonSchemaAtDataPointer(bundle.manifest.dataModelSchema, field.path) !== void 0;
|
|
@@ -42174,7 +41651,7 @@ function extractA2UICardAuthoringModel(bundle, options = {}) {
|
|
|
42174
41651
|
...binding ? { binding: cloneBinding(binding) } : {},
|
|
42175
41652
|
occurrences,
|
|
42176
41653
|
usageCount: new Set(occurrences.map((target) => `${target.occurrenceId}\0${target.propertyPath}`)).size,
|
|
42177
|
-
status: occurrences.length === 0 ? "unused" : binding || pipelineBound ? "bound" : field.required ? "unbound-required" : "unbound-optional"
|
|
41654
|
+
status: occurrences.length === 0 ? "unused" : binding || pipelineBound || bundle.manifest.schemaVersion === "4" && bundle.manifest.dataMode === "model" ? "bound" : field.required ? "unbound-required" : "unbound-optional"
|
|
42178
41655
|
};
|
|
42179
41656
|
});
|
|
42180
41657
|
const diagnostics = getA2UICardAuthoringDiagnostics(bundle, {
|
|
@@ -42251,254 +41728,1327 @@ function getA2UICardAuthoringDiagnostics(bundle, partial2) {
|
|
|
42251
41728
|
});
|
|
42252
41729
|
}
|
|
42253
41730
|
}
|
|
42254
|
-
return deduplicateDiagnostics(diagnostics);
|
|
42255
|
-
}
|
|
42256
|
-
function validateA2UICardForPublish(bundle) {
|
|
42257
|
-
return getA2UICardAuthoringDiagnostics(bundle).filter((
|
|
42258
|
-
}
|
|
42259
|
-
function createA2UICardAuthoringOccurrenceId(surfaceId, componentId) {
|
|
42260
|
-
return `${encodeURIComponent(surfaceId)}:${encodeURIComponent(componentId)}`;
|
|
42261
|
-
}
|
|
42262
|
-
function createA2UICardAuthoringTargetId(occurrenceId, propertyPath) {
|
|
42263
|
-
return `${occurrenceId}:${encodeURIComponent(propertyPath)}`;
|
|
42264
|
-
}
|
|
42265
|
-
function isSafePageUrl2(url2, actionName) {
|
|
42266
|
-
const trimmed = url2.trim();
|
|
42267
|
-
if (trimmed.length === 0 || trimmed.length > 2e3)
|
|
42268
|
-
return false;
|
|
42269
|
-
const token = /\{\{([^{}]+)\}\}/gu;
|
|
42270
|
-
let tokenCount = 0;
|
|
42271
|
-
for (const match of trimmed.matchAll(token)) {
|
|
42272
|
-
tokenCount++;
|
|
42273
|
-
if (tokenCount > 32)
|
|
42274
|
-
return false;
|
|
42275
|
-
const path28 = match[1]?.trim() ?? "";
|
|
42276
|
-
if (!(path28 === "/" || path28.startsWith("/") || path28.startsWith("./")) || path28.split("/").some((part) => ["..", "__proto__", "constructor", "prototype"].includes(part))) {
|
|
42277
|
-
return false;
|
|
41731
|
+
return deduplicateDiagnostics(diagnostics);
|
|
41732
|
+
}
|
|
41733
|
+
function validateA2UICardForPublish(bundle) {
|
|
41734
|
+
return getA2UICardAuthoringDiagnostics(bundle).filter((diagnostic2) => diagnostic2.severity === "hard-error");
|
|
41735
|
+
}
|
|
41736
|
+
function createA2UICardAuthoringOccurrenceId(surfaceId, componentId) {
|
|
41737
|
+
return `${encodeURIComponent(surfaceId)}:${encodeURIComponent(componentId)}`;
|
|
41738
|
+
}
|
|
41739
|
+
function createA2UICardAuthoringTargetId(occurrenceId, propertyPath) {
|
|
41740
|
+
return `${occurrenceId}:${encodeURIComponent(propertyPath)}`;
|
|
41741
|
+
}
|
|
41742
|
+
function isSafePageUrl2(url2, actionName) {
|
|
41743
|
+
const trimmed = url2.trim();
|
|
41744
|
+
if (trimmed.length === 0 || trimmed.length > 2e3)
|
|
41745
|
+
return false;
|
|
41746
|
+
const token = /\{\{([^{}]+)\}\}/gu;
|
|
41747
|
+
let tokenCount = 0;
|
|
41748
|
+
for (const match of trimmed.matchAll(token)) {
|
|
41749
|
+
tokenCount++;
|
|
41750
|
+
if (tokenCount > 32)
|
|
41751
|
+
return false;
|
|
41752
|
+
const path28 = match[1]?.trim() ?? "";
|
|
41753
|
+
if (!(path28 === "/" || path28.startsWith("/") || path28.startsWith("./")) || path28.split("/").some((part) => ["..", "__proto__", "constructor", "prototype"].includes(part))) {
|
|
41754
|
+
return false;
|
|
41755
|
+
}
|
|
41756
|
+
}
|
|
41757
|
+
const candidate = trimmed.replace(token, "value");
|
|
41758
|
+
if (candidate.includes("{{") || candidate.includes("}}"))
|
|
41759
|
+
return false;
|
|
41760
|
+
try {
|
|
41761
|
+
const parsedUrl = new URL(candidate);
|
|
41762
|
+
if (actionName === "ui.miniprogram.embed") {
|
|
41763
|
+
return Boolean(parsedUrl.searchParams.get("appId"));
|
|
41764
|
+
}
|
|
41765
|
+
return ["https:", "alipays:"].includes(parsedUrl.protocol);
|
|
41766
|
+
} catch {
|
|
41767
|
+
return false;
|
|
41768
|
+
}
|
|
41769
|
+
}
|
|
41770
|
+
function orderedComponents(bundle) {
|
|
41771
|
+
const result = [];
|
|
41772
|
+
for (const message of bundle.card) {
|
|
41773
|
+
for (const instruction of message.datas) {
|
|
41774
|
+
if (!("updateComponents" in instruction))
|
|
41775
|
+
continue;
|
|
41776
|
+
for (const component of instruction.updateComponents.components) {
|
|
41777
|
+
result.push({
|
|
41778
|
+
surfaceId: instruction.updateComponents.surfaceId,
|
|
41779
|
+
component
|
|
41780
|
+
});
|
|
41781
|
+
}
|
|
41782
|
+
}
|
|
41783
|
+
}
|
|
41784
|
+
return result;
|
|
41785
|
+
}
|
|
41786
|
+
function discoverTargets(value, occurrenceId, propertyPath, targets) {
|
|
41787
|
+
if (Array.isArray(value)) {
|
|
41788
|
+
value.forEach((entry, index) => discoverTargets(entry, occurrenceId, appendPath(propertyPath, String(index)), targets));
|
|
41789
|
+
return;
|
|
41790
|
+
}
|
|
41791
|
+
if (!isPlainRecord(value))
|
|
41792
|
+
return;
|
|
41793
|
+
if (typeof value.path === "string")
|
|
41794
|
+
return;
|
|
41795
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
41796
|
+
const nextPath = appendPath(propertyPath, key);
|
|
41797
|
+
if (INTERNAL_KEYS.has(key) || key === "action")
|
|
41798
|
+
continue;
|
|
41799
|
+
if (Array.isArray(entry) || isPlainRecord(entry)) {
|
|
41800
|
+
discoverTargets(entry, occurrenceId, nextPath, targets);
|
|
41801
|
+
continue;
|
|
41802
|
+
}
|
|
41803
|
+
if (!isJsonValue(entry))
|
|
41804
|
+
continue;
|
|
41805
|
+
if (typeof entry !== "string" || !MERCHANT_CONTENT_KEYS.has(key))
|
|
41806
|
+
continue;
|
|
41807
|
+
targets.push({
|
|
41808
|
+
kind: "literal",
|
|
41809
|
+
targetId: createA2UICardAuthoringTargetId(occurrenceId, nextPath),
|
|
41810
|
+
occurrenceId,
|
|
41811
|
+
propertyPath: nextPath,
|
|
41812
|
+
label: propertyLabel(nextPath),
|
|
41813
|
+
value: entry
|
|
41814
|
+
});
|
|
41815
|
+
}
|
|
41816
|
+
}
|
|
41817
|
+
function actionTargets(component, occurrenceId) {
|
|
41818
|
+
if (!isPlainRecord(component.action))
|
|
41819
|
+
return [];
|
|
41820
|
+
const action = component.action;
|
|
41821
|
+
const event = isPlainRecord(action.event) ? action.event : void 0;
|
|
41822
|
+
if (event) {
|
|
41823
|
+
const message = event["x2-user-message"];
|
|
41824
|
+
if (typeof message === "string" && typeof event.name === "string") {
|
|
41825
|
+
return [
|
|
41826
|
+
{
|
|
41827
|
+
kind: "agent-event",
|
|
41828
|
+
targetId: createA2UICardAuthoringTargetId(occurrenceId, "action"),
|
|
41829
|
+
occurrenceId,
|
|
41830
|
+
propertyPath: "action",
|
|
41831
|
+
label: "\u70B9\u51FB\u540E",
|
|
41832
|
+
message,
|
|
41833
|
+
eventName: event.name,
|
|
41834
|
+
hasContext: isPlainRecord(event.context)
|
|
41835
|
+
}
|
|
41836
|
+
];
|
|
41837
|
+
}
|
|
41838
|
+
return [agentOnlyAction(occurrenceId, "\u52A8\u6001\u6216\u590D\u6742\u4E8B\u4EF6\u901A\u8FC7\u667A\u80FD\u4F53\u4FEE\u6539")];
|
|
41839
|
+
}
|
|
41840
|
+
const functionAction = isPlainRecord(action.function) ? action.function : void 0;
|
|
41841
|
+
if (functionAction && typeof functionAction.ref === "string") {
|
|
41842
|
+
return [
|
|
41843
|
+
{
|
|
41844
|
+
kind: "function",
|
|
41845
|
+
targetId: createA2UICardAuthoringTargetId(occurrenceId, "action"),
|
|
41846
|
+
occurrenceId,
|
|
41847
|
+
propertyPath: "action",
|
|
41848
|
+
label: "\u524D\u7AEF\u51FD\u6570",
|
|
41849
|
+
ref: functionAction.ref
|
|
41850
|
+
}
|
|
41851
|
+
];
|
|
41852
|
+
}
|
|
41853
|
+
const client = isPlainRecord(action.client) ? action.client : void 0;
|
|
41854
|
+
if (client?.name === "ui.page.open" || client?.name === "ui.miniprogram.embed") {
|
|
41855
|
+
const context = isPlainRecord(client.context) ? client.context : void 0;
|
|
41856
|
+
const url2 = context?.url;
|
|
41857
|
+
return [
|
|
41858
|
+
{
|
|
41859
|
+
kind: client.name === "ui.miniprogram.embed" ? "miniprogram-embed" : "page-open",
|
|
41860
|
+
targetId: createA2UICardAuthoringTargetId(occurrenceId, "action"),
|
|
41861
|
+
occurrenceId,
|
|
41862
|
+
propertyPath: "action",
|
|
41863
|
+
label: client.name === "ui.miniprogram.embed" ? "\u534A\u5C4F\u6253\u5F00\u5C0F\u7A0B\u5E8F" : "\u6253\u5F00\u9875\u9762",
|
|
41864
|
+
...typeof url2 === "string" ? { url: url2 } : {},
|
|
41865
|
+
dynamic: isPlainRecord(url2) && typeof url2.path === "string"
|
|
41866
|
+
}
|
|
41867
|
+
];
|
|
41868
|
+
}
|
|
41869
|
+
return [agentOnlyAction(occurrenceId, "\u8BE5\u884C\u4E3A\u53EA\u80FD\u901A\u8FC7 Coding Agent \u4FEE\u6539")];
|
|
41870
|
+
}
|
|
41871
|
+
function fieldTargets(component, occurrenceId, fields2, occurrences, projectedOnly) {
|
|
41872
|
+
const projection = componentAuthoringProjection(component);
|
|
41873
|
+
const ordered = [...fields2].sort((left, right) => right.path.length - left.path.length);
|
|
41874
|
+
return occurrences.flatMap((occurrence) => {
|
|
41875
|
+
if (projectedOnly && !isProjectedFieldOccurrence(occurrence.propertyPath, projection)) {
|
|
41876
|
+
return [];
|
|
41877
|
+
}
|
|
41878
|
+
const field = ordered.find((candidate) => occurrence.canonicalPath === candidate.path || occurrence.canonicalPath.startsWith(`${candidate.path}/*/`) || occurrence.canonicalPath.startsWith(`${candidate.path}/`));
|
|
41879
|
+
if (!field)
|
|
41880
|
+
return [];
|
|
41881
|
+
const suffix = occurrence.canonicalPath.slice(field.path.length).replace(/^\/\*/u, "");
|
|
41882
|
+
const targetPath = suffix ? suffix.startsWith("/") ? suffix : `/${suffix}` : void 0;
|
|
41883
|
+
return [
|
|
41884
|
+
{
|
|
41885
|
+
kind: "field-occurrence",
|
|
41886
|
+
targetId: createA2UICardAuthoringTargetId(occurrenceId, occurrence.propertyPath),
|
|
41887
|
+
occurrenceId,
|
|
41888
|
+
propertyPath: occurrence.propertyPath,
|
|
41889
|
+
label: fieldOccurrenceLabel(targetPath, occurrence.propertyPath),
|
|
41890
|
+
fieldId: field.fieldId,
|
|
41891
|
+
dataPath: occurrence.rawPath,
|
|
41892
|
+
...occurrence.listRoot ? { listRoot: occurrence.listRoot } : {},
|
|
41893
|
+
valueType: occurrence.usage === "list" ? "array" : getJsonSchemaAtDataPointer(field.valueSchema, occurrence.canonicalPath.slice(field.path.length) || "/")?.type,
|
|
41894
|
+
...targetPath ? { targetPath } : {}
|
|
41895
|
+
}
|
|
41896
|
+
];
|
|
41897
|
+
});
|
|
41898
|
+
}
|
|
41899
|
+
function isProjectedFieldOccurrence(propertyPath, projection) {
|
|
41900
|
+
if (propertyPath === "action" || propertyPath.startsWith("action.")) {
|
|
41901
|
+
return false;
|
|
41902
|
+
}
|
|
41903
|
+
return projection.fieldProperties === void 0 || projection.fieldProperties.includes(propertyPath);
|
|
41904
|
+
}
|
|
41905
|
+
function fieldOccurrenceLabel(targetPath, propertyPath) {
|
|
41906
|
+
if (!targetPath)
|
|
41907
|
+
return propertyLabel(propertyPath);
|
|
41908
|
+
const segment = targetPath.split("/").filter(Boolean).at(-1);
|
|
41909
|
+
return segment ? decodeJsonPointerSegment(segment) : propertyLabel(propertyPath);
|
|
41910
|
+
}
|
|
41911
|
+
function decodeJsonPointerSegment(segment) {
|
|
41912
|
+
return segment.replace(/~1/gu, "/").replace(/~0/gu, "~");
|
|
41913
|
+
}
|
|
41914
|
+
function groupBindingOccurrences(occurrences) {
|
|
41915
|
+
const result = /* @__PURE__ */ new Map();
|
|
41916
|
+
for (const occurrence of occurrences) {
|
|
41917
|
+
if (!occurrence.surfaceId)
|
|
41918
|
+
continue;
|
|
41919
|
+
const key = componentKey(occurrence.surfaceId, occurrence.componentId);
|
|
41920
|
+
const entries = result.get(key) ?? [];
|
|
41921
|
+
entries.push(occurrence);
|
|
41922
|
+
result.set(key, entries);
|
|
41923
|
+
}
|
|
41924
|
+
return result;
|
|
41925
|
+
}
|
|
41926
|
+
function findComponent(bundle, surfaceId, componentId) {
|
|
41927
|
+
return orderedComponents(bundle).find((entry) => entry.surfaceId === surfaceId && entry.component.id === componentId)?.component;
|
|
41928
|
+
}
|
|
41929
|
+
function agentOnlyAction(occurrenceId, reason) {
|
|
41930
|
+
return {
|
|
41931
|
+
kind: "agent-only",
|
|
41932
|
+
targetId: createA2UICardAuthoringTargetId(occurrenceId, "action"),
|
|
41933
|
+
occurrenceId,
|
|
41934
|
+
propertyPath: "action",
|
|
41935
|
+
label: "\u901A\u8FC7 Coding Agent \u4FEE\u6539\u884C\u4E3A",
|
|
41936
|
+
reason
|
|
41937
|
+
};
|
|
41938
|
+
}
|
|
41939
|
+
function componentLabel(component) {
|
|
41940
|
+
const candidate = component.label ?? component.title ?? component.text;
|
|
41941
|
+
return typeof candidate === "string" && candidate.trim() ? candidate : component.component;
|
|
41942
|
+
}
|
|
41943
|
+
function propertyLabel(propertyPath) {
|
|
41944
|
+
const key = propertyPath.split(".").at(-1) ?? propertyPath;
|
|
41945
|
+
const labels = {
|
|
41946
|
+
text: "\u6587\u6848",
|
|
41947
|
+
title: "\u6807\u9898",
|
|
41948
|
+
subtitle: "\u526F\u6807\u9898",
|
|
41949
|
+
label: "\u6807\u7B7E",
|
|
41950
|
+
description: "\u8BF4\u660E",
|
|
41951
|
+
value: "\u5185\u5BB9",
|
|
41952
|
+
alt: "\u56FE\u7247\u8BF4\u660E"
|
|
41953
|
+
};
|
|
41954
|
+
return labels[key] ?? key;
|
|
41955
|
+
}
|
|
41956
|
+
function appendPath(base, segment) {
|
|
41957
|
+
return base ? `${base}.${segment}` : segment;
|
|
41958
|
+
}
|
|
41959
|
+
function componentKey(surfaceId, componentId) {
|
|
41960
|
+
return `${surfaceId}\0${componentId}`;
|
|
41961
|
+
}
|
|
41962
|
+
function deduplicateTargets(targets) {
|
|
41963
|
+
return [
|
|
41964
|
+
...new Map(targets.map((target) => [target.targetId, target])).values()
|
|
41965
|
+
];
|
|
41966
|
+
}
|
|
41967
|
+
function deduplicateDiagnostics(diagnostics) {
|
|
41968
|
+
return [
|
|
41969
|
+
...new Map(diagnostics.map((entry) => [
|
|
41970
|
+
`${entry.code}\0${entry.path}\0${entry.fieldId ?? ""}`,
|
|
41971
|
+
entry
|
|
41972
|
+
])).values()
|
|
41973
|
+
];
|
|
41974
|
+
}
|
|
41975
|
+
function cloneBinding(binding) {
|
|
41976
|
+
return JSON.parse(JSON.stringify(binding));
|
|
41977
|
+
}
|
|
41978
|
+
|
|
41979
|
+
// ../linkque-agent-protocol/dist/esm/validator/impl/vanillajs/valueChecks.js
|
|
41980
|
+
var diagnostic = (path28, code, message) => ({ path: path28, code, message });
|
|
41981
|
+
function isRecord(value) {
|
|
41982
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.prototype.toString.call(value) === "[object Object]";
|
|
41983
|
+
}
|
|
41984
|
+
function fieldPath(path28, key) {
|
|
41985
|
+
return /^[A-Za-z_$][\w$]*$/u.test(key) ? `${path28}.${key}` : `${path28}[${JSON.stringify(key)}]`;
|
|
41986
|
+
}
|
|
41987
|
+
var invalidType = (value, path28, expected) => [
|
|
41988
|
+
diagnostic(path28, value === void 0 ? "REQUIRED" : "INVALID_TYPE", `\u5E94\u4E3A${expected}`)
|
|
41989
|
+
];
|
|
41990
|
+
var stringValue = (value, path28) => typeof value === "string" ? [] : invalidType(value, path28, "\u5B57\u7B26\u4E32");
|
|
41991
|
+
var booleanValue = (value, path28) => typeof value === "boolean" ? [] : invalidType(value, path28, "\u5E03\u5C14\u503C");
|
|
41992
|
+
var numberValue = (value, path28) => typeof value === "number" && Number.isFinite(value) ? [] : invalidType(value, path28, "\u6709\u9650\u6570\u503C");
|
|
41993
|
+
var objectValue = (value, path28) => isRecord(value) ? [] : invalidType(value, path28, "\u5BF9\u8C61");
|
|
41994
|
+
var arrayValue = (value, path28) => Array.isArray(value) ? [] : invalidType(value, path28, "\u6570\u7EC4");
|
|
41995
|
+
var optional = (check2) => (value, path28, strict) => value === void 0 ? [] : check2(value, path28, strict);
|
|
41996
|
+
var enumValue = (values) => (value, path28) => {
|
|
41997
|
+
const issues = stringValue(value, path28, false);
|
|
41998
|
+
return issues.length ? issues : values.includes(value) ? [] : [
|
|
41999
|
+
diagnostic(path28, "INVALID_ENUM", `\u5E94\u4E3A\u4EE5\u4E0B\u679A\u4E3E\u4E4B\u4E00\uFF1A${values.join("\u3001")}`)
|
|
42000
|
+
];
|
|
42001
|
+
};
|
|
42002
|
+
var arrayOf = (check2) => (value, path28, strict) => {
|
|
42003
|
+
if (!Array.isArray(value))
|
|
42004
|
+
return arrayValue(value, path28, strict);
|
|
42005
|
+
const issues = [];
|
|
42006
|
+
for (let index = 0; index < value.length; index++)
|
|
42007
|
+
issues.push(...check2(value[index], `${path28}[${index}]`, strict));
|
|
42008
|
+
return issues;
|
|
42009
|
+
};
|
|
42010
|
+
var deferred = () => [];
|
|
42011
|
+
var objectOf = (fields2) => (value, path28, strict) => {
|
|
42012
|
+
if (!isRecord(value))
|
|
42013
|
+
return objectValue(value, path28, strict);
|
|
42014
|
+
const issues = [];
|
|
42015
|
+
for (const [key, check2] of Object.entries(fields2)) {
|
|
42016
|
+
issues.push(...check2(Object.hasOwn(value, key) ? value[key] : void 0, fieldPath(path28, key), strict));
|
|
42017
|
+
}
|
|
42018
|
+
if (strict) {
|
|
42019
|
+
for (const key of Object.keys(value)) {
|
|
42020
|
+
if (!Object.hasOwn(fields2, key))
|
|
42021
|
+
issues.push(diagnostic(fieldPath(path28, key), "UNKNOWN_FIELD", "\u534F\u8BAE\u672A\u58F0\u660E\u6B64\u5B57\u6BB5"));
|
|
42022
|
+
}
|
|
42023
|
+
}
|
|
42024
|
+
return issues;
|
|
42025
|
+
};
|
|
42026
|
+
|
|
42027
|
+
// ../linkque-agent-protocol/dist/esm/validator/impl/vanillajs/remoteAgentRules.js
|
|
42028
|
+
var remoteAgentString = (value, path28) => typeof value === "string" && value.trim() ? [] : [diagnostic(path28, "INVALID_STRING", "\u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32")];
|
|
42029
|
+
var fields = {
|
|
42030
|
+
protocolVersion: enumValue(["0.3.0"]),
|
|
42031
|
+
name: remoteAgentString,
|
|
42032
|
+
enName: remoteAgentString,
|
|
42033
|
+
openAgentId: remoteAgentString,
|
|
42034
|
+
description: remoteAgentString,
|
|
42035
|
+
routingExamples: optional(arrayOf(remoteAgentString))
|
|
42036
|
+
};
|
|
42037
|
+
var shape = objectOf(fields);
|
|
42038
|
+
var remoteAgentConfig = (value, path28) => {
|
|
42039
|
+
const issues = shape(value, path28, false);
|
|
42040
|
+
if (isRecord(value) && Object.keys(value).some((key) => !Object.hasOwn(fields, key))) {
|
|
42041
|
+
issues.push(diagnostic(path28, "UNKNOWN_FIELD", "\u5305\u542B\u672A\u58F0\u660E\u5B57\u6BB5\uFF1B\u5730\u5740\u3001\u8D85\u65F6\u53CA\u51ED\u636E\u7531\u5BBF\u4E3B\u63D0\u4F9B"));
|
|
42042
|
+
}
|
|
42043
|
+
return issues;
|
|
42044
|
+
};
|
|
42045
|
+
|
|
42046
|
+
// ../linkque-agent-protocol/dist/esm/validator/impl/vanillajs/resourceRules.js
|
|
42047
|
+
function isResourcePair(resourceType, providerType, checks) {
|
|
42048
|
+
return typeof resourceType === "string" && Object.hasOwn(checks, resourceType) && typeof providerType === "string" && Object.hasOwn(checks[resourceType], providerType) && typeof checks[resourceType][providerType] === "function";
|
|
42049
|
+
}
|
|
42050
|
+
var mappingFields = {
|
|
42051
|
+
argJsonPath: stringValue,
|
|
42052
|
+
disabled: booleanValue,
|
|
42053
|
+
valueType: enumValue(Object.values(EArgsMappingValueType)),
|
|
42054
|
+
value: optional(stringValue)
|
|
42055
|
+
};
|
|
42056
|
+
function createResourceConfigChecks() {
|
|
42057
|
+
return {
|
|
42058
|
+
REMOTE_AGENT: { [EResourceProviderType.ALIPAY_OPEN]: remoteAgentConfig },
|
|
42059
|
+
SKILL: {
|
|
42060
|
+
[EResourceProviderType.ALIPAY_OPEN]: objectOf({
|
|
42061
|
+
skillZipUrl: optional(stringValue)
|
|
42062
|
+
})
|
|
42063
|
+
},
|
|
42064
|
+
MCP: {
|
|
42065
|
+
[EResourceProviderType.ALIPAY_OPEN]: objectOf({
|
|
42066
|
+
agentId: stringValue,
|
|
42067
|
+
serverName: stringValue,
|
|
42068
|
+
description: stringValue,
|
|
42069
|
+
argsMappingRules: arrayOf(objectOf({ mcpToolName: stringValue, ...mappingFields })),
|
|
42070
|
+
allowedTools: optional(arrayOf(stringValue))
|
|
42071
|
+
})
|
|
42072
|
+
},
|
|
42073
|
+
MCP_TOOL: {
|
|
42074
|
+
[EResourceProviderType.ALIPAY_OPEN]: objectOf({
|
|
42075
|
+
agentId: stringValue,
|
|
42076
|
+
serverName: stringValue,
|
|
42077
|
+
description: stringValue,
|
|
42078
|
+
toolName: stringValue,
|
|
42079
|
+
argsMappingRules: optional(arrayOf(objectOf(mappingFields))),
|
|
42080
|
+
dependencies: optional(arrayOf(objectOf({
|
|
42081
|
+
name: enumValue(["phoneAuthorization"]),
|
|
42082
|
+
required: booleanValue
|
|
42083
|
+
})))
|
|
42084
|
+
})
|
|
42085
|
+
},
|
|
42086
|
+
KNOWLEDGE: {
|
|
42087
|
+
[EResourceProviderType.ALIPAY_OPEN]: objectOf({
|
|
42088
|
+
knowledgeDesc: stringValue,
|
|
42089
|
+
knowledgeBaseId: stringValue
|
|
42090
|
+
})
|
|
42091
|
+
},
|
|
42092
|
+
CARD: {
|
|
42093
|
+
[EResourceProviderType.LINK_QUE]: (value, path28) => getA2UICardResourceConfigIssues(value).map((issue4) => ({
|
|
42094
|
+
...issue4,
|
|
42095
|
+
path: issue4.path === "config" ? path28 : issue4.path.startsWith("config.") || issue4.path.startsWith("config[") || issue4.path.startsWith("config/") ? `${path28}${issue4.path.slice(6)}` : `${path28}.${issue4.path}`
|
|
42096
|
+
}))
|
|
42097
|
+
},
|
|
42098
|
+
TOOL: {
|
|
42099
|
+
[EResourceProviderType.BUILTIN]: objectOf({
|
|
42100
|
+
websearch: objectOf({ enable: booleanValue })
|
|
42101
|
+
})
|
|
42102
|
+
},
|
|
42103
|
+
WEB_SEARCH: {
|
|
42104
|
+
[EResourceProviderType.BUILTIN]: objectOf({ enable: booleanValue })
|
|
42105
|
+
},
|
|
42106
|
+
MEMORY: {
|
|
42107
|
+
[EResourceProviderType.BUILTIN]: objectOf({
|
|
42108
|
+
crossSessionEnabled: optional(booleanValue)
|
|
42109
|
+
})
|
|
42110
|
+
},
|
|
42111
|
+
FOLLOW_UP_QUESTIONS: {
|
|
42112
|
+
[EResourceProviderType.BUILTIN]: objectOf({ enable: booleanValue })
|
|
42113
|
+
},
|
|
42114
|
+
CLIENT_CAPABILITY: {
|
|
42115
|
+
[EResourceProviderType.BUILTIN]: objectOf({
|
|
42116
|
+
allowedCapabilities: arrayOf(enumValue(["location"]))
|
|
42117
|
+
})
|
|
42118
|
+
},
|
|
42119
|
+
HOOK: {
|
|
42120
|
+
[EResourceProviderType.LINK_QUE]: objectOf({
|
|
42121
|
+
name: stringValue,
|
|
42122
|
+
executorName: enumValue(Object.values(EHookExecutorName)),
|
|
42123
|
+
stage: enumValue(Object.values(EHookStage)),
|
|
42124
|
+
hasSideEffects: booleanValue,
|
|
42125
|
+
enabled: optional(booleanValue),
|
|
42126
|
+
order: optional(numberValue),
|
|
42127
|
+
timeoutMs: optional(numberValue),
|
|
42128
|
+
matcher: optional(objectOf({
|
|
42129
|
+
toolNames: optional(arrayOf(stringValue)),
|
|
42130
|
+
runStatuses: optional(arrayOf(enumValue(["success", "failed"])))
|
|
42131
|
+
}))
|
|
42132
|
+
})
|
|
42133
|
+
}
|
|
42134
|
+
};
|
|
42135
|
+
}
|
|
42136
|
+
function createResourceRules(checks) {
|
|
42137
|
+
const rules = [];
|
|
42138
|
+
for (const resourceType of Object.values(EResourceType)) {
|
|
42139
|
+
for (const providerType of Object.values(EResourceProviderType)) {
|
|
42140
|
+
if (!isResourcePair(resourceType, providerType, checks))
|
|
42141
|
+
continue;
|
|
42142
|
+
const check2 = checks[resourceType][providerType];
|
|
42143
|
+
const target = {
|
|
42144
|
+
kind: "resourceConfig",
|
|
42145
|
+
resourceType,
|
|
42146
|
+
providerType
|
|
42147
|
+
};
|
|
42148
|
+
const prefix = `resourceConfig.${resourceType}.${providerType}`;
|
|
42149
|
+
rules.push({
|
|
42150
|
+
id: `${prefix}.shape`,
|
|
42151
|
+
target,
|
|
42152
|
+
validate: (value, context) => check2(value, context.path, context.options.strict ?? false)
|
|
42153
|
+
});
|
|
42154
|
+
if (resourceType === EResourceType.HOOK)
|
|
42155
|
+
rules.push({
|
|
42156
|
+
id: `${prefix}.timeout`,
|
|
42157
|
+
target,
|
|
42158
|
+
validate: (value, context) => isRecord(value) && typeof value.timeoutMs === "number" && Number.isFinite(value.timeoutMs) && (value.timeoutMs < 0 || value.timeoutMs > 6e3) ? [
|
|
42159
|
+
diagnostic(`${context.path}.timeoutMs`, "OUT_OF_RANGE", "\u8D85\u65F6\u65F6\u95F4\u987B\u5728 0\uFF5E6000 \u6BEB\u79D2\u4E4B\u95F4")
|
|
42160
|
+
] : []
|
|
42161
|
+
});
|
|
42162
|
+
}
|
|
42163
|
+
}
|
|
42164
|
+
return rules;
|
|
42165
|
+
}
|
|
42166
|
+
function resourceCollectionIssues(value, path28) {
|
|
42167
|
+
if (!Array.isArray(value))
|
|
42168
|
+
return [];
|
|
42169
|
+
const issues = [];
|
|
42170
|
+
const ids = /* @__PURE__ */ new Set();
|
|
42171
|
+
const remoteIds = /* @__PURE__ */ new Set();
|
|
42172
|
+
const remoteNames = /* @__PURE__ */ new Set();
|
|
42173
|
+
const singletons = /* @__PURE__ */ new Set();
|
|
42174
|
+
value.forEach((resource, index) => {
|
|
42175
|
+
if (!isRecord(resource))
|
|
42176
|
+
return;
|
|
42177
|
+
if (typeof resource.resourceId === "string") {
|
|
42178
|
+
const scopedIds = resource.resourceType === EResourceType.REMOTE_AGENT ? remoteIds : ids;
|
|
42179
|
+
if (scopedIds.has(resource.resourceId))
|
|
42180
|
+
issues.push(diagnostic(`${path28}[${index}].resourceId`, "DUPLICATE_RESOURCE_ID", "\u8D44\u6E90 ID \u4E0D\u5F97\u91CD\u590D"));
|
|
42181
|
+
scopedIds.add(resource.resourceId);
|
|
42182
|
+
}
|
|
42183
|
+
if (resource.resourceType === EResourceType.REMOTE_AGENT && isRecord(resource.config) && typeof resource.config.enName === "string") {
|
|
42184
|
+
if (remoteNames.has(resource.config.enName)) {
|
|
42185
|
+
issues.push(diagnostic(`${path28}[${index}].config.enName`, "DUPLICATE_REMOTE_AGENT_NAME", "\u5728 REMOTE_AGENT \u4E2D\u5FC5\u987B\u552F\u4E00"));
|
|
42186
|
+
}
|
|
42187
|
+
remoteNames.add(resource.config.enName);
|
|
42188
|
+
}
|
|
42189
|
+
if (resource.resourceType === EResourceType.WEB_SEARCH || resource.resourceType === EResourceType.MEMORY) {
|
|
42190
|
+
if (singletons.has(resource.resourceType))
|
|
42191
|
+
issues.push(diagnostic(`${path28}[${index}].resourceType`, "RESOURCE_LIMIT_EXCEEDED", "\u6B64\u7C7B\u8D44\u6E90\u6700\u591A\u58F0\u660E\u4E00\u9879"));
|
|
42192
|
+
singletons.add(resource.resourceType);
|
|
42193
|
+
}
|
|
42194
|
+
});
|
|
42195
|
+
return issues;
|
|
42196
|
+
}
|
|
42197
|
+
|
|
42198
|
+
// ../linkque-agent-protocol/dist/esm/validator/impl/vanillajs/defaultRules.js
|
|
42199
|
+
var shapeRule = (kind, check2) => ({
|
|
42200
|
+
id: `${kind}.shape`,
|
|
42201
|
+
target: { kind },
|
|
42202
|
+
validate: (value, context) => check2(value, context.path, context.options.strict ?? false)
|
|
42203
|
+
});
|
|
42204
|
+
function createDefaultRules(resourceChecks) {
|
|
42205
|
+
const shapes = {
|
|
42206
|
+
protocol: objectOf({
|
|
42207
|
+
agentId: stringValue,
|
|
42208
|
+
name: stringValue,
|
|
42209
|
+
version: stringValue,
|
|
42210
|
+
agent: deferred
|
|
42211
|
+
}),
|
|
42212
|
+
agent: objectOf({
|
|
42213
|
+
model: deferred,
|
|
42214
|
+
systemPrompt: deferred,
|
|
42215
|
+
multimodel: deferred,
|
|
42216
|
+
resources: deferred,
|
|
42217
|
+
harness: deferred
|
|
42218
|
+
}),
|
|
42219
|
+
model: objectOf({
|
|
42220
|
+
provider: enumValue(Object.values(EModelProvider)),
|
|
42221
|
+
defaultModel: stringValue,
|
|
42222
|
+
callParams: optional(objectOf({
|
|
42223
|
+
temperature: optional(numberValue),
|
|
42224
|
+
topP: optional(numberValue),
|
|
42225
|
+
topK: optional(numberValue),
|
|
42226
|
+
maxTokens: optional(numberValue),
|
|
42227
|
+
thinkingLevel: optional(enumValue(["off", "low", "medium", "high"]))
|
|
42228
|
+
}))
|
|
42229
|
+
}),
|
|
42230
|
+
systemPrompt: objectOf({ content: stringValue }),
|
|
42231
|
+
multimodel: objectOf({ enabled: booleanValue }),
|
|
42232
|
+
harness: objectOf({ systemPrompt: stringValue }),
|
|
42233
|
+
resources: arrayValue,
|
|
42234
|
+
resource: objectOf({
|
|
42235
|
+
resourceId: stringValue,
|
|
42236
|
+
resourceType: enumValue(Object.values(EResourceType)),
|
|
42237
|
+
providerType: enumValue(Object.values(EResourceProviderType)),
|
|
42238
|
+
config: deferred
|
|
42239
|
+
})
|
|
42240
|
+
};
|
|
42241
|
+
return [
|
|
42242
|
+
...Object.entries(shapes).map(([kind, check2]) => shapeRule(kind, check2)),
|
|
42243
|
+
{
|
|
42244
|
+
id: "resources.constraints",
|
|
42245
|
+
target: { kind: "resources" },
|
|
42246
|
+
validate: (value, context) => resourceCollectionIssues(value, context.path)
|
|
42247
|
+
},
|
|
42248
|
+
{
|
|
42249
|
+
id: "resource.remoteAgent",
|
|
42250
|
+
target: { kind: "resource" },
|
|
42251
|
+
validate: (value, context) => isRecord(value) && value.resourceType === EResourceType.REMOTE_AGENT && typeof value.resourceId === "string" ? remoteAgentString(value.resourceId, `${context.path}.resourceId`, false) : []
|
|
42252
|
+
},
|
|
42253
|
+
{
|
|
42254
|
+
id: "resource.provider",
|
|
42255
|
+
target: { kind: "resource" },
|
|
42256
|
+
validate: (value, context) => {
|
|
42257
|
+
if (!isRecord(value) || typeof value.resourceType !== "string" || !Object.values(EResourceType).includes(value.resourceType) || !Object.values(EResourceProviderType).includes(value.providerType))
|
|
42258
|
+
return [];
|
|
42259
|
+
return isResourcePair(value.resourceType, value.providerType, resourceChecks) ? [] : [
|
|
42260
|
+
diagnostic(`${context.path}.providerType`, "INVALID_RESOURCE_PROVIDER", "\u8D44\u6E90\u7C7B\u578B\u4E0E\u63D0\u4F9B\u65B9\u4E0D\u5339\u914D")
|
|
42261
|
+
];
|
|
42262
|
+
}
|
|
42263
|
+
},
|
|
42264
|
+
...createResourceRules(resourceChecks)
|
|
42265
|
+
];
|
|
42266
|
+
}
|
|
42267
|
+
|
|
42268
|
+
// ../linkque-agent-protocol/dist/esm/validator/impl/vanillajs/vanillaAgentProtocolValidator.js
|
|
42269
|
+
function targetKey(target) {
|
|
42270
|
+
return target.kind === "resourceConfig" ? `${target.kind}:${target.resourceType}:${target.providerType}` : target.kind;
|
|
42271
|
+
}
|
|
42272
|
+
function copyRule(rule) {
|
|
42273
|
+
if (!rule.id.trim())
|
|
42274
|
+
throw new Error("\u6821\u9A8C\u89C4\u5219 ID \u4E0D\u80FD\u4E3A\u7A7A");
|
|
42275
|
+
return Object.freeze({
|
|
42276
|
+
id: rule.id,
|
|
42277
|
+
target: Object.freeze({ ...rule.target }),
|
|
42278
|
+
validate: rule.validate.bind(rule)
|
|
42279
|
+
});
|
|
42280
|
+
}
|
|
42281
|
+
var VanillaAgentProtocolValidator = class {
|
|
42282
|
+
resourceChecks;
|
|
42283
|
+
rulesByTarget;
|
|
42284
|
+
constructor(options = {}) {
|
|
42285
|
+
this.resourceChecks = createResourceConfigChecks();
|
|
42286
|
+
const defaults = createDefaultRules(this.resourceChecks);
|
|
42287
|
+
const known = new Map(defaults.map((rule) => [rule.id, rule]));
|
|
42288
|
+
const targets = new Set(defaults.map((rule) => targetKey(rule.target)));
|
|
42289
|
+
const overrides = /* @__PURE__ */ new Map();
|
|
42290
|
+
for (const [id2, rule] of Object.entries(options.ruleOverrides ?? {})) {
|
|
42291
|
+
const existing = known.get(id2);
|
|
42292
|
+
if (!existing)
|
|
42293
|
+
throw new Error(`\u5F85\u66FF\u6362\u7684\u9ED8\u8BA4\u89C4\u5219\u4E0D\u5B58\u5728\uFF1A${id2}`);
|
|
42294
|
+
if (rule.id !== id2 || targetKey(rule.target) !== targetKey(existing.target))
|
|
42295
|
+
throw new Error(`\u66FF\u6362\u89C4\u5219\u7684 ID \u6216\u76EE\u6807\u4E0D\u4E00\u81F4\uFF1A${id2}`);
|
|
42296
|
+
overrides.set(id2, copyRule(rule));
|
|
42297
|
+
}
|
|
42298
|
+
const rules = defaults.map((rule) => overrides.get(rule.id) ?? copyRule(rule));
|
|
42299
|
+
const ids = new Set(known.keys());
|
|
42300
|
+
for (const rule of options.additionalRules ?? []) {
|
|
42301
|
+
if (ids.has(rule.id))
|
|
42302
|
+
throw new Error(`\u6821\u9A8C\u89C4\u5219 ID \u91CD\u590D\uFF1A${rule.id}`);
|
|
42303
|
+
if (!targets.has(targetKey(rule.target)))
|
|
42304
|
+
throw new Error(`\u4E0D\u652F\u6301\u7684\u6821\u9A8C\u89C4\u5219\u76EE\u6807\uFF1A${targetKey(rule.target)}`);
|
|
42305
|
+
rules.push(copyRule(rule));
|
|
42306
|
+
ids.add(rule.id);
|
|
42307
|
+
}
|
|
42308
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
42309
|
+
for (const rule of rules) {
|
|
42310
|
+
const key = targetKey(rule.target);
|
|
42311
|
+
const group = grouped.get(key) ?? [];
|
|
42312
|
+
group.push(rule);
|
|
42313
|
+
grouped.set(key, group);
|
|
42314
|
+
}
|
|
42315
|
+
this.rulesByTarget = grouped;
|
|
42316
|
+
}
|
|
42317
|
+
validate(value, options) {
|
|
42318
|
+
return this.run(value, { kind: "protocol" }, options);
|
|
42319
|
+
}
|
|
42320
|
+
validateAgent(value, options) {
|
|
42321
|
+
return this.run(value, { kind: "agent" }, options);
|
|
42322
|
+
}
|
|
42323
|
+
validateModel(value, options) {
|
|
42324
|
+
return this.run(value, { kind: "model" }, options);
|
|
42325
|
+
}
|
|
42326
|
+
validateSystemPrompt(value, options) {
|
|
42327
|
+
return this.run(value, { kind: "systemPrompt" }, options);
|
|
42328
|
+
}
|
|
42329
|
+
validateMultimodel(value, options) {
|
|
42330
|
+
return this.run(value, { kind: "multimodel" }, options);
|
|
42331
|
+
}
|
|
42332
|
+
validateHarness(value, options) {
|
|
42333
|
+
return this.run(value, { kind: "harness" }, options);
|
|
42334
|
+
}
|
|
42335
|
+
validateResources(value, options) {
|
|
42336
|
+
return this.run(value, { kind: "resources" }, options);
|
|
42337
|
+
}
|
|
42338
|
+
validateResource(value, options) {
|
|
42339
|
+
return this.run(value, { kind: "resource" }, options);
|
|
42340
|
+
}
|
|
42341
|
+
validateResourceConfig(value, resourceType, providerType, options) {
|
|
42342
|
+
if (!isResourcePair(resourceType, providerType, this.resourceChecks)) {
|
|
42343
|
+
return {
|
|
42344
|
+
valid: false,
|
|
42345
|
+
issues: [
|
|
42346
|
+
{
|
|
42347
|
+
path: "$",
|
|
42348
|
+
code: "INVALID_RESOURCE_PROVIDER",
|
|
42349
|
+
message: "\u8D44\u6E90\u7C7B\u578B\u6216\u63D0\u4F9B\u65B9\u672A\u77E5\uFF0C\u6216\u4E24\u8005\u4E0D\u5339\u914D",
|
|
42350
|
+
ruleId: "resource.provider"
|
|
42351
|
+
}
|
|
42352
|
+
]
|
|
42353
|
+
};
|
|
42354
|
+
}
|
|
42355
|
+
return this.run(value, { kind: "resourceConfig", resourceType, providerType }, options);
|
|
42356
|
+
}
|
|
42357
|
+
run(value, target, options = {}) {
|
|
42358
|
+
const issues = [];
|
|
42359
|
+
const context = Object.freeze({
|
|
42360
|
+
root: value,
|
|
42361
|
+
options: Object.freeze({ strict: options.strict ?? false }),
|
|
42362
|
+
path: "$"
|
|
42363
|
+
});
|
|
42364
|
+
this.visit(value, target, context, issues);
|
|
42365
|
+
return { valid: issues.length === 0, issues };
|
|
42366
|
+
}
|
|
42367
|
+
visit(value, target, context, issues) {
|
|
42368
|
+
for (const rule of this.rulesByTarget.get(targetKey(target)) ?? []) {
|
|
42369
|
+
try {
|
|
42370
|
+
for (const issue4 of rule.validate(value, context))
|
|
42371
|
+
issues.push({
|
|
42372
|
+
path: issue4.path,
|
|
42373
|
+
code: issue4.code,
|
|
42374
|
+
message: issue4.message,
|
|
42375
|
+
ruleId: rule.id
|
|
42376
|
+
});
|
|
42377
|
+
} catch (cause) {
|
|
42378
|
+
throw new ValidationRuleExecutionError(rule.id, cause);
|
|
42379
|
+
}
|
|
42380
|
+
}
|
|
42381
|
+
if (target.kind === "resources" && Array.isArray(value)) {
|
|
42382
|
+
for (let index = 0; index < value.length; index++)
|
|
42383
|
+
this.visit(value[index], { kind: "resource" }, Object.freeze({ ...context, path: `${context.path}[${index}]` }), issues);
|
|
42384
|
+
}
|
|
42385
|
+
if (!isRecord(value))
|
|
42386
|
+
return;
|
|
42387
|
+
const child = (key, childTarget) => this.visit(Object.hasOwn(value, key) ? value[key] : void 0, childTarget, Object.freeze({ ...context, path: fieldPath(context.path, key) }), issues);
|
|
42388
|
+
if (target.kind === "protocol")
|
|
42389
|
+
child("agent", { kind: "agent" });
|
|
42390
|
+
if (target.kind === "agent") {
|
|
42391
|
+
child("model", { kind: "model" });
|
|
42392
|
+
child("systemPrompt", { kind: "systemPrompt" });
|
|
42393
|
+
child("multimodel", { kind: "multimodel" });
|
|
42394
|
+
child("resources", { kind: "resources" });
|
|
42395
|
+
if (Object.hasOwn(value, "harness") && value.harness !== void 0)
|
|
42396
|
+
child("harness", { kind: "harness" });
|
|
42397
|
+
}
|
|
42398
|
+
if (target.kind === "resource" && isResourcePair(value.resourceType, value.providerType, this.resourceChecks)) {
|
|
42399
|
+
child("config", {
|
|
42400
|
+
kind: "resourceConfig",
|
|
42401
|
+
resourceType: value.resourceType,
|
|
42402
|
+
providerType: value.providerType
|
|
42403
|
+
});
|
|
42404
|
+
}
|
|
42405
|
+
}
|
|
42406
|
+
};
|
|
42407
|
+
|
|
42408
|
+
// src/commands/agentConfigValidation.ts
|
|
42409
|
+
var isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
42410
|
+
function assertRemoteAgentConfig(protocol) {
|
|
42411
|
+
if (!isObject(protocol)) throw new Error("$: \u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
42412
|
+
if (!isObject(protocol.agent)) throw new Error("agent: \u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
42413
|
+
const resources = protocol.agent.resources;
|
|
42414
|
+
if (resources === void 0) return;
|
|
42415
|
+
if (!Array.isArray(resources)) throw new Error("agent.resources: \u5FC5\u987B\u662F\u6570\u7EC4");
|
|
42416
|
+
const entries = resources.map((resource, index) => ({ resource, index })).filter(
|
|
42417
|
+
({ resource }) => isObject(resource) && resource.resourceType === EResourceType.REMOTE_AGENT
|
|
42418
|
+
);
|
|
42419
|
+
const result = new VanillaAgentProtocolValidator().validateResources(
|
|
42420
|
+
entries.map(({ resource }) => resource)
|
|
42421
|
+
);
|
|
42422
|
+
const issue4 = result.issues[0];
|
|
42423
|
+
if (issue4) {
|
|
42424
|
+
const path28 = issue4.path.replace(
|
|
42425
|
+
/^\$\[(\d+)\]/,
|
|
42426
|
+
(_2, index) => `agent.resources[${entries[Number(index)].index}]`
|
|
42427
|
+
);
|
|
42428
|
+
throw new Error(`${path28}: ${issue4.message}`);
|
|
42429
|
+
}
|
|
42430
|
+
}
|
|
42431
|
+
|
|
42432
|
+
// src/commands/agentbuild/bundlerRoller.ts
|
|
42433
|
+
var import_node_fs7 = require("node:fs");
|
|
42434
|
+
var import_node_path10 = require("node:path");
|
|
42435
|
+
var import_node_module = require("node:module");
|
|
42436
|
+
var import_node_zlib = require("node:zlib");
|
|
42437
|
+
function distModulePath(pkgRoot, rel) {
|
|
42438
|
+
return (0, import_node_path10.resolve)(pkgRoot, "dist", "esm", rel);
|
|
42439
|
+
}
|
|
42440
|
+
var HANDLER_DIST_PATHS = {
|
|
42441
|
+
chat: "runtime/handler/chat.js",
|
|
42442
|
+
"client-capability": "runtime/handler/clientCapability.js"
|
|
42443
|
+
};
|
|
42444
|
+
var PROTOCOL_DIST_PATH = "runtime/protocol.js";
|
|
42445
|
+
async function createBundler(input) {
|
|
42446
|
+
const startedAt = Date.now();
|
|
42447
|
+
const protocol = JSON.parse(
|
|
42448
|
+
JSON.stringify(input.protocol)
|
|
42449
|
+
);
|
|
42450
|
+
assertRemoteAgentConfig(protocol);
|
|
42451
|
+
const pkgRoot = input.pkgRoot ?? process.cwd();
|
|
42452
|
+
const outDir = (0, import_node_path10.resolve)(input.outDir ?? (0, import_node_path10.join)(pkgRoot, "dist-bundle"));
|
|
42453
|
+
const entrypoint = input.entrypoint ?? "chat";
|
|
42454
|
+
const minify = input.minify ?? true;
|
|
42455
|
+
const bakeDir = (0, import_node_path10.join)(outDir, ".bake");
|
|
42456
|
+
(0, import_node_fs7.rmSync)(outDir, { recursive: true, force: true });
|
|
42457
|
+
(0, import_node_fs7.mkdirSync)(outDir, { recursive: true });
|
|
42458
|
+
prepareBakeDir(bakeDir);
|
|
42459
|
+
writeGeneratedProtocol(bakeDir, pkgRoot, protocol);
|
|
42460
|
+
const entryPath = writeEntry(bakeDir, pkgRoot, entrypoint);
|
|
42461
|
+
try {
|
|
42462
|
+
const result = await (0, import_esbuild.build)({
|
|
42463
|
+
entryPoints: [entryPath],
|
|
42464
|
+
bundle: true,
|
|
42465
|
+
// 用 CJS 而非 UMD:产物含 Node 内置 require('crypto'),UMD 的 globals 映射
|
|
42466
|
+
// 对 Node 内置不适用。AppBase node-22 runtime 支持 CJS entrypoint。
|
|
42467
|
+
format: "cjs",
|
|
42468
|
+
platform: "node",
|
|
42469
|
+
target: "node22",
|
|
42470
|
+
outfile: (0, import_node_path10.join)(outDir, "index.js"),
|
|
42471
|
+
minify,
|
|
42472
|
+
sourcemap: false,
|
|
42473
|
+
treeShaking: true,
|
|
42474
|
+
legalComments: "none",
|
|
42475
|
+
logLevel: "warning",
|
|
42476
|
+
// 全量 inline 依赖(Node 内置由 platform:node 自动留作裸名 require,运行时由 Node 提供)。
|
|
42477
|
+
external: [],
|
|
42478
|
+
// 固化 production 语义。
|
|
42479
|
+
define: { "process.env.NODE_ENV": '"production"' },
|
|
42480
|
+
// esbuild 默认不追加 development export 条件,故不会把带 development 字段的包
|
|
42481
|
+
// (如 @alipay/agent-a2ui-card-contract)解析到 src/*.ts;无需额外处理。
|
|
42482
|
+
write: false
|
|
42483
|
+
});
|
|
42484
|
+
const outputFile = result.outputFiles[0];
|
|
42485
|
+
if (!outputFile) throw new Error("esbuild \u672A\u4EA7\u51FA\u6587\u4EF6");
|
|
42486
|
+
const outputPath = (0, import_node_path10.join)(outDir, "index.js");
|
|
42487
|
+
(0, import_node_fs7.writeFileSync)(outputPath, outputFile.text, "utf8");
|
|
42488
|
+
await buildDataTransformWorker(pkgRoot, outDir, minify);
|
|
42489
|
+
const bundleName = "@alipay/linkque-agent-appwrite-gateway-bundle";
|
|
42490
|
+
(0, import_node_fs7.writeFileSync)(
|
|
42491
|
+
(0, import_node_path10.join)(outDir, "package.json"),
|
|
42492
|
+
JSON.stringify(
|
|
42493
|
+
{
|
|
42494
|
+
name: bundleName,
|
|
42495
|
+
version: "1.0.0",
|
|
42496
|
+
// CJS 产物(inline 全量业务依赖,Node 内置走 require);不加 type:module
|
|
42497
|
+
main: "./index.js"
|
|
42498
|
+
},
|
|
42499
|
+
null,
|
|
42500
|
+
2
|
|
42501
|
+
) + "\n"
|
|
42502
|
+
);
|
|
42503
|
+
(0, import_node_fs7.writeFileSync)(
|
|
42504
|
+
(0, import_node_path10.join)(outDir, "package-lock.json"),
|
|
42505
|
+
`${JSON.stringify({
|
|
42506
|
+
name: bundleName,
|
|
42507
|
+
version: "1.0.0",
|
|
42508
|
+
lockfileVersion: 3,
|
|
42509
|
+
packages: {}
|
|
42510
|
+
})}
|
|
42511
|
+
`,
|
|
42512
|
+
"utf8"
|
|
42513
|
+
);
|
|
42514
|
+
const bytes = (0, import_node_fs7.statSync)(outputPath).size;
|
|
42515
|
+
const gzipBytes = (0, import_node_zlib.gzipSync)(Buffer.from(outputFile.text, "utf8")).length;
|
|
42516
|
+
return { outputPath, bytes, gzipBytes, durationMs: Date.now() - startedAt };
|
|
42517
|
+
} finally {
|
|
42518
|
+
(0, import_node_fs7.rmSync)(bakeDir, { recursive: true, force: true });
|
|
42519
|
+
}
|
|
42520
|
+
}
|
|
42521
|
+
async function buildDataTransformWorker(pkgRoot, outDir, minify) {
|
|
42522
|
+
const portableRoot = (0, import_node_path10.join)(pkgRoot, "data-transform");
|
|
42523
|
+
const portableWorker = (0, import_node_path10.join)(portableRoot, "dataTransformWorker.js");
|
|
42524
|
+
const portableWasm = (0, import_node_path10.join)(portableRoot, "emscripten-module.wasm");
|
|
42525
|
+
if ((0, import_node_fs7.existsSync)(portableWorker) && (0, import_node_fs7.existsSync)(portableWasm)) {
|
|
42526
|
+
(0, import_node_fs7.copyFileSync)(portableWorker, (0, import_node_path10.join)(outDir, "dataTransformWorker.js"));
|
|
42527
|
+
(0, import_node_fs7.copyFileSync)(portableWasm, (0, import_node_path10.join)(outDir, "emscripten-module.wasm"));
|
|
42528
|
+
return;
|
|
42529
|
+
}
|
|
42530
|
+
const resolver = (0, import_node_module.createRequire)((0, import_node_path10.join)(pkgRoot, "package.json"));
|
|
42531
|
+
const runtimeRoot = (0, import_node_path10.dirname)(
|
|
42532
|
+
resolver.resolve("@alipay/linkque-agent-runtime/package.json")
|
|
42533
|
+
);
|
|
42534
|
+
const quickJsRoot = (0, import_node_path10.dirname)(
|
|
42535
|
+
resolver.resolve("@jitl/quickjs-wasmfile-release-sync/package.json")
|
|
42536
|
+
);
|
|
42537
|
+
const workerEntry = (0, import_node_path10.join)(runtimeRoot, "dist/esm/core/dataTransformWorker.js");
|
|
42538
|
+
const variantCjs = (0, import_node_path10.join)(quickJsRoot, "dist/index.js");
|
|
42539
|
+
const emscriptenCjs = (0, import_node_path10.join)(quickJsRoot, "dist/emscripten-module.cjs");
|
|
42540
|
+
await (0, import_esbuild.build)({
|
|
42541
|
+
entryPoints: [workerEntry],
|
|
42542
|
+
bundle: true,
|
|
42543
|
+
format: "cjs",
|
|
42544
|
+
platform: "node",
|
|
42545
|
+
target: "node22",
|
|
42546
|
+
outfile: (0, import_node_path10.join)(outDir, "dataTransformWorker.js"),
|
|
42547
|
+
minify,
|
|
42548
|
+
sourcemap: false,
|
|
42549
|
+
treeShaking: true,
|
|
42550
|
+
legalComments: "none",
|
|
42551
|
+
logLevel: "warning",
|
|
42552
|
+
plugins: [
|
|
42553
|
+
{
|
|
42554
|
+
name: "quickjs-node-cjs",
|
|
42555
|
+
setup(api) {
|
|
42556
|
+
api.onResolve(
|
|
42557
|
+
{ filter: /^@jitl\/quickjs-wasmfile-release-sync$/u },
|
|
42558
|
+
() => ({ path: variantCjs })
|
|
42559
|
+
);
|
|
42560
|
+
api.onResolve(
|
|
42561
|
+
{
|
|
42562
|
+
filter: /^@jitl\/quickjs-wasmfile-release-sync\/emscripten-module$/u
|
|
42563
|
+
},
|
|
42564
|
+
() => ({ path: emscriptenCjs })
|
|
42565
|
+
);
|
|
42566
|
+
}
|
|
42567
|
+
}
|
|
42568
|
+
]
|
|
42569
|
+
});
|
|
42570
|
+
(0, import_node_fs7.copyFileSync)(
|
|
42571
|
+
(0, import_node_path10.join)(quickJsRoot, "dist/emscripten-module.wasm"),
|
|
42572
|
+
(0, import_node_path10.join)(outDir, "emscripten-module.wasm")
|
|
42573
|
+
);
|
|
42574
|
+
}
|
|
42575
|
+
function prepareBakeDir(bakeDir) {
|
|
42576
|
+
(0, import_node_fs7.rmSync)(bakeDir, { recursive: true, force: true });
|
|
42577
|
+
(0, import_node_fs7.mkdirSync)(bakeDir, { recursive: true });
|
|
42578
|
+
}
|
|
42579
|
+
function writeGeneratedProtocol(bakeDir, pkgRoot, protocol) {
|
|
42580
|
+
const protocolJson = JSON.stringify(protocol);
|
|
42581
|
+
const code = `import { setBakedProtocol } from '${distModulePath(pkgRoot, PROTOCOL_DIST_PATH)}';
|
|
42582
|
+
setBakedProtocol(${protocolJson});
|
|
42583
|
+
`;
|
|
42584
|
+
(0, import_node_fs7.writeFileSync)((0, import_node_path10.join)(bakeDir, "protocol.generated.js"), code, "utf8");
|
|
42585
|
+
}
|
|
42586
|
+
function writeEntry(bakeDir, pkgRoot, entrypoint) {
|
|
42587
|
+
const handlerPath = distModulePath(pkgRoot, HANDLER_DIST_PATHS[entrypoint]);
|
|
42588
|
+
const code = `import './protocol.generated.js';
|
|
42589
|
+
export { default } from '${handlerPath}';
|
|
42590
|
+
`;
|
|
42591
|
+
const entryPath = (0, import_node_path10.join)(bakeDir, "entry.js");
|
|
42592
|
+
(0, import_node_fs7.writeFileSync)(entryPath, code, "utf8");
|
|
42593
|
+
return entryPath;
|
|
42594
|
+
}
|
|
42595
|
+
|
|
42596
|
+
// src/commands/agentbuild/bundlerApi.ts
|
|
42597
|
+
function assertProtocolValid(protocol) {
|
|
42598
|
+
const issues = [];
|
|
42599
|
+
if (!protocol.agentId) issues.push("agentId \u5FC5\u586B");
|
|
42600
|
+
if (!protocol.name) issues.push("name \u5FC5\u586B");
|
|
42601
|
+
if (!protocol.version) issues.push("version \u5FC5\u586B");
|
|
42602
|
+
if (!protocol.agent?.model) issues.push("agent.model \u5FC5\u586B");
|
|
42603
|
+
if (!protocol.agent?.systemPrompt) issues.push("agent.systemPrompt \u5FC5\u586B");
|
|
42604
|
+
if (issues.length) {
|
|
42605
|
+
throw new Error(`IAgentProtocol \u6821\u9A8C\u5931\u8D25: ${issues.join("; ")}`);
|
|
42606
|
+
}
|
|
42607
|
+
}
|
|
42608
|
+
async function bundleAgentInstallation(input) {
|
|
42609
|
+
assertProtocolValid(input.protocol);
|
|
42610
|
+
return createBundler(input);
|
|
42611
|
+
}
|
|
42612
|
+
|
|
42613
|
+
// src/commands/agentbuild/configLoader.ts
|
|
42614
|
+
var import_path7 = __toESM(require("path"));
|
|
42615
|
+
|
|
42616
|
+
// src/commands/agentbuild/types.ts
|
|
42617
|
+
var AGENT_BUNDLE_DIR = ".linkque/artifacts/agent-bundle";
|
|
42618
|
+
var AGENT_BUNDLE_ENTRY = "index.js";
|
|
42619
|
+
var AGENT_ARCHIVE_NAME = "code.tar";
|
|
42620
|
+
var AGENT_DEPLOY_META_NAME = "agent-deploy.meta.json";
|
|
42621
|
+
var DEFAULT_ARCHIVE_DIR = ".linkque/artifacts";
|
|
42622
|
+
var AGENTBUILD_LOCK = ".linkque/runtime/agentbuild.lock";
|
|
42623
|
+
var LOCK_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
42624
|
+
var LOCK_RETRY_MS = 100;
|
|
42625
|
+
var DEFAULT_CONFIG_NAME = "agent_config.json";
|
|
42626
|
+
|
|
42627
|
+
// src/commands/agentbuild/configLoader.ts
|
|
42628
|
+
var loadAgentProtocol = async (rawConfigPath, cwd) => {
|
|
42629
|
+
const configPath = import_path7.default.resolve(
|
|
42630
|
+
cwd,
|
|
42631
|
+
rawConfigPath === "" ? DEFAULT_CONFIG_NAME : rawConfigPath
|
|
42632
|
+
);
|
|
42633
|
+
if (!await pathHasKind(configPath, "file")) {
|
|
42634
|
+
throw new LinkqueCliError(
|
|
42635
|
+
"AGENTBUILD_CONFIG_NOT_FOUND",
|
|
42636
|
+
`agent config not found at ${configPath}`
|
|
42637
|
+
);
|
|
42638
|
+
}
|
|
42639
|
+
const content = await readUtf8IfExists(configPath);
|
|
42640
|
+
if (content === null) {
|
|
42641
|
+
throw new LinkqueCliError(
|
|
42642
|
+
"AGENTBUILD_CONFIG_INVALID",
|
|
42643
|
+
`agent config could not be read at ${configPath}`
|
|
42644
|
+
);
|
|
42645
|
+
}
|
|
42646
|
+
const root = parseJsonObject(
|
|
42647
|
+
content,
|
|
42648
|
+
"AGENTBUILD_CONFIG_INVALID",
|
|
42649
|
+
`agent config at ${configPath} is not a JSON object`
|
|
42650
|
+
);
|
|
42651
|
+
if (Object.prototype.hasOwnProperty.call(root, "apiKey")) {
|
|
42652
|
+
throw new LinkqueCliError(
|
|
42653
|
+
"AGENTBUILD_API_KEY_IN_CONFIG",
|
|
42654
|
+
`agent config at ${configPath} must not carry an 'apiKey' field (use env LINKQUE_API_KEY instead)`
|
|
42655
|
+
);
|
|
42656
|
+
}
|
|
42657
|
+
try {
|
|
42658
|
+
assertRemoteAgentConfig(root);
|
|
42659
|
+
return root;
|
|
42660
|
+
} catch (error2) {
|
|
42661
|
+
throw new LinkqueCliError(
|
|
42662
|
+
"AGENTBUILD_CONFIG_INVALID",
|
|
42663
|
+
`agent config at ${configPath} is invalid: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
42664
|
+
);
|
|
42665
|
+
}
|
|
42666
|
+
};
|
|
42667
|
+
|
|
42668
|
+
// ../linkque-agent-runtime/dist/esm/core/executionScene.js
|
|
42669
|
+
var EExecutionScene;
|
|
42670
|
+
(function(EExecutionScene2) {
|
|
42671
|
+
EExecutionScene2["DEVICE_PREVIEW"] = "DEVICE_PREVIEW";
|
|
42672
|
+
EExecutionScene2["SANDBOX_PREVIEW"] = "SANDBOX_PREVIEW";
|
|
42673
|
+
EExecutionScene2["LIVE"] = "LIVE";
|
|
42674
|
+
EExecutionScene2["UNKNOWN"] = "UNKNOWN";
|
|
42675
|
+
})(EExecutionScene || (EExecutionScene = {}));
|
|
42676
|
+
|
|
42677
|
+
// ../linkque-agent-runtime/dist/esm/core/mcpExecutionResult.js
|
|
42678
|
+
var EMcpErrorCode;
|
|
42679
|
+
(function(EMcpErrorCode2) {
|
|
42680
|
+
EMcpErrorCode2["ERR_UNKOWN"] = "ERR_UNKOWN";
|
|
42681
|
+
EMcpErrorCode2["ERR_AUTH"] = "ERR_AUTH";
|
|
42682
|
+
})(EMcpErrorCode || (EMcpErrorCode = {}));
|
|
42683
|
+
|
|
42684
|
+
// ../linkque-agent-runtime/dist/esm/core/modelRequestSource.js
|
|
42685
|
+
var EModelRequestSource;
|
|
42686
|
+
(function(EModelRequestSource2) {
|
|
42687
|
+
EModelRequestSource2["LINKQUE_EDITOR"] = "LINKQUE_EDITOR";
|
|
42688
|
+
EModelRequestSource2["APPBASE_FUNCTION"] = "APPBASE_FUNCTION";
|
|
42689
|
+
})(EModelRequestSource || (EModelRequestSource = {}));
|
|
42690
|
+
|
|
42691
|
+
// ../linkque-agent-runtime/dist/esm/core/dataTransformExecutor.js
|
|
42692
|
+
var import_node_crypto3 = require("node:crypto");
|
|
42693
|
+
var import_node_worker_threads = require("node:worker_threads");
|
|
42694
|
+
|
|
42695
|
+
// ../linkque-agent-runtime/dist/esm/core/dataTransformWorkerUrl.js
|
|
42696
|
+
var import_node_path11 = require("node:path");
|
|
42697
|
+
var import_node_url = require("node:url");
|
|
42698
|
+
var import_meta = {};
|
|
42699
|
+
function defaultDataTransformWorkerUrl() {
|
|
42700
|
+
if (typeof __dirname === "string") {
|
|
42701
|
+
return (0, import_node_url.pathToFileURL)((0, import_node_path11.join)(__dirname, "dataTransformWorker.js"));
|
|
42702
|
+
}
|
|
42703
|
+
return new URL("dataTransformWorker.js", import_meta.url);
|
|
42704
|
+
}
|
|
42705
|
+
|
|
42706
|
+
// ../linkque-agent-runtime/dist/esm/core/aiFilter.js
|
|
42707
|
+
function validateAIFilterIndices(value, length) {
|
|
42708
|
+
if (!Array.isArray(value) || Array.from(value).some((index) => !Number.isInteger(index) || index < 0 || index >= length) || new Set(value).size !== value.length) {
|
|
42709
|
+
throw new TypeError("AI \u7B5B\u9009\u7ED3\u679C\u5FC5\u987B\u662F\u8303\u56F4\u5408\u6CD5\u4E14\u4E0D\u91CD\u590D\u7684\u6574\u6570\u4E0B\u6807\u6570\u7EC4");
|
|
42710
|
+
}
|
|
42711
|
+
return value;
|
|
42712
|
+
}
|
|
42713
|
+
|
|
42714
|
+
// ../linkque-agent-runtime/dist/esm/core/dataTransformExecutor.js
|
|
42715
|
+
var DATA_TRANSFORM_LIMITS = Object.freeze({
|
|
42716
|
+
sourceBytes: 32 * 1024,
|
|
42717
|
+
inputBytes: 2 * 1024 * 1024,
|
|
42718
|
+
outputBytes: 1024 * 1024,
|
|
42719
|
+
maxDepth: 64,
|
|
42720
|
+
memoryBytes: 32 * 1024 * 1024,
|
|
42721
|
+
stackBytes: 512 * 1024,
|
|
42722
|
+
executionMs: 100,
|
|
42723
|
+
watchdogMs: 500,
|
|
42724
|
+
initializationMs: 5e3,
|
|
42725
|
+
maxConcurrent: 4,
|
|
42726
|
+
maxQueued: 32
|
|
42727
|
+
});
|
|
42728
|
+
var DataTransformError = class extends Error {
|
|
42729
|
+
code;
|
|
42730
|
+
sourceHash;
|
|
42731
|
+
constructor(code, message, sourceHash) {
|
|
42732
|
+
super(message);
|
|
42733
|
+
this.code = code;
|
|
42734
|
+
this.sourceHash = sourceHash;
|
|
42735
|
+
this.name = "DataTransformError";
|
|
42736
|
+
}
|
|
42737
|
+
};
|
|
42738
|
+
var DataTransformExecutor = class {
|
|
42739
|
+
workerUrl;
|
|
42740
|
+
queue = [];
|
|
42741
|
+
slots = [];
|
|
42742
|
+
nextRequestId = 1;
|
|
42743
|
+
disposed = false;
|
|
42744
|
+
constructor(workerUrl = defaultDataTransformWorkerUrl()) {
|
|
42745
|
+
this.workerUrl = workerUrl;
|
|
42746
|
+
}
|
|
42747
|
+
execute(source, input, signal, options) {
|
|
42748
|
+
const sourceBytes = Buffer.byteLength(source, "utf8");
|
|
42749
|
+
const sourceHash = (0, import_node_crypto3.createHash)("sha256").update(source).digest("hex");
|
|
42750
|
+
if (!source.trim() || sourceBytes > DATA_TRANSFORM_LIMITS.sourceBytes) {
|
|
42751
|
+
return Promise.reject(new DataTransformError("CARD_TRANSFORM_SOURCE_INVALID", `\u6570\u636E\u8F6C\u6362\u6E90\u7801\u4E3A\u7A7A\u6216\u8D85\u8FC7 ${DATA_TRANSFORM_LIMITS.sourceBytes} \u5B57\u8282`, sourceHash));
|
|
42752
|
+
}
|
|
42753
|
+
if (signal?.aborted) {
|
|
42754
|
+
return Promise.reject(signal.reason ?? new Error("\u64CD\u4F5C\u5DF2\u53D6\u6D88"));
|
|
42755
|
+
}
|
|
42756
|
+
let inputJson;
|
|
42757
|
+
try {
|
|
42758
|
+
inputJson = JSON.stringify(input);
|
|
42759
|
+
} catch {
|
|
42760
|
+
return Promise.reject(new DataTransformError("CARD_TRANSFORM_INPUT_TOO_LARGE", "\u6570\u636E\u8F6C\u6362\u8F93\u5165\u65E0\u6CD5\u5E8F\u5217\u5316", sourceHash));
|
|
42761
|
+
}
|
|
42762
|
+
const inputBytes = Buffer.byteLength(inputJson, "utf8");
|
|
42763
|
+
if (inputBytes > DATA_TRANSFORM_LIMITS.inputBytes || jsonDepth(input) > DATA_TRANSFORM_LIMITS.maxDepth) {
|
|
42764
|
+
return Promise.reject(new DataTransformError("CARD_TRANSFORM_INPUT_TOO_LARGE", "\u6570\u636E\u8F6C\u6362\u8F93\u5165\u8D85\u8FC7\u5927\u5C0F\u6216\u6DF1\u5EA6\u9650\u5236", sourceHash));
|
|
42765
|
+
}
|
|
42766
|
+
const active = this.slots.filter((slot) => slot.busy).length;
|
|
42767
|
+
if (active >= DATA_TRANSFORM_LIMITS.maxConcurrent && this.queue.length >= DATA_TRANSFORM_LIMITS.maxQueued) {
|
|
42768
|
+
return Promise.reject(new DataTransformError("CARD_TRANSFORM_BUSY", "\u6570\u636E\u8F6C\u6362\u6267\u884C\u961F\u5217\u5DF2\u6EE1", sourceHash));
|
|
42769
|
+
}
|
|
42770
|
+
if (this.disposed) {
|
|
42771
|
+
return Promise.reject(new DataTransformError("CARD_TRANSFORM_FAILED", "\u6570\u636E\u8F6C\u6362\u6267\u884C\u5668\u5DF2\u5173\u95ED", sourceHash));
|
|
42772
|
+
}
|
|
42773
|
+
return new Promise((resolve2, reject) => {
|
|
42774
|
+
const abortQueued = () => {
|
|
42775
|
+
const index = this.queue.indexOf(queued);
|
|
42776
|
+
if (index < 0)
|
|
42777
|
+
return;
|
|
42778
|
+
this.queue.splice(index, 1);
|
|
42779
|
+
queued.reject(signal?.reason ?? new Error("\u64CD\u4F5C\u5DF2\u53D6\u6D88"));
|
|
42780
|
+
};
|
|
42781
|
+
const queued = {
|
|
42782
|
+
mode: "execute",
|
|
42783
|
+
source,
|
|
42784
|
+
sourceHash,
|
|
42785
|
+
inputJson,
|
|
42786
|
+
inputBytes,
|
|
42787
|
+
signal,
|
|
42788
|
+
options,
|
|
42789
|
+
resolve: (value) => {
|
|
42790
|
+
signal?.removeEventListener("abort", abortQueued);
|
|
42791
|
+
resolve2(value);
|
|
42792
|
+
},
|
|
42793
|
+
reject: (reason) => {
|
|
42794
|
+
signal?.removeEventListener("abort", abortQueued);
|
|
42795
|
+
reject(reason);
|
|
42796
|
+
}
|
|
42797
|
+
};
|
|
42798
|
+
this.queue.push(queued);
|
|
42799
|
+
signal?.addEventListener("abort", abortQueued, { once: true });
|
|
42800
|
+
this.drain();
|
|
42801
|
+
});
|
|
42802
|
+
}
|
|
42803
|
+
validateSource(source, profile) {
|
|
42804
|
+
const sourceBytes = Buffer.byteLength(source, "utf8");
|
|
42805
|
+
const sourceHash = (0, import_node_crypto3.createHash)("sha256").update(source).digest("hex");
|
|
42806
|
+
if (!source.trim() || sourceBytes > DATA_TRANSFORM_LIMITS.sourceBytes) {
|
|
42807
|
+
return Promise.reject(new DataTransformError("CARD_TRANSFORM_SOURCE_INVALID", `\u6570\u636E\u8F6C\u6362\u6E90\u7801\u4E3A\u7A7A\u6216\u8D85\u8FC7 ${DATA_TRANSFORM_LIMITS.sourceBytes} \u5B57\u8282`, sourceHash));
|
|
42808
|
+
}
|
|
42809
|
+
if (this.disposed) {
|
|
42810
|
+
return Promise.reject(new DataTransformError("CARD_TRANSFORM_FAILED", "\u6570\u636E\u8F6C\u6362\u6267\u884C\u5668\u5DF2\u5173\u95ED", sourceHash));
|
|
42811
|
+
}
|
|
42812
|
+
const active = this.slots.filter((slot) => slot.busy).length;
|
|
42813
|
+
if (active >= DATA_TRANSFORM_LIMITS.maxConcurrent && this.queue.length >= DATA_TRANSFORM_LIMITS.maxQueued) {
|
|
42814
|
+
return Promise.reject(new DataTransformError("CARD_TRANSFORM_BUSY", "\u6570\u636E\u8F6C\u6362\u6267\u884C\u961F\u5217\u5DF2\u6EE1", sourceHash));
|
|
42278
42815
|
}
|
|
42816
|
+
return new Promise((resolve2, reject) => {
|
|
42817
|
+
this.queue.push({
|
|
42818
|
+
mode: "validate",
|
|
42819
|
+
source,
|
|
42820
|
+
sourceHash,
|
|
42821
|
+
inputJson: "[]",
|
|
42822
|
+
inputBytes: 2,
|
|
42823
|
+
options: { profile },
|
|
42824
|
+
resolve: () => resolve2(),
|
|
42825
|
+
reject
|
|
42826
|
+
});
|
|
42827
|
+
this.drain();
|
|
42828
|
+
});
|
|
42279
42829
|
}
|
|
42280
|
-
|
|
42281
|
-
|
|
42282
|
-
|
|
42283
|
-
|
|
42284
|
-
const parsedUrl = new URL(candidate);
|
|
42285
|
-
if (actionName === "ui.miniprogram.embed") {
|
|
42286
|
-
return Boolean(parsedUrl.searchParams.get("appId"));
|
|
42830
|
+
async close() {
|
|
42831
|
+
this.disposed = true;
|
|
42832
|
+
for (const queued of this.queue.splice(0)) {
|
|
42833
|
+
queued.reject(new DataTransformError("CARD_TRANSFORM_FAILED", "\u6570\u636E\u8F6C\u6362\u6267\u884C\u5668\u5DF2\u5173\u95ED", queued.sourceHash));
|
|
42287
42834
|
}
|
|
42288
|
-
|
|
42289
|
-
|
|
42290
|
-
|
|
42835
|
+
await Promise.all(this.slots.splice(0).map(async (slot) => {
|
|
42836
|
+
slot.cancel?.();
|
|
42837
|
+
slot.disposed = true;
|
|
42838
|
+
await slot.worker.terminate();
|
|
42839
|
+
}));
|
|
42291
42840
|
}
|
|
42292
|
-
|
|
42293
|
-
|
|
42294
|
-
|
|
42295
|
-
|
|
42296
|
-
|
|
42297
|
-
if (!
|
|
42841
|
+
drain() {
|
|
42842
|
+
if (this.disposed)
|
|
42843
|
+
return;
|
|
42844
|
+
while (this.queue.length > 0) {
|
|
42845
|
+
let slot = this.slots.find((candidate) => !candidate.busy);
|
|
42846
|
+
if (!slot && this.slots.length < DATA_TRANSFORM_LIMITS.maxConcurrent) {
|
|
42847
|
+
slot = this.createSlot();
|
|
42848
|
+
this.slots.push(slot);
|
|
42849
|
+
}
|
|
42850
|
+
if (!slot)
|
|
42851
|
+
return;
|
|
42852
|
+
const queued = this.queue.shift();
|
|
42853
|
+
if (!queued)
|
|
42854
|
+
return;
|
|
42855
|
+
if (queued.signal?.aborted) {
|
|
42856
|
+
queued.reject(queued.signal.reason ?? new Error("\u64CD\u4F5C\u5DF2\u53D6\u6D88"));
|
|
42298
42857
|
continue;
|
|
42299
|
-
for (const component of instruction.updateComponents.components) {
|
|
42300
|
-
result.push({
|
|
42301
|
-
surfaceId: instruction.updateComponents.surfaceId,
|
|
42302
|
-
component
|
|
42303
|
-
});
|
|
42304
42858
|
}
|
|
42859
|
+
slot.busy = true;
|
|
42860
|
+
void this.run(slot, queued).finally(() => {
|
|
42861
|
+
if (!slot.disposed)
|
|
42862
|
+
slot.busy = false;
|
|
42863
|
+
this.drain();
|
|
42864
|
+
});
|
|
42305
42865
|
}
|
|
42306
42866
|
}
|
|
42307
|
-
|
|
42308
|
-
|
|
42309
|
-
|
|
42310
|
-
|
|
42311
|
-
|
|
42312
|
-
|
|
42867
|
+
createSlot() {
|
|
42868
|
+
const worker = new import_node_worker_threads.Worker(this.workerUrl);
|
|
42869
|
+
const slot = {
|
|
42870
|
+
worker,
|
|
42871
|
+
busy: false,
|
|
42872
|
+
disposed: false,
|
|
42873
|
+
ready: Promise.resolve()
|
|
42874
|
+
};
|
|
42875
|
+
slot.ready = new Promise((resolve2, reject) => {
|
|
42876
|
+
const timeout = setTimeout(() => {
|
|
42877
|
+
reject(new DataTransformError("CARD_TRANSFORM_TIMEOUT", "\u6570\u636E\u8F6C\u6362\u5F15\u64CE\u521D\u59CB\u5316\u8D85\u65F6"));
|
|
42878
|
+
this.discardSlot(slot);
|
|
42879
|
+
}, DATA_TRANSFORM_LIMITS.initializationMs);
|
|
42880
|
+
worker.once("message", (message) => {
|
|
42881
|
+
if (message?.type !== "ready")
|
|
42882
|
+
return;
|
|
42883
|
+
clearTimeout(timeout);
|
|
42884
|
+
resolve2();
|
|
42885
|
+
});
|
|
42886
|
+
worker.once("error", (error2) => {
|
|
42887
|
+
clearTimeout(timeout);
|
|
42888
|
+
reject(error2);
|
|
42889
|
+
});
|
|
42890
|
+
worker.once("exit", () => {
|
|
42891
|
+
clearTimeout(timeout);
|
|
42892
|
+
reject(new Error("\u6570\u636E\u8F6C\u6362 Worker \u5DF2\u9000\u51FA"));
|
|
42893
|
+
});
|
|
42894
|
+
});
|
|
42895
|
+
return slot;
|
|
42313
42896
|
}
|
|
42314
|
-
|
|
42315
|
-
|
|
42316
|
-
|
|
42317
|
-
|
|
42318
|
-
|
|
42319
|
-
|
|
42320
|
-
|
|
42321
|
-
continue;
|
|
42322
|
-
if (Array.isArray(entry) || isPlainRecord(entry)) {
|
|
42323
|
-
discoverTargets(entry, occurrenceId, nextPath, targets);
|
|
42324
|
-
continue;
|
|
42897
|
+
async run(slot, queued) {
|
|
42898
|
+
try {
|
|
42899
|
+
await slot.ready;
|
|
42900
|
+
} catch (error2) {
|
|
42901
|
+
queued.reject(error2 instanceof DataTransformError ? error2 : new DataTransformError("CARD_TRANSFORM_FAILED", error2 instanceof Error ? error2.message : "\u6570\u636E\u8F6C\u6362\u5F15\u64CE\u521D\u59CB\u5316\u5931\u8D25", queued.sourceHash));
|
|
42902
|
+
this.discardSlot(slot);
|
|
42903
|
+
return;
|
|
42325
42904
|
}
|
|
42326
|
-
if (
|
|
42327
|
-
|
|
42328
|
-
|
|
42329
|
-
|
|
42330
|
-
|
|
42331
|
-
|
|
42332
|
-
|
|
42333
|
-
|
|
42334
|
-
|
|
42335
|
-
|
|
42336
|
-
|
|
42905
|
+
if (queued.signal?.aborted) {
|
|
42906
|
+
queued.reject(queued.signal.reason ?? new Error("\u64CD\u4F5C\u5DF2\u53D6\u6D88"));
|
|
42907
|
+
return;
|
|
42908
|
+
}
|
|
42909
|
+
const requestId = this.nextRequestId++;
|
|
42910
|
+
await new Promise((resolve2) => {
|
|
42911
|
+
let settled = false;
|
|
42912
|
+
let watchdog;
|
|
42913
|
+
const scope = new AbortController();
|
|
42914
|
+
const finish = (callback) => {
|
|
42915
|
+
if (settled)
|
|
42916
|
+
return;
|
|
42917
|
+
settled = true;
|
|
42918
|
+
clearTimeout(watchdog);
|
|
42919
|
+
scope.abort();
|
|
42920
|
+
slot.cancel = void 0;
|
|
42921
|
+
queued.signal?.removeEventListener("abort", abort2);
|
|
42922
|
+
slot.worker.off("message", onMessage2);
|
|
42923
|
+
slot.worker.off("error", onError);
|
|
42924
|
+
callback();
|
|
42925
|
+
resolve2();
|
|
42926
|
+
};
|
|
42927
|
+
const abort2 = () => {
|
|
42928
|
+
finish(() => {
|
|
42929
|
+
queued.reject(queued.signal?.reason ?? new Error("\u64CD\u4F5C\u5DF2\u53D6\u6D88"));
|
|
42930
|
+
this.discardSlot(slot);
|
|
42931
|
+
});
|
|
42932
|
+
};
|
|
42933
|
+
const onError = (error2) => {
|
|
42934
|
+
finish(() => {
|
|
42935
|
+
queued.reject(new DataTransformError("CARD_TRANSFORM_FAILED", error2.message, queued.sourceHash));
|
|
42936
|
+
this.discardSlot(slot);
|
|
42937
|
+
});
|
|
42938
|
+
};
|
|
42939
|
+
const armWatchdog = () => {
|
|
42940
|
+
clearTimeout(watchdog);
|
|
42941
|
+
watchdog = setTimeout(() => {
|
|
42942
|
+
finish(() => {
|
|
42943
|
+
queued.reject(new DataTransformError("CARD_TRANSFORM_TIMEOUT", "\u6570\u636E\u8F6C\u6362\u8D85\u8FC7\u5BBF\u4E3B\u6267\u884C\u671F\u9650", queued.sourceHash));
|
|
42944
|
+
this.discardSlot(slot);
|
|
42945
|
+
});
|
|
42946
|
+
}, DATA_TRANSFORM_LIMITS.watchdogMs);
|
|
42947
|
+
};
|
|
42948
|
+
const onMessage2 = (message) => {
|
|
42949
|
+
if (message?.requestId !== requestId || settled)
|
|
42950
|
+
return;
|
|
42951
|
+
if (message.type === "waiting") {
|
|
42952
|
+
clearTimeout(watchdog);
|
|
42953
|
+
} else if (message.type === "running") {
|
|
42954
|
+
armWatchdog();
|
|
42955
|
+
} else if (message.type === "filter") {
|
|
42956
|
+
const reply = (result) => {
|
|
42957
|
+
if (settled)
|
|
42958
|
+
return;
|
|
42959
|
+
armWatchdog();
|
|
42960
|
+
slot.worker.postMessage({
|
|
42961
|
+
type: "filter-result",
|
|
42962
|
+
requestId,
|
|
42963
|
+
callId: message.callId,
|
|
42964
|
+
...result
|
|
42965
|
+
});
|
|
42966
|
+
};
|
|
42967
|
+
void Promise.resolve().then(async () => {
|
|
42968
|
+
if (!queued.options?.aiFilter)
|
|
42969
|
+
throw new Error("\u5F53\u524D\u5DE5\u5177\u672A\u63D0\u4F9B AI \u7B5B\u9009\u80FD\u529B");
|
|
42970
|
+
const indices = await queued.options.aiFilter.select(message.modelList, message.prompt, scope.signal);
|
|
42971
|
+
return validateAIFilterIndices(indices, message.modelList.length);
|
|
42972
|
+
}).then((indices) => reply({ indices }), () => reply({ error: "AI \u7B5B\u9009\u6267\u884C\u5931\u8D25" }));
|
|
42973
|
+
} else if (message.type === "result") {
|
|
42974
|
+
finish(() => this.acceptWorkerResult(queued, message));
|
|
42975
|
+
}
|
|
42976
|
+
};
|
|
42977
|
+
slot.cancel = () => finish(() => queued.reject(new DataTransformError("CARD_TRANSFORM_FAILED", "\u6570\u636E\u8F6C\u6362\u6267\u884C\u5668\u5DF2\u5173\u95ED", queued.sourceHash)));
|
|
42978
|
+
armWatchdog();
|
|
42979
|
+
queued.signal?.addEventListener("abort", abort2, { once: true });
|
|
42980
|
+
slot.worker.on("message", onMessage2);
|
|
42981
|
+
slot.worker.once("error", onError);
|
|
42982
|
+
slot.worker.postMessage({
|
|
42983
|
+
type: "execute",
|
|
42984
|
+
mode: queued.mode,
|
|
42985
|
+
requestId,
|
|
42986
|
+
source: queued.source,
|
|
42987
|
+
inputJson: queued.inputJson,
|
|
42988
|
+
limits: DATA_TRANSFORM_LIMITS,
|
|
42989
|
+
profile: queued.options?.profile,
|
|
42990
|
+
preview: queued.options?.preview === true
|
|
42991
|
+
});
|
|
42337
42992
|
});
|
|
42338
42993
|
}
|
|
42339
|
-
|
|
42340
|
-
|
|
42341
|
-
|
|
42342
|
-
|
|
42343
|
-
const action = component.action;
|
|
42344
|
-
const event = isPlainRecord(action.event) ? action.event : void 0;
|
|
42345
|
-
if (event) {
|
|
42346
|
-
const message = event["x2-user-message"];
|
|
42347
|
-
if (typeof message === "string" && typeof event.name === "string") {
|
|
42348
|
-
return [
|
|
42349
|
-
{
|
|
42350
|
-
kind: "agent-event",
|
|
42351
|
-
targetId: createA2UICardAuthoringTargetId(occurrenceId, "action"),
|
|
42352
|
-
occurrenceId,
|
|
42353
|
-
propertyPath: "action",
|
|
42354
|
-
label: "\u70B9\u51FB\u540E",
|
|
42355
|
-
message,
|
|
42356
|
-
eventName: event.name,
|
|
42357
|
-
hasContext: isPlainRecord(event.context)
|
|
42358
|
-
}
|
|
42359
|
-
];
|
|
42994
|
+
acceptWorkerResult(queued, message) {
|
|
42995
|
+
if (!message.ok || typeof message.resultJson !== "string") {
|
|
42996
|
+
queued.reject(new DataTransformError(message.code ?? "CARD_TRANSFORM_FAILED", message.message ?? "\u6570\u636E\u8F6C\u6362\u6267\u884C\u5931\u8D25", queued.sourceHash));
|
|
42997
|
+
return;
|
|
42360
42998
|
}
|
|
42361
|
-
|
|
42362
|
-
|
|
42363
|
-
|
|
42364
|
-
|
|
42365
|
-
return [
|
|
42366
|
-
{
|
|
42367
|
-
kind: "function",
|
|
42368
|
-
targetId: createA2UICardAuthoringTargetId(occurrenceId, "action"),
|
|
42369
|
-
occurrenceId,
|
|
42370
|
-
propertyPath: "action",
|
|
42371
|
-
label: "\u524D\u7AEF\u51FD\u6570",
|
|
42372
|
-
ref: functionAction.ref
|
|
42373
|
-
}
|
|
42374
|
-
];
|
|
42375
|
-
}
|
|
42376
|
-
const client = isPlainRecord(action.client) ? action.client : void 0;
|
|
42377
|
-
if (client?.name === "ui.page.open" || client?.name === "ui.miniprogram.embed") {
|
|
42378
|
-
const context = isPlainRecord(client.context) ? client.context : void 0;
|
|
42379
|
-
const url2 = context?.url;
|
|
42380
|
-
return [
|
|
42381
|
-
{
|
|
42382
|
-
kind: client.name === "ui.miniprogram.embed" ? "miniprogram-embed" : "page-open",
|
|
42383
|
-
targetId: createA2UICardAuthoringTargetId(occurrenceId, "action"),
|
|
42384
|
-
occurrenceId,
|
|
42385
|
-
propertyPath: "action",
|
|
42386
|
-
label: client.name === "ui.miniprogram.embed" ? "\u534A\u5C4F\u6253\u5F00\u5C0F\u7A0B\u5E8F" : "\u6253\u5F00\u9875\u9762",
|
|
42387
|
-
...typeof url2 === "string" ? { url: url2 } : {},
|
|
42388
|
-
dynamic: isPlainRecord(url2) && typeof url2.path === "string"
|
|
42389
|
-
}
|
|
42390
|
-
];
|
|
42391
|
-
}
|
|
42392
|
-
return [agentOnlyAction(occurrenceId, "\u8BE5\u884C\u4E3A\u53EA\u80FD\u901A\u8FC7 Coding Agent \u4FEE\u6539")];
|
|
42393
|
-
}
|
|
42394
|
-
function fieldTargets(component, occurrenceId, fields, occurrences, projectedOnly) {
|
|
42395
|
-
const projection = componentAuthoringProjection(component);
|
|
42396
|
-
const ordered = [...fields].sort((left, right) => right.path.length - left.path.length);
|
|
42397
|
-
return occurrences.flatMap((occurrence) => {
|
|
42398
|
-
if (projectedOnly && !isProjectedFieldOccurrence(occurrence.propertyPath, projection)) {
|
|
42399
|
-
return [];
|
|
42999
|
+
const outputBytes = Buffer.byteLength(message.resultJson, "utf8");
|
|
43000
|
+
if (outputBytes > DATA_TRANSFORM_LIMITS.outputBytes) {
|
|
43001
|
+
queued.reject(new DataTransformError("CARD_TRANSFORM_OUTPUT_TOO_LARGE", "\u6570\u636E\u8F6C\u6362\u7ED3\u679C\u8D85\u8FC7\u5927\u5C0F\u9650\u5236", queued.sourceHash));
|
|
43002
|
+
return;
|
|
42400
43003
|
}
|
|
42401
|
-
|
|
42402
|
-
|
|
42403
|
-
|
|
42404
|
-
|
|
42405
|
-
const targetPath = suffix ? suffix.startsWith("/") ? suffix : `/${suffix}` : void 0;
|
|
42406
|
-
return [
|
|
42407
|
-
{
|
|
42408
|
-
kind: "field-occurrence",
|
|
42409
|
-
targetId: createA2UICardAuthoringTargetId(occurrenceId, occurrence.propertyPath),
|
|
42410
|
-
occurrenceId,
|
|
42411
|
-
propertyPath: occurrence.propertyPath,
|
|
42412
|
-
label: fieldOccurrenceLabel(targetPath, occurrence.propertyPath),
|
|
42413
|
-
fieldId: field.fieldId,
|
|
42414
|
-
dataPath: occurrence.rawPath,
|
|
42415
|
-
...occurrence.listRoot ? { listRoot: occurrence.listRoot } : {},
|
|
42416
|
-
valueType: occurrence.usage === "list" ? "array" : getJsonSchemaAtDataPointer(field.valueSchema, occurrence.canonicalPath.slice(field.path.length) || "/")?.type,
|
|
42417
|
-
...targetPath ? { targetPath } : {}
|
|
43004
|
+
try {
|
|
43005
|
+
const data = JSON.parse(message.resultJson);
|
|
43006
|
+
if (data !== null && (typeof data !== "object" || Array.isArray(data) || jsonDepth(data) > DATA_TRANSFORM_LIMITS.maxDepth)) {
|
|
43007
|
+
throw new DataTransformError("CARD_TRANSFORM_OUTPUT_INVALID", "\u6570\u636E\u8F6C\u6362\u7ED3\u679C\u5FC5\u987B\u662F JSON \u5BF9\u8C61\u6216 null", queued.sourceHash);
|
|
42418
43008
|
}
|
|
42419
|
-
|
|
42420
|
-
|
|
42421
|
-
|
|
42422
|
-
|
|
42423
|
-
|
|
42424
|
-
|
|
43009
|
+
queued.resolve({
|
|
43010
|
+
data,
|
|
43011
|
+
durationMs: message.durationMs ?? 0,
|
|
43012
|
+
inputBytes: queued.inputBytes,
|
|
43013
|
+
outputBytes,
|
|
43014
|
+
sourceHash: queued.sourceHash
|
|
43015
|
+
});
|
|
43016
|
+
} catch (error2) {
|
|
43017
|
+
queued.reject(error2 instanceof DataTransformError ? error2 : new DataTransformError("CARD_TRANSFORM_OUTPUT_INVALID", "\u6570\u636E\u8F6C\u6362\u7ED3\u679C\u4E0D\u662F\u6709\u6548 JSON", queued.sourceHash));
|
|
43018
|
+
}
|
|
42425
43019
|
}
|
|
42426
|
-
|
|
42427
|
-
|
|
42428
|
-
|
|
42429
|
-
|
|
42430
|
-
|
|
42431
|
-
|
|
42432
|
-
|
|
42433
|
-
|
|
42434
|
-
function decodeJsonPointerSegment(segment) {
|
|
42435
|
-
return segment.replace(/~1/gu, "/").replace(/~0/gu, "~");
|
|
42436
|
-
}
|
|
42437
|
-
function groupBindingOccurrences(occurrences) {
|
|
42438
|
-
const result = /* @__PURE__ */ new Map();
|
|
42439
|
-
for (const occurrence of occurrences) {
|
|
42440
|
-
if (!occurrence.surfaceId)
|
|
42441
|
-
continue;
|
|
42442
|
-
const key = componentKey(occurrence.surfaceId, occurrence.componentId);
|
|
42443
|
-
const entries = result.get(key) ?? [];
|
|
42444
|
-
entries.push(occurrence);
|
|
42445
|
-
result.set(key, entries);
|
|
43020
|
+
discardSlot(slot) {
|
|
43021
|
+
if (slot.disposed)
|
|
43022
|
+
return;
|
|
43023
|
+
slot.disposed = true;
|
|
43024
|
+
const index = this.slots.indexOf(slot);
|
|
43025
|
+
if (index >= 0)
|
|
43026
|
+
this.slots.splice(index, 1);
|
|
43027
|
+
void slot.worker.terminate();
|
|
42446
43028
|
}
|
|
42447
|
-
|
|
42448
|
-
|
|
42449
|
-
|
|
42450
|
-
|
|
42451
|
-
|
|
42452
|
-
|
|
42453
|
-
|
|
42454
|
-
|
|
42455
|
-
targetId: createA2UICardAuthoringTargetId(occurrenceId, "action"),
|
|
42456
|
-
occurrenceId,
|
|
42457
|
-
propertyPath: "action",
|
|
42458
|
-
label: "\u901A\u8FC7 Coding Agent \u4FEE\u6539\u884C\u4E3A",
|
|
42459
|
-
reason
|
|
42460
|
-
};
|
|
42461
|
-
}
|
|
42462
|
-
function componentLabel(component) {
|
|
42463
|
-
const candidate = component.label ?? component.title ?? component.text;
|
|
42464
|
-
return typeof candidate === "string" && candidate.trim() ? candidate : component.component;
|
|
42465
|
-
}
|
|
42466
|
-
function propertyLabel(propertyPath) {
|
|
42467
|
-
const key = propertyPath.split(".").at(-1) ?? propertyPath;
|
|
42468
|
-
const labels = {
|
|
42469
|
-
text: "\u6587\u6848",
|
|
42470
|
-
title: "\u6807\u9898",
|
|
42471
|
-
subtitle: "\u526F\u6807\u9898",
|
|
42472
|
-
label: "\u6807\u7B7E",
|
|
42473
|
-
description: "\u8BF4\u660E",
|
|
42474
|
-
value: "\u5185\u5BB9",
|
|
42475
|
-
alt: "\u56FE\u7247\u8BF4\u660E"
|
|
42476
|
-
};
|
|
42477
|
-
return labels[key] ?? key;
|
|
42478
|
-
}
|
|
42479
|
-
function appendPath(base, segment) {
|
|
42480
|
-
return base ? `${base}.${segment}` : segment;
|
|
42481
|
-
}
|
|
42482
|
-
function componentKey(surfaceId, componentId) {
|
|
42483
|
-
return `${surfaceId}\0${componentId}`;
|
|
42484
|
-
}
|
|
42485
|
-
function deduplicateTargets(targets) {
|
|
42486
|
-
return [
|
|
42487
|
-
...new Map(targets.map((target) => [target.targetId, target])).values()
|
|
42488
|
-
];
|
|
42489
|
-
}
|
|
42490
|
-
function deduplicateDiagnostics(diagnostics) {
|
|
42491
|
-
return [
|
|
42492
|
-
...new Map(diagnostics.map((entry) => [
|
|
42493
|
-
`${entry.code}\0${entry.path}\0${entry.fieldId ?? ""}`,
|
|
42494
|
-
entry
|
|
42495
|
-
])).values()
|
|
42496
|
-
];
|
|
42497
|
-
}
|
|
42498
|
-
function cloneBinding(binding) {
|
|
42499
|
-
return JSON.parse(JSON.stringify(binding));
|
|
43029
|
+
};
|
|
43030
|
+
function jsonDepth(value, depth = 0) {
|
|
43031
|
+
if (value === null || typeof value !== "object")
|
|
43032
|
+
return depth;
|
|
43033
|
+
if (depth > DATA_TRANSFORM_LIMITS.maxDepth)
|
|
43034
|
+
return depth;
|
|
43035
|
+
const children = Array.isArray(value) ? value : Object.values(value);
|
|
43036
|
+
return children.reduce((maximum, child) => Math.max(maximum, jsonDepth(child, depth + 1)), depth);
|
|
42500
43037
|
}
|
|
42501
43038
|
|
|
43039
|
+
// ../linkque-agent-runtime/dist/esm/core/types.js
|
|
43040
|
+
var EDebugLogScope;
|
|
43041
|
+
(function(EDebugLogScope2) {
|
|
43042
|
+
EDebugLogScope2["A2UI_ACTION"] = "A2UI_ACTION";
|
|
43043
|
+
EDebugLogScope2["CONFIG"] = "CONFIG";
|
|
43044
|
+
EDebugLogScope2["LLM"] = "LLM";
|
|
43045
|
+
EDebugLogScope2["PI_EVENT"] = "PI_EVENT";
|
|
43046
|
+
EDebugLogScope2["MCP"] = "MCP";
|
|
43047
|
+
EDebugLogScope2["SKILL"] = "SKILL";
|
|
43048
|
+
EDebugLogScope2["HTTP"] = "HTTP";
|
|
43049
|
+
EDebugLogScope2["HOOK"] = "HOOK";
|
|
43050
|
+
})(EDebugLogScope || (EDebugLogScope = {}));
|
|
43051
|
+
|
|
42502
43052
|
// ../linkque-agent-protocol/dist/esm/telemetry/telemetryEnums.js
|
|
42503
43053
|
var CONTENT_VALUE_MAX_LENGTH = 16 * 1024;
|
|
42504
43054
|
var ETelemetryAttribute;
|
|
@@ -43444,15 +43994,15 @@ var ParseStatus = class _ParseStatus {
|
|
|
43444
43994
|
this.value = "aborted";
|
|
43445
43995
|
}
|
|
43446
43996
|
static mergeArray(status2, results) {
|
|
43447
|
-
const
|
|
43997
|
+
const arrayValue2 = [];
|
|
43448
43998
|
for (const s4 of results) {
|
|
43449
43999
|
if (s4.status === "aborted")
|
|
43450
44000
|
return INVALID;
|
|
43451
44001
|
if (s4.status === "dirty")
|
|
43452
44002
|
status2.dirty();
|
|
43453
|
-
|
|
44003
|
+
arrayValue2.push(s4.value);
|
|
43454
44004
|
}
|
|
43455
|
-
return { status: status2.value, value:
|
|
44005
|
+
return { status: status2.value, value: arrayValue2 };
|
|
43456
44006
|
}
|
|
43457
44007
|
static async mergeObjectAsync(status2, pairs) {
|
|
43458
44008
|
const syncPairs = [];
|
|
@@ -45287,9 +45837,9 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
45287
45837
|
_getCached() {
|
|
45288
45838
|
if (this._cached !== null)
|
|
45289
45839
|
return this._cached;
|
|
45290
|
-
const
|
|
45291
|
-
const keys2 = util.objectKeys(
|
|
45292
|
-
this._cached = { shape, keys: keys2 };
|
|
45840
|
+
const shape2 = this._def.shape();
|
|
45841
|
+
const keys2 = util.objectKeys(shape2);
|
|
45842
|
+
this._cached = { shape: shape2, keys: keys2 };
|
|
45293
45843
|
return this._cached;
|
|
45294
45844
|
}
|
|
45295
45845
|
_parse(input) {
|
|
@@ -45304,7 +45854,7 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
45304
45854
|
return INVALID;
|
|
45305
45855
|
}
|
|
45306
45856
|
const { status: status2, ctx } = this._processInputParams(input);
|
|
45307
|
-
const { shape, keys: shapeKeys } = this._getCached();
|
|
45857
|
+
const { shape: shape2, keys: shapeKeys } = this._getCached();
|
|
45308
45858
|
const extraKeys = [];
|
|
45309
45859
|
if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
|
|
45310
45860
|
for (const key in ctx.data) {
|
|
@@ -45315,7 +45865,7 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
45315
45865
|
}
|
|
45316
45866
|
const pairs = [];
|
|
45317
45867
|
for (const key of shapeKeys) {
|
|
45318
|
-
const keyValidator =
|
|
45868
|
+
const keyValidator = shape2[key];
|
|
45319
45869
|
const value = ctx.data[key];
|
|
45320
45870
|
pairs.push({
|
|
45321
45871
|
key: { status: "valid", value: key },
|
|
@@ -45521,27 +46071,27 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
45521
46071
|
});
|
|
45522
46072
|
}
|
|
45523
46073
|
pick(mask) {
|
|
45524
|
-
const
|
|
46074
|
+
const shape2 = {};
|
|
45525
46075
|
for (const key of util.objectKeys(mask)) {
|
|
45526
46076
|
if (mask[key] && this.shape[key]) {
|
|
45527
|
-
|
|
46077
|
+
shape2[key] = this.shape[key];
|
|
45528
46078
|
}
|
|
45529
46079
|
}
|
|
45530
46080
|
return new _ZodObject({
|
|
45531
46081
|
...this._def,
|
|
45532
|
-
shape: () =>
|
|
46082
|
+
shape: () => shape2
|
|
45533
46083
|
});
|
|
45534
46084
|
}
|
|
45535
46085
|
omit(mask) {
|
|
45536
|
-
const
|
|
46086
|
+
const shape2 = {};
|
|
45537
46087
|
for (const key of util.objectKeys(this.shape)) {
|
|
45538
46088
|
if (!mask[key]) {
|
|
45539
|
-
|
|
46089
|
+
shape2[key] = this.shape[key];
|
|
45540
46090
|
}
|
|
45541
46091
|
}
|
|
45542
46092
|
return new _ZodObject({
|
|
45543
46093
|
...this._def,
|
|
45544
|
-
shape: () =>
|
|
46094
|
+
shape: () => shape2
|
|
45545
46095
|
});
|
|
45546
46096
|
}
|
|
45547
46097
|
/**
|
|
@@ -45588,27 +46138,27 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
45588
46138
|
return createZodEnum(util.objectKeys(this.shape));
|
|
45589
46139
|
}
|
|
45590
46140
|
};
|
|
45591
|
-
ZodObject.create = (
|
|
46141
|
+
ZodObject.create = (shape2, params) => {
|
|
45592
46142
|
return new ZodObject({
|
|
45593
|
-
shape: () =>
|
|
46143
|
+
shape: () => shape2,
|
|
45594
46144
|
unknownKeys: "strip",
|
|
45595
46145
|
catchall: ZodNever.create(),
|
|
45596
46146
|
typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
45597
46147
|
...processCreateParams(params)
|
|
45598
46148
|
});
|
|
45599
46149
|
};
|
|
45600
|
-
ZodObject.strictCreate = (
|
|
46150
|
+
ZodObject.strictCreate = (shape2, params) => {
|
|
45601
46151
|
return new ZodObject({
|
|
45602
|
-
shape: () =>
|
|
46152
|
+
shape: () => shape2,
|
|
45603
46153
|
unknownKeys: "strict",
|
|
45604
46154
|
catchall: ZodNever.create(),
|
|
45605
46155
|
typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
45606
46156
|
...processCreateParams(params)
|
|
45607
46157
|
});
|
|
45608
46158
|
};
|
|
45609
|
-
ZodObject.lazycreate = (
|
|
46159
|
+
ZodObject.lazycreate = (shape2, params) => {
|
|
45610
46160
|
return new ZodObject({
|
|
45611
|
-
shape,
|
|
46161
|
+
shape: shape2,
|
|
45612
46162
|
unknownKeys: "strip",
|
|
45613
46163
|
catchall: ZodNever.create(),
|
|
45614
46164
|
typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
@@ -47532,6 +48082,7 @@ var RUNTIME_CONFIG_DEFAULTS = Object.freeze({
|
|
|
47532
48082
|
LINKQUEGW_WEB_SEARCH_BASE_URL: LINKQUE_ENDPOINT_PROD,
|
|
47533
48083
|
LINKQUEGW_EVENT_BASE_URL: LINKQUE_ENDPOINT_PROD,
|
|
47534
48084
|
LINKQUEGW_MCP_SIGN_ENDPOINT: `${LINKQUE_ENDPOINT_PROD}/api/mcp/signature`,
|
|
48085
|
+
LINKQUEGW_A2A_SIGN_ENDPOINT: `${LINKQUE_ENDPOINT_PROD}/api/a2a/signature`,
|
|
47535
48086
|
LINKQUEGW_TOKEN_VERIFY_ENDPOINT: `${LINKQUE_ENDPOINT_PROD}/api/auth/verify`
|
|
47536
48087
|
});
|
|
47537
48088
|
var RuntimeConfigProvider = class {
|
|
@@ -47674,7 +48225,7 @@ __export(util_exports, {
|
|
|
47674
48225
|
getLengthableOrigin: () => getLengthableOrigin,
|
|
47675
48226
|
getParsedType: () => getParsedType2,
|
|
47676
48227
|
getSizableOrigin: () => getSizableOrigin,
|
|
47677
|
-
isObject: () =>
|
|
48228
|
+
isObject: () => isObject2,
|
|
47678
48229
|
isPlainObject: () => isPlainObject,
|
|
47679
48230
|
issue: () => issue3,
|
|
47680
48231
|
joinValues: () => joinValues,
|
|
@@ -47808,7 +48359,7 @@ function esc(str) {
|
|
|
47808
48359
|
}
|
|
47809
48360
|
var captureStackTrace = Error.captureStackTrace ? Error.captureStackTrace : (..._args) => {
|
|
47810
48361
|
};
|
|
47811
|
-
function
|
|
48362
|
+
function isObject2(data) {
|
|
47812
48363
|
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
47813
48364
|
}
|
|
47814
48365
|
var allowsEval = cached(() => {
|
|
@@ -47824,13 +48375,13 @@ var allowsEval = cached(() => {
|
|
|
47824
48375
|
}
|
|
47825
48376
|
});
|
|
47826
48377
|
function isPlainObject(o2) {
|
|
47827
|
-
if (
|
|
48378
|
+
if (isObject2(o2) === false)
|
|
47828
48379
|
return false;
|
|
47829
48380
|
const ctor = o2.constructor;
|
|
47830
48381
|
if (ctor === void 0)
|
|
47831
48382
|
return true;
|
|
47832
48383
|
const prot = ctor.prototype;
|
|
47833
|
-
if (
|
|
48384
|
+
if (isObject2(prot) === false)
|
|
47834
48385
|
return false;
|
|
47835
48386
|
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
|
|
47836
48387
|
return false;
|
|
@@ -47957,9 +48508,9 @@ function stringifyPrimitive(value) {
|
|
|
47957
48508
|
return `"${value}"`;
|
|
47958
48509
|
return `${value}`;
|
|
47959
48510
|
}
|
|
47960
|
-
function optionalKeys(
|
|
47961
|
-
return Object.keys(
|
|
47962
|
-
return
|
|
48511
|
+
function optionalKeys(shape2) {
|
|
48512
|
+
return Object.keys(shape2).filter((k2) => {
|
|
48513
|
+
return shape2[k2]._zod.optin === "optional" && shape2[k2]._zod.optout === "optional";
|
|
47963
48514
|
});
|
|
47964
48515
|
}
|
|
47965
48516
|
var NUMBER_FORMAT_RANGES = {
|
|
@@ -48007,14 +48558,14 @@ function omit(schema2, mask) {
|
|
|
48007
48558
|
checks: []
|
|
48008
48559
|
});
|
|
48009
48560
|
}
|
|
48010
|
-
function extend(schema2,
|
|
48011
|
-
if (!isPlainObject(
|
|
48561
|
+
function extend(schema2, shape2) {
|
|
48562
|
+
if (!isPlainObject(shape2)) {
|
|
48012
48563
|
throw new Error("Invalid input to extend: expected a plain object");
|
|
48013
48564
|
}
|
|
48014
48565
|
const def = {
|
|
48015
48566
|
...schema2._zod.def,
|
|
48016
48567
|
get shape() {
|
|
48017
|
-
const _shape = { ...schema2._zod.def.shape, ...
|
|
48568
|
+
const _shape = { ...schema2._zod.def.shape, ...shape2 };
|
|
48018
48569
|
assignProp(this, "shape", _shape);
|
|
48019
48570
|
return _shape;
|
|
48020
48571
|
},
|
|
@@ -48038,7 +48589,7 @@ function merge(a, b3) {
|
|
|
48038
48589
|
}
|
|
48039
48590
|
function partial(Class2, schema2, mask) {
|
|
48040
48591
|
const oldShape = schema2._zod.def.shape;
|
|
48041
|
-
const
|
|
48592
|
+
const shape2 = { ...oldShape };
|
|
48042
48593
|
if (mask) {
|
|
48043
48594
|
for (const key in mask) {
|
|
48044
48595
|
if (!(key in oldShape)) {
|
|
@@ -48046,14 +48597,14 @@ function partial(Class2, schema2, mask) {
|
|
|
48046
48597
|
}
|
|
48047
48598
|
if (!mask[key])
|
|
48048
48599
|
continue;
|
|
48049
|
-
|
|
48600
|
+
shape2[key] = Class2 ? new Class2({
|
|
48050
48601
|
type: "optional",
|
|
48051
48602
|
innerType: oldShape[key]
|
|
48052
48603
|
}) : oldShape[key];
|
|
48053
48604
|
}
|
|
48054
48605
|
} else {
|
|
48055
48606
|
for (const key in oldShape) {
|
|
48056
|
-
|
|
48607
|
+
shape2[key] = Class2 ? new Class2({
|
|
48057
48608
|
type: "optional",
|
|
48058
48609
|
innerType: oldShape[key]
|
|
48059
48610
|
}) : oldShape[key];
|
|
@@ -48061,28 +48612,28 @@ function partial(Class2, schema2, mask) {
|
|
|
48061
48612
|
}
|
|
48062
48613
|
return clone(schema2, {
|
|
48063
48614
|
...schema2._zod.def,
|
|
48064
|
-
shape,
|
|
48615
|
+
shape: shape2,
|
|
48065
48616
|
checks: []
|
|
48066
48617
|
});
|
|
48067
48618
|
}
|
|
48068
48619
|
function required(Class2, schema2, mask) {
|
|
48069
48620
|
const oldShape = schema2._zod.def.shape;
|
|
48070
|
-
const
|
|
48621
|
+
const shape2 = { ...oldShape };
|
|
48071
48622
|
if (mask) {
|
|
48072
48623
|
for (const key in mask) {
|
|
48073
|
-
if (!(key in
|
|
48624
|
+
if (!(key in shape2)) {
|
|
48074
48625
|
throw new Error(`Unrecognized key: "${key}"`);
|
|
48075
48626
|
}
|
|
48076
48627
|
if (!mask[key])
|
|
48077
48628
|
continue;
|
|
48078
|
-
|
|
48629
|
+
shape2[key] = new Class2({
|
|
48079
48630
|
type: "nonoptional",
|
|
48080
48631
|
innerType: oldShape[key]
|
|
48081
48632
|
});
|
|
48082
48633
|
}
|
|
48083
48634
|
} else {
|
|
48084
48635
|
for (const key in oldShape) {
|
|
48085
|
-
|
|
48636
|
+
shape2[key] = new Class2({
|
|
48086
48637
|
type: "nonoptional",
|
|
48087
48638
|
innerType: oldShape[key]
|
|
48088
48639
|
});
|
|
@@ -48090,7 +48641,7 @@ function required(Class2, schema2, mask) {
|
|
|
48090
48641
|
}
|
|
48091
48642
|
return clone(schema2, {
|
|
48092
48643
|
...schema2._zod.def,
|
|
48093
|
-
shape,
|
|
48644
|
+
shape: shape2,
|
|
48094
48645
|
// optional: [],
|
|
48095
48646
|
checks: []
|
|
48096
48647
|
});
|
|
@@ -49372,10 +49923,10 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
49372
49923
|
};
|
|
49373
49924
|
});
|
|
49374
49925
|
defineLazy(inst._zod, "propValues", () => {
|
|
49375
|
-
const
|
|
49926
|
+
const shape2 = def.shape;
|
|
49376
49927
|
const propValues = {};
|
|
49377
|
-
for (const key in
|
|
49378
|
-
const field =
|
|
49928
|
+
for (const key in shape2) {
|
|
49929
|
+
const field = shape2[key]._zod;
|
|
49379
49930
|
if (field.values) {
|
|
49380
49931
|
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
49381
49932
|
for (const v2 of field.values)
|
|
@@ -49384,7 +49935,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
49384
49935
|
}
|
|
49385
49936
|
return propValues;
|
|
49386
49937
|
});
|
|
49387
|
-
const generateFastpass = (
|
|
49938
|
+
const generateFastpass = (shape2) => {
|
|
49388
49939
|
const doc = new Doc(["shape", "payload", "ctx"]);
|
|
49389
49940
|
const normalized = _normalized.value;
|
|
49390
49941
|
const parseStr = (key) => {
|
|
@@ -49437,10 +49988,10 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
49437
49988
|
doc.write(`payload.value = newResult;`);
|
|
49438
49989
|
doc.write(`return payload;`);
|
|
49439
49990
|
const fn = doc.compile();
|
|
49440
|
-
return (payload, ctx) => fn(
|
|
49991
|
+
return (payload, ctx) => fn(shape2, payload, ctx);
|
|
49441
49992
|
};
|
|
49442
49993
|
let fastpass;
|
|
49443
|
-
const
|
|
49994
|
+
const isObject3 = isObject2;
|
|
49444
49995
|
const jit = !globalConfig.jitless;
|
|
49445
49996
|
const allowsEval2 = allowsEval;
|
|
49446
49997
|
const fastEnabled = jit && allowsEval2.value;
|
|
@@ -49449,7 +50000,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
49449
50000
|
inst._zod.parse = (payload, ctx) => {
|
|
49450
50001
|
value ?? (value = _normalized.value);
|
|
49451
50002
|
const input = payload.value;
|
|
49452
|
-
if (!
|
|
50003
|
+
if (!isObject3(input)) {
|
|
49453
50004
|
payload.issues.push({
|
|
49454
50005
|
expected: "object",
|
|
49455
50006
|
code: "invalid_type",
|
|
@@ -49465,9 +50016,9 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
49465
50016
|
payload = fastpass(payload, ctx);
|
|
49466
50017
|
} else {
|
|
49467
50018
|
payload.value = {};
|
|
49468
|
-
const
|
|
50019
|
+
const shape2 = value.shape;
|
|
49469
50020
|
for (const key of value.keys) {
|
|
49470
|
-
const el =
|
|
50021
|
+
const el = shape2[key];
|
|
49471
50022
|
const r2 = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
49472
50023
|
const isOptional = el._zod.optin === "optional" && el._zod.optout === "optional";
|
|
49473
50024
|
if (r2 instanceof Promise) {
|
|
@@ -49608,7 +50159,7 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
49608
50159
|
});
|
|
49609
50160
|
inst._zod.parse = (payload, ctx) => {
|
|
49610
50161
|
const input = payload.value;
|
|
49611
|
-
if (!
|
|
50162
|
+
if (!isObject2(input)) {
|
|
49612
50163
|
payload.issues.push({
|
|
49613
50164
|
code: "invalid_type",
|
|
49614
50165
|
expected: "object",
|
|
@@ -50822,9 +51373,9 @@ var ZodType2 = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
50822
51373
|
inst.refine = (check2, params) => inst.check(refine(check2, params));
|
|
50823
51374
|
inst.superRefine = (refinement) => inst.check(superRefine(refinement));
|
|
50824
51375
|
inst.overwrite = (fn) => inst.check(_overwrite(fn));
|
|
50825
|
-
inst.optional = () =>
|
|
51376
|
+
inst.optional = () => optional2(inst);
|
|
50826
51377
|
inst.nullable = () => nullable(inst);
|
|
50827
|
-
inst.nullish = () =>
|
|
51378
|
+
inst.nullish = () => optional2(nullable(inst));
|
|
50828
51379
|
inst.nonoptional = (params) => nonoptional(inst, params);
|
|
50829
51380
|
inst.array = () => array(inst);
|
|
50830
51381
|
inst.or = (arg) => union([inst, arg]);
|
|
@@ -51129,22 +51680,22 @@ var ZodObject2 = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
|
51129
51680
|
inst.partial = (...args) => util_exports.partial(ZodOptional2, inst, args[0]);
|
|
51130
51681
|
inst.required = (...args) => util_exports.required(ZodNonOptional, inst, args[0]);
|
|
51131
51682
|
});
|
|
51132
|
-
function object(
|
|
51683
|
+
function object(shape2, params) {
|
|
51133
51684
|
const def = {
|
|
51134
51685
|
type: "object",
|
|
51135
51686
|
get shape() {
|
|
51136
|
-
util_exports.assignProp(this, "shape", { ...
|
|
51687
|
+
util_exports.assignProp(this, "shape", { ...shape2 });
|
|
51137
51688
|
return this.shape;
|
|
51138
51689
|
},
|
|
51139
51690
|
...util_exports.normalizeParams(params)
|
|
51140
51691
|
};
|
|
51141
51692
|
return new ZodObject2(def);
|
|
51142
51693
|
}
|
|
51143
|
-
function looseObject(
|
|
51694
|
+
function looseObject(shape2, params) {
|
|
51144
51695
|
return new ZodObject2({
|
|
51145
51696
|
type: "object",
|
|
51146
51697
|
get shape() {
|
|
51147
|
-
util_exports.assignProp(this, "shape", { ...
|
|
51698
|
+
util_exports.assignProp(this, "shape", { ...shape2 });
|
|
51148
51699
|
return this.shape;
|
|
51149
51700
|
},
|
|
51150
51701
|
catchall: unknown(),
|
|
@@ -51305,7 +51856,7 @@ var ZodOptional2 = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
|
51305
51856
|
ZodType2.init(inst, def);
|
|
51306
51857
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
51307
51858
|
});
|
|
51308
|
-
function
|
|
51859
|
+
function optional2(innerType) {
|
|
51309
51860
|
return new ZodOptional2({
|
|
51310
51861
|
type: "optional",
|
|
51311
51862
|
innerType
|
|
@@ -51891,11 +52442,11 @@ var ProgressSchema = object({
|
|
|
51891
52442
|
/**
|
|
51892
52443
|
* Total number of items to process (or total progress required), if known.
|
|
51893
52444
|
*/
|
|
51894
|
-
total:
|
|
52445
|
+
total: optional2(number2()),
|
|
51895
52446
|
/**
|
|
51896
52447
|
* An optional message describing the current progress.
|
|
51897
52448
|
*/
|
|
51898
|
-
message:
|
|
52449
|
+
message: optional2(string3())
|
|
51899
52450
|
});
|
|
51900
52451
|
var ProgressNotificationParamsSchema = object({
|
|
51901
52452
|
...NotificationsParamsSchema.shape,
|
|
@@ -51943,11 +52494,11 @@ var TaskSchema = object({
|
|
|
51943
52494
|
* ISO 8601 timestamp when the task was last updated.
|
|
51944
52495
|
*/
|
|
51945
52496
|
lastUpdatedAt: string3(),
|
|
51946
|
-
pollInterval:
|
|
52497
|
+
pollInterval: optional2(number2()),
|
|
51947
52498
|
/**
|
|
51948
52499
|
* Optional diagnostic message for failed tasks or other status information.
|
|
51949
52500
|
*/
|
|
51950
|
-
statusMessage:
|
|
52501
|
+
statusMessage: optional2(string3())
|
|
51951
52502
|
});
|
|
51952
52503
|
var CreateTaskResultSchema = ResultSchema.extend({
|
|
51953
52504
|
task: TaskSchema
|
|
@@ -51992,7 +52543,7 @@ var ResourceContentsSchema = object({
|
|
|
51992
52543
|
/**
|
|
51993
52544
|
* The MIME type of this resource, if known.
|
|
51994
52545
|
*/
|
|
51995
|
-
mimeType:
|
|
52546
|
+
mimeType: optional2(string3()),
|
|
51996
52547
|
/**
|
|
51997
52548
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
51998
52549
|
* for notes on _meta usage.
|
|
@@ -52046,17 +52597,17 @@ var ResourceSchema = object({
|
|
|
52046
52597
|
*
|
|
52047
52598
|
* This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model.
|
|
52048
52599
|
*/
|
|
52049
|
-
description:
|
|
52600
|
+
description: optional2(string3()),
|
|
52050
52601
|
/**
|
|
52051
52602
|
* The MIME type of this resource, if known.
|
|
52052
52603
|
*/
|
|
52053
|
-
mimeType:
|
|
52604
|
+
mimeType: optional2(string3()),
|
|
52054
52605
|
/**
|
|
52055
52606
|
* The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
|
|
52056
52607
|
*
|
|
52057
52608
|
* This can be used by Hosts to display file sizes and estimate context window usage.
|
|
52058
52609
|
*/
|
|
52059
|
-
size:
|
|
52610
|
+
size: optional2(number2()),
|
|
52060
52611
|
/**
|
|
52061
52612
|
* Optional annotations for the client.
|
|
52062
52613
|
*/
|
|
@@ -52065,7 +52616,7 @@ var ResourceSchema = object({
|
|
|
52065
52616
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
52066
52617
|
* for notes on _meta usage.
|
|
52067
52618
|
*/
|
|
52068
|
-
_meta:
|
|
52619
|
+
_meta: optional2(looseObject({}))
|
|
52069
52620
|
});
|
|
52070
52621
|
var ResourceTemplateSchema = object({
|
|
52071
52622
|
...BaseMetadataSchema.shape,
|
|
@@ -52079,11 +52630,11 @@ var ResourceTemplateSchema = object({
|
|
|
52079
52630
|
*
|
|
52080
52631
|
* This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model.
|
|
52081
52632
|
*/
|
|
52082
|
-
description:
|
|
52633
|
+
description: optional2(string3()),
|
|
52083
52634
|
/**
|
|
52084
52635
|
* The MIME type for all resources that match this template. This should only be included if all resources matching this template have the same type.
|
|
52085
52636
|
*/
|
|
52086
|
-
mimeType:
|
|
52637
|
+
mimeType: optional2(string3()),
|
|
52087
52638
|
/**
|
|
52088
52639
|
* Optional annotations for the client.
|
|
52089
52640
|
*/
|
|
@@ -52092,7 +52643,7 @@ var ResourceTemplateSchema = object({
|
|
|
52092
52643
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
52093
52644
|
* for notes on _meta usage.
|
|
52094
52645
|
*/
|
|
52095
|
-
_meta:
|
|
52646
|
+
_meta: optional2(looseObject({}))
|
|
52096
52647
|
});
|
|
52097
52648
|
var ListResourcesRequestSchema = PaginatedRequestSchema.extend({
|
|
52098
52649
|
method: literal("resources/list")
|
|
@@ -52154,11 +52705,11 @@ var PromptArgumentSchema = object({
|
|
|
52154
52705
|
/**
|
|
52155
52706
|
* A human-readable description of the argument.
|
|
52156
52707
|
*/
|
|
52157
|
-
description:
|
|
52708
|
+
description: optional2(string3()),
|
|
52158
52709
|
/**
|
|
52159
52710
|
* Whether this argument must be provided.
|
|
52160
52711
|
*/
|
|
52161
|
-
required:
|
|
52712
|
+
required: optional2(boolean2())
|
|
52162
52713
|
});
|
|
52163
52714
|
var PromptSchema = object({
|
|
52164
52715
|
...BaseMetadataSchema.shape,
|
|
@@ -52166,16 +52717,16 @@ var PromptSchema = object({
|
|
|
52166
52717
|
/**
|
|
52167
52718
|
* An optional description of what this prompt provides
|
|
52168
52719
|
*/
|
|
52169
|
-
description:
|
|
52720
|
+
description: optional2(string3()),
|
|
52170
52721
|
/**
|
|
52171
52722
|
* A list of arguments to use for templating the prompt.
|
|
52172
52723
|
*/
|
|
52173
|
-
arguments:
|
|
52724
|
+
arguments: optional2(array(PromptArgumentSchema)),
|
|
52174
52725
|
/**
|
|
52175
52726
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
52176
52727
|
* for notes on _meta usage.
|
|
52177
52728
|
*/
|
|
52178
|
-
_meta:
|
|
52729
|
+
_meta: optional2(looseObject({}))
|
|
52179
52730
|
});
|
|
52180
52731
|
var ListPromptsRequestSchema = PaginatedRequestSchema.extend({
|
|
52181
52732
|
method: literal("prompts/list")
|
|
@@ -52633,7 +53184,7 @@ var CreateMessageResultSchema = ResultSchema.extend({
|
|
|
52633
53184
|
*
|
|
52634
53185
|
* This field is an open string to allow for provider-specific stop reasons.
|
|
52635
53186
|
*/
|
|
52636
|
-
stopReason:
|
|
53187
|
+
stopReason: optional2(_enum(["endTurn", "stopSequence", "maxTokens"]).or(string3())),
|
|
52637
53188
|
role: RoleSchema2,
|
|
52638
53189
|
/**
|
|
52639
53190
|
* Response content. Single content block (text, image, or audio).
|
|
@@ -52656,7 +53207,7 @@ var CreateMessageResultWithToolsSchema = ResultSchema.extend({
|
|
|
52656
53207
|
*
|
|
52657
53208
|
* This field is an open string to allow for provider-specific stop reasons.
|
|
52658
53209
|
*/
|
|
52659
|
-
stopReason:
|
|
53210
|
+
stopReason: optional2(_enum(["endTurn", "stopSequence", "maxTokens", "toolUse"]).or(string3())),
|
|
52660
53211
|
role: RoleSchema2,
|
|
52661
53212
|
/**
|
|
52662
53213
|
* Response content. May be a single block or array. May include ToolUseContent if stopReason is "toolUse".
|
|
@@ -52861,11 +53412,11 @@ var CompleteResultSchema = ResultSchema.extend({
|
|
|
52861
53412
|
/**
|
|
52862
53413
|
* The total number of completion options available. This can exceed the number of values actually sent in the response.
|
|
52863
53414
|
*/
|
|
52864
|
-
total:
|
|
53415
|
+
total: optional2(number2().int()),
|
|
52865
53416
|
/**
|
|
52866
53417
|
* Indicates whether there are additional completion options beyond those provided in the current response, even if the exact total is unknown.
|
|
52867
53418
|
*/
|
|
52868
|
-
hasMore:
|
|
53419
|
+
hasMore: optional2(boolean2())
|
|
52869
53420
|
})
|
|
52870
53421
|
});
|
|
52871
53422
|
var RootSchema = object({
|
|
@@ -53486,6 +54037,7 @@ var APPBASE_RUNTIME_CONFIG_DEFAULTS = Object.freeze({
|
|
|
53486
54037
|
LINKQUEGW_TELEMETRY_LOGS_ENDPOINT_PRE: `${LINKQUE_ENDPOINT_PRE}/api/telemetry/v1/logs`,
|
|
53487
54038
|
LINKQUEGW_TELEMETRY_TRACES_ENDPOINT_PRE: `${LINKQUE_ENDPOINT_PRE}/api/telemetry/v1/traces`,
|
|
53488
54039
|
LINKQUEGW_MCP_SIGN_ENDPOINT_PRE: `${LINKQUE_ENDPOINT_PRE}/api/mcp/signature`,
|
|
54040
|
+
LINKQUEGW_A2A_SIGN_ENDPOINT_PRE: `${LINKQUE_ENDPOINT_PRE}/api/a2a/signature`,
|
|
53489
54041
|
LINKQUE_OPEN_MCP_BASE_URL: "https://opengw.alipay.com",
|
|
53490
54042
|
LINKQUE_OPEN_MCP_BASE_URL_PRE: "https://opengw-pre.alipay.com",
|
|
53491
54043
|
EXTERNAL_ACTION_DATABASE_ID: "linkque",
|
|
@@ -54334,8 +54886,8 @@ var bundleWhileLocked = async (cwd, protocol, minify, pkgRoot, archive, archiveO
|
|
|
54334
54886
|
for (const def of FUNCTION_DEFS) {
|
|
54335
54887
|
const fnOutDir = import_path11.default.join(outDir, def.$id);
|
|
54336
54888
|
const result = await bundleAgentInstallation({
|
|
54337
|
-
// loadAgentProtocol
|
|
54338
|
-
// bundler 的 assertProtocolValid
|
|
54889
|
+
// loadAgentProtocol 已做文件基础检查及 REMOTE_AGENT 声明校验,返回 Record。
|
|
54890
|
+
// bundler 的 assertProtocolValid 补充最小必需字段检查,此处转换类型。
|
|
54339
54891
|
protocol,
|
|
54340
54892
|
entrypoint: def.handler,
|
|
54341
54893
|
outDir: fnOutDir,
|
|
@@ -54386,6 +54938,7 @@ var bundleWhileLocked = async (cwd, protocol, minify, pkgRoot, archive, archiveO
|
|
|
54386
54938
|
bundleDir: "",
|
|
54387
54939
|
configPath,
|
|
54388
54940
|
archivePath: import_path11.default.relative(cwd, archiveAbsPath),
|
|
54941
|
+
modelCardData: true,
|
|
54389
54942
|
functions: stats,
|
|
54390
54943
|
totalBytes,
|
|
54391
54944
|
durationMs
|
|
@@ -54949,6 +55502,7 @@ var SANDBOX_RUNTIME_CONFIG_DEFAULTS = Object.freeze({
|
|
|
54949
55502
|
LOG_LEVEL: "DEBUG",
|
|
54950
55503
|
LINKQUE_MCP_SIGN_ENDPOINT: RUNTIME_CONFIG_DEFAULTS.LINKQUEGW_MCP_SIGN_ENDPOINT,
|
|
54951
55504
|
LINKQUE_OPEN_MCP_BASE_URL: "https://opengw.alipay.com",
|
|
55505
|
+
LINKQUE_A2A_ENVIRONMENT: "PROD",
|
|
54952
55506
|
LINKQUEGW_TELEMETRY_LOGS_ENDPOINT: `${LINKQUE_ENDPOINT_PROD}/api/telemetry/v1/logs`,
|
|
54953
55507
|
LINKQUEGW_TELEMETRY_TRACES_ENDPOINT: `${LINKQUE_ENDPOINT_PROD}/api/telemetry/v1/traces`
|
|
54954
55508
|
});
|
|
@@ -54965,9 +55519,12 @@ function resolveTokenVerifyDefault(env) {
|
|
|
54965
55519
|
}
|
|
54966
55520
|
var SandboxRuntimeConfigProvider = class extends RuntimeConfigProvider {
|
|
54967
55521
|
constructor(env = process.env) {
|
|
55522
|
+
const a2aEnvironment = env.LINKQUE_A2A_ENVIRONMENT?.trim() || (env.LINKQUE_MCP_SIGN_ENDPOINT?.trim() === "https://linkquegw-pre.alipay.com/api/mcp/signature" || env.LINKQUE_OPEN_MCP_BASE_URL?.trim() === "https://opengw-pre.alipay.com" ? "PRE" : "PROD");
|
|
54968
55523
|
super(env, {
|
|
54969
55524
|
...SANDBOX_RUNTIME_CONFIG_DEFAULTS,
|
|
54970
|
-
LINKQUEGW_TOKEN_VERIFY_ENDPOINT: resolveTokenVerifyDefault(env)
|
|
55525
|
+
LINKQUEGW_TOKEN_VERIFY_ENDPOINT: resolveTokenVerifyDefault(env),
|
|
55526
|
+
LINKQUE_A2A_ENVIRONMENT: a2aEnvironment,
|
|
55527
|
+
LINKQUEGW_A2A_SIGN_ENDPOINT: a2aEnvironment === "PRE" ? "https://linkquegw-pre.alipay.com/api/a2a/signature" : RUNTIME_CONFIG_DEFAULTS.LINKQUEGW_A2A_SIGN_ENDPOINT
|
|
54971
55528
|
});
|
|
54972
55529
|
}
|
|
54973
55530
|
getSource(name) {
|
|
@@ -55073,6 +55630,14 @@ var loadAgentConfig = async (rawConfigPath, cwd) => {
|
|
|
55073
55630
|
"AGENTDEV_CONFIG_INVALID",
|
|
55074
55631
|
configPath
|
|
55075
55632
|
);
|
|
55633
|
+
try {
|
|
55634
|
+
assertRemoteAgentConfig(root);
|
|
55635
|
+
} catch (error2) {
|
|
55636
|
+
throw new LinkqueCliError(
|
|
55637
|
+
"AGENTDEV_CONFIG_INVALID",
|
|
55638
|
+
`agent config at ${configPath} is invalid: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
55639
|
+
);
|
|
55640
|
+
}
|
|
55076
55641
|
return {
|
|
55077
55642
|
agentId,
|
|
55078
55643
|
configPath,
|
|
@@ -60350,6 +60915,17 @@ async function validateCardBindingsFromDisk(cwd, draftId, fieldId) {
|
|
|
60350
60915
|
}
|
|
60351
60916
|
async function validateCardBindingsForBundle(cwd, draftId, bundle, fieldId) {
|
|
60352
60917
|
const directory = draftDirectory(cwd, draftId);
|
|
60918
|
+
if (bundle.manifest.schemaVersion === "4" && bundle.manifest.dataMode === "model") {
|
|
60919
|
+
return {
|
|
60920
|
+
bindingCount: 0,
|
|
60921
|
+
complete: true,
|
|
60922
|
+
draftChecksum: draftChecksum(bundle),
|
|
60923
|
+
draftId,
|
|
60924
|
+
draftStructureChecksum: createA2UICardDraftStructureChecksum(bundle),
|
|
60925
|
+
validatedFieldIds: [],
|
|
60926
|
+
valid: true
|
|
60927
|
+
};
|
|
60928
|
+
}
|
|
60353
60929
|
const [contextValue, configValue] = await Promise.all([
|
|
60354
60930
|
readOptionalJson(import_path24.default.join(directory, "binding-context.json")),
|
|
60355
60931
|
readAgentCards(import_path24.default.join(cwd, AGENT_CONFIG_PATH))
|
|
@@ -60927,10 +61503,10 @@ function validateBindingsWithoutContext(bundle, mountedMcpResourceIds, fieldId)
|
|
|
60927
61503
|
}
|
|
60928
61504
|
if (!selectedFields) {
|
|
60929
61505
|
issues.push(
|
|
60930
|
-
...validateA2UICardForPublish(bundle).map((
|
|
60931
|
-
code:
|
|
60932
|
-
message:
|
|
60933
|
-
path:
|
|
61506
|
+
...validateA2UICardForPublish(bundle).map((diagnostic2) => ({
|
|
61507
|
+
code: diagnostic2.code,
|
|
61508
|
+
message: diagnostic2.message,
|
|
61509
|
+
path: diagnostic2.path
|
|
60934
61510
|
}))
|
|
60935
61511
|
);
|
|
60936
61512
|
}
|
|
@@ -61009,8 +61585,8 @@ var REQUEST_FILE_PATTERN = /^request-[A-Za-z0-9_-]+\.json$/u;
|
|
|
61009
61585
|
var INSPECTOR_LOCK = ".linkque/runtime/inspector.lock";
|
|
61010
61586
|
var LOCK_TIMEOUT_MS6 = 1e4;
|
|
61011
61587
|
var LOCK_POLL_MS2 = 50;
|
|
61012
|
-
var
|
|
61013
|
-
var isInspectorCliError = (value) => value instanceof LinkqueCliError ||
|
|
61588
|
+
var isRecord2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
61589
|
+
var isInspectorCliError = (value) => value instanceof LinkqueCliError || isRecord2(value) && typeof value.code === "string" && value.code.startsWith("INSPECTOR_");
|
|
61014
61590
|
var importInspectorModule = async (resolvedPath) => {
|
|
61015
61591
|
const imported = await import((0, import_url.pathToFileURL)(resolvedPath).href);
|
|
61016
61592
|
if (typeof imported.createInspectorWorkspaceEngine !== "function") {
|
|
@@ -61097,7 +61673,7 @@ var readInspectorRequest = async (requestFile) => {
|
|
|
61097
61673
|
);
|
|
61098
61674
|
}
|
|
61099
61675
|
const value = JSON.parse(content);
|
|
61100
|
-
if (!
|
|
61676
|
+
if (!isRecord2(value)) throw new Error("\u8BF7\u6C42\u6839\u8282\u70B9\u4E0D\u662F\u5BF9\u8C61");
|
|
61101
61677
|
return value;
|
|
61102
61678
|
} catch (cause) {
|
|
61103
61679
|
if (isInspectorCliError(cause)) throw cause;
|
|
@@ -61134,12 +61710,12 @@ var inspectorErrorCode = (cause) => {
|
|
|
61134
61710
|
};
|
|
61135
61711
|
var normalizeInspectorError = (cause) => {
|
|
61136
61712
|
if (isInspectorCliError(cause)) return cause;
|
|
61137
|
-
const error2 =
|
|
61713
|
+
const error2 = isRecord2(cause) ? cause : {};
|
|
61138
61714
|
const message = typeof error2.message === "string" ? error2.message : "Inspector \u5DE5\u4F5C\u533A\u64CD\u4F5C\u5931\u8D25";
|
|
61139
61715
|
return new LinkqueCliError(inspectorErrorCode(error2), message, { cause });
|
|
61140
61716
|
};
|
|
61141
61717
|
var normalizeApplyResult = (value) => {
|
|
61142
|
-
if (!
|
|
61718
|
+
if (!isRecord2(value) || typeof value.revision !== "string" || !/^[a-f0-9]{24}$/u.test(value.revision) || !Array.isArray(value.changedFiles) || !value.changedFiles.every((item) => typeof item === "string") || !Array.isArray(value.warnings) || !value.warnings.every((item) => typeof item === "string") || value.previewUrl !== void 0 && (typeof value.previewUrl !== "string" || value.previewUrl.trim() === "")) {
|
|
61143
61719
|
throw new LinkqueCliError(
|
|
61144
61720
|
"INSPECTOR_INTERNAL_ERROR",
|
|
61145
61721
|
"Inspector \u5DE5\u4F5C\u533A\u8FD4\u56DE\u4E86\u65E0\u6548\u7ED3\u679C"
|
|
@@ -61579,7 +62155,7 @@ var MAX_ARCHIVE_SIZE = 512 * 1024 * 1024;
|
|
|
61579
62155
|
var failManifest = (message) => {
|
|
61580
62156
|
throw new LinkqueCliError("PLATFORM_SDK_MANIFEST_INVALID", message);
|
|
61581
62157
|
};
|
|
61582
|
-
var
|
|
62158
|
+
var isRecord3 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
61583
62159
|
var isSha256 = (value) => typeof value === "string" && /^sha256:[a-f0-9]{64}$/u.test(value);
|
|
61584
62160
|
var isSafePlatformPath = (value) => {
|
|
61585
62161
|
if (value.includes("\\") || value.includes("\0") || import_path27.default.posix.isAbsolute(value)) {
|
|
@@ -61595,15 +62171,15 @@ var parseManifest = (content) => {
|
|
|
61595
62171
|
} catch {
|
|
61596
62172
|
return failManifest("platform SDK manifest must be valid JSON");
|
|
61597
62173
|
}
|
|
61598
|
-
if (!
|
|
62174
|
+
if (!isRecord3(raw) || raw.schemaVersion !== 1) {
|
|
61599
62175
|
return failManifest("platform SDK manifest schemaVersion must be 1");
|
|
61600
62176
|
}
|
|
61601
|
-
if (typeof raw.bundleVersion !== "string" || !raw.bundleVersion.trim() || typeof raw.compatibleTemplateRange !== "string" || !
|
|
62177
|
+
if (typeof raw.bundleVersion !== "string" || !raw.bundleVersion.trim() || typeof raw.compatibleTemplateRange !== "string" || !isRecord3(raw.archive) || !isSha256(raw.archive.sha256) || !Number.isSafeInteger(raw.archive.size) || Number(raw.archive.size) <= 0 || Number(raw.archive.size) > MAX_ARCHIVE_SIZE || typeof raw.archive.ossKey !== "string" || !isRecord3(raw.packages) || Object.keys(raw.packages).length === 0) {
|
|
61602
62178
|
return failManifest("platform SDK manifest is incomplete");
|
|
61603
62179
|
}
|
|
61604
62180
|
const packages = {};
|
|
61605
62181
|
for (const [packageName, value] of Object.entries(raw.packages)) {
|
|
61606
|
-
if (!packageName.startsWith("@alipay/") || !
|
|
62182
|
+
if (!packageName.startsWith("@alipay/") || !isRecord3(value) || typeof value.version !== "string" || typeof value.file !== "string" || !isSafePlatformPath(value.file) || !isSha256(value.sha256)) {
|
|
61607
62183
|
return failManifest(`invalid platform SDK package entry: ${packageName}`);
|
|
61608
62184
|
}
|
|
61609
62185
|
packages[packageName] = {
|
|
@@ -61663,7 +62239,7 @@ var validateVersionMarker = async (cwd, manifest) => {
|
|
|
61663
62239
|
{ cause: error2 instanceof Error ? error2 : void 0 }
|
|
61664
62240
|
);
|
|
61665
62241
|
}
|
|
61666
|
-
if (!
|
|
62242
|
+
if (!isRecord3(value) || value.schemaVersion !== 1 || value.bundleVersion !== manifest.bundleVersion) {
|
|
61667
62243
|
throw new LinkqueCliError(
|
|
61668
62244
|
"PLATFORM_SDK_ARCHIVE_INVALID",
|
|
61669
62245
|
"platform SDK archive version marker does not match the manifest"
|
|
@@ -61688,11 +62264,11 @@ var rewritePackageJson = async (cwd, manifest) => {
|
|
|
61688
62264
|
"peerDependencies",
|
|
61689
62265
|
"optionalDependencies"
|
|
61690
62266
|
];
|
|
61691
|
-
const dependencies =
|
|
62267
|
+
const dependencies = isRecord3(packageJson.dependencies) ? packageJson.dependencies : {};
|
|
61692
62268
|
packageJson.dependencies = dependencies;
|
|
61693
62269
|
for (const blockName of dependencyBlocks) {
|
|
61694
62270
|
const block = packageJson[blockName];
|
|
61695
|
-
if (!
|
|
62271
|
+
if (!isRecord3(block)) continue;
|
|
61696
62272
|
for (const [packageName, specifier] of Object.entries(block)) {
|
|
61697
62273
|
if (packageName.startsWith("@alipay/") && typeof specifier === "string" && specifier.startsWith(`file:${PLATFORM_SDK_DIR}/`) && !Object.hasOwn(manifest.packages, packageName)) {
|
|
61698
62274
|
delete block[packageName];
|
|
@@ -61703,7 +62279,7 @@ var rewritePackageJson = async (cwd, manifest) => {
|
|
|
61703
62279
|
let target = dependencies;
|
|
61704
62280
|
for (const blockName of dependencyBlocks) {
|
|
61705
62281
|
const block = packageJson[blockName];
|
|
61706
|
-
if (
|
|
62282
|
+
if (isRecord3(block) && Object.hasOwn(block, packageName)) {
|
|
61707
62283
|
target = block;
|
|
61708
62284
|
break;
|
|
61709
62285
|
}
|