linkque-cli-v2 1.0.2-beta.2 → 1.0.2-beta.4
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/package.json +1 -1
- package/worker.js +0 -32
package/package.json
CHANGED
package/worker.js
CHANGED
|
@@ -12027,21 +12027,6 @@ function getJsonSchemaIssues(value, path6 = "schema") {
|
|
|
12027
12027
|
function isObjectJsonSchema(value) {
|
|
12028
12028
|
return isPlainRecord(value) && value.type === "object" && getJsonSchemaIssues(value).length === 0;
|
|
12029
12029
|
}
|
|
12030
|
-
function validateJsonSchemaValue(schema, value, path6 = "$") {
|
|
12031
|
-
let validate;
|
|
12032
|
-
try {
|
|
12033
|
-
validate = ajv.compile(schema);
|
|
12034
|
-
} catch (error40) {
|
|
12035
|
-
return [
|
|
12036
|
-
issue(path6, "INVALID_JSON_SCHEMA", error40 instanceof Error ? error40.message : "schema is invalid")
|
|
12037
|
-
];
|
|
12038
|
-
}
|
|
12039
|
-
return validate(value) ? [] : (validate.errors ?? []).map(errorToIssue.bind(null, path6));
|
|
12040
|
-
}
|
|
12041
|
-
function errorToIssue(root, error40) {
|
|
12042
|
-
const suffix = error40.instancePath.split("/").filter(Boolean).map((segment) => segment.replace(/~1/gu, "/").replace(/~0/gu, "~")).map((segment) => `[${JSON.stringify(segment)}]`).join("");
|
|
12043
|
-
return issue(`${root}${suffix}`, "JSON_SCHEMA_VALUE_INVALID", error40.message ?? "value does not match schema");
|
|
12044
|
-
}
|
|
12045
12030
|
var import_ajv, AjvConstructor, ajv;
|
|
12046
12031
|
var init_schema = __esm({
|
|
12047
12032
|
"../linkque-agent-data-binding-contract/dist/esm/schema.js"() {
|
|
@@ -15836,11 +15821,6 @@ async function executeHomeData(input) {
|
|
|
15836
15821
|
if (!handle) {
|
|
15837
15822
|
return failure("TOOL_NOT_ALLOWED", "MCP \u5DE5\u5177\u4E0D\u5B58\u5728\u6216\u4E0D\u53EF\u7528", false);
|
|
15838
15823
|
}
|
|
15839
|
-
const inputSchema = cloneJsonObject(handle.inputSchema);
|
|
15840
|
-
const outputSchema = cloneJsonObject(handle.outputSchema);
|
|
15841
|
-
if (!inputSchema || !outputSchema) {
|
|
15842
|
-
return failure("INVALID_OUTPUT", "\u9996\u9875\u5361\u7247\u8981\u6C42 MCP \u5DE5\u5177\u58F0\u660E\u5B8C\u6574\u7684\u8F93\u5165\u548C\u8F93\u51FA Schema", false);
|
|
15843
|
-
}
|
|
15844
15824
|
const toolInput = {};
|
|
15845
15825
|
for (const mapping of request.binding.input) {
|
|
15846
15826
|
let value;
|
|
@@ -15859,10 +15839,6 @@ async function executeHomeData(input) {
|
|
|
15859
15839
|
return failure("INVALID_INPUT", `\u65E0\u6CD5\u751F\u6210 MCP \u5165\u53C2 ${mapping.target}`, false);
|
|
15860
15840
|
}
|
|
15861
15841
|
}
|
|
15862
|
-
const inputIssues = validateJsonSchemaValue(inputSchema, toolInput);
|
|
15863
|
-
if (inputIssues.length > 0) {
|
|
15864
|
-
return failure("INVALID_INPUT", inputIssues[0].message, false);
|
|
15865
|
-
}
|
|
15866
15842
|
let result;
|
|
15867
15843
|
try {
|
|
15868
15844
|
result = await handle.execute(toolInput, input.signal);
|
|
@@ -15870,10 +15846,6 @@ async function executeHomeData(input) {
|
|
|
15870
15846
|
return failure("EXECUTION_FAILED", error40 instanceof Error ? error40.message : "MCP \u5DE5\u5177\u8C03\u7528\u5931\u8D25", true);
|
|
15871
15847
|
}
|
|
15872
15848
|
const structured = readStructuredContent2(result);
|
|
15873
|
-
const outputIssues = validateJsonSchemaValue(outputSchema, structured);
|
|
15874
|
-
if (outputIssues.length > 0) {
|
|
15875
|
-
return failure("INVALID_OUTPUT", outputIssues[0].message, false);
|
|
15876
|
-
}
|
|
15877
15849
|
let cardData = structured;
|
|
15878
15850
|
if (request.binding.transform) {
|
|
15879
15851
|
try {
|
|
@@ -15886,10 +15858,6 @@ async function executeHomeData(input) {
|
|
|
15886
15858
|
if (!cardDataObject) {
|
|
15887
15859
|
return failure("INVALID_CARD_DATA", "\u9996\u9875\u5361\u7247\u6570\u636E\u5FC5\u987B\u662F JSON object", false);
|
|
15888
15860
|
}
|
|
15889
|
-
const cardIssues = validateJsonSchemaValue(request.dataSchema, cardDataObject);
|
|
15890
|
-
if (cardIssues.length > 0) {
|
|
15891
|
-
return failure("INVALID_CARD_DATA", cardIssues[0].message, false);
|
|
15892
|
-
}
|
|
15893
15861
|
return { ok: true, data: cardDataObject };
|
|
15894
15862
|
} finally {
|
|
15895
15863
|
await registry2.closeAll();
|