@finchtech/cli 0.3.1 → 0.3.3
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/README.md +46 -1
- package/dist/finch.js +1226 -739
- package/package.json +4 -4
package/dist/finch.js
CHANGED
|
@@ -1075,52 +1075,52 @@ var require_util = __commonJS({
|
|
|
1075
1075
|
return hash5;
|
|
1076
1076
|
}
|
|
1077
1077
|
exports.toHash = toHash;
|
|
1078
|
-
function alwaysValidSchema(it,
|
|
1079
|
-
if (typeof
|
|
1080
|
-
return
|
|
1081
|
-
if (Object.keys(
|
|
1078
|
+
function alwaysValidSchema(it, schema4) {
|
|
1079
|
+
if (typeof schema4 == "boolean")
|
|
1080
|
+
return schema4;
|
|
1081
|
+
if (Object.keys(schema4).length === 0)
|
|
1082
1082
|
return true;
|
|
1083
|
-
checkUnknownRules(it,
|
|
1084
|
-
return !schemaHasRules(
|
|
1083
|
+
checkUnknownRules(it, schema4);
|
|
1084
|
+
return !schemaHasRules(schema4, it.self.RULES.all);
|
|
1085
1085
|
}
|
|
1086
1086
|
exports.alwaysValidSchema = alwaysValidSchema;
|
|
1087
|
-
function checkUnknownRules(it,
|
|
1087
|
+
function checkUnknownRules(it, schema4 = it.schema) {
|
|
1088
1088
|
const { opts, self } = it;
|
|
1089
1089
|
if (!opts.strictSchema)
|
|
1090
1090
|
return;
|
|
1091
|
-
if (typeof
|
|
1091
|
+
if (typeof schema4 === "boolean")
|
|
1092
1092
|
return;
|
|
1093
1093
|
const rules = self.RULES.keywords;
|
|
1094
|
-
for (const key in
|
|
1094
|
+
for (const key in schema4) {
|
|
1095
1095
|
if (!rules[key])
|
|
1096
1096
|
checkStrictMode(it, `unknown keyword: "${key}"`);
|
|
1097
1097
|
}
|
|
1098
1098
|
}
|
|
1099
1099
|
exports.checkUnknownRules = checkUnknownRules;
|
|
1100
|
-
function schemaHasRules(
|
|
1101
|
-
if (typeof
|
|
1102
|
-
return !
|
|
1103
|
-
for (const key in
|
|
1100
|
+
function schemaHasRules(schema4, rules) {
|
|
1101
|
+
if (typeof schema4 == "boolean")
|
|
1102
|
+
return !schema4;
|
|
1103
|
+
for (const key in schema4)
|
|
1104
1104
|
if (rules[key])
|
|
1105
1105
|
return true;
|
|
1106
1106
|
return false;
|
|
1107
1107
|
}
|
|
1108
1108
|
exports.schemaHasRules = schemaHasRules;
|
|
1109
|
-
function schemaHasRulesButRef(
|
|
1110
|
-
if (typeof
|
|
1111
|
-
return !
|
|
1112
|
-
for (const key in
|
|
1109
|
+
function schemaHasRulesButRef(schema4, RULES) {
|
|
1110
|
+
if (typeof schema4 == "boolean")
|
|
1111
|
+
return !schema4;
|
|
1112
|
+
for (const key in schema4)
|
|
1113
1113
|
if (key !== "$ref" && RULES.all[key])
|
|
1114
1114
|
return true;
|
|
1115
1115
|
return false;
|
|
1116
1116
|
}
|
|
1117
1117
|
exports.schemaHasRulesButRef = schemaHasRulesButRef;
|
|
1118
|
-
function schemaRefOrVal({ topSchemaRef, schemaPath },
|
|
1118
|
+
function schemaRefOrVal({ topSchemaRef, schemaPath }, schema4, keyword, $data) {
|
|
1119
1119
|
if (!$data) {
|
|
1120
|
-
if (typeof
|
|
1121
|
-
return
|
|
1122
|
-
if (typeof
|
|
1123
|
-
return (0, codegen_1._)`${
|
|
1120
|
+
if (typeof schema4 == "number" || typeof schema4 == "boolean")
|
|
1121
|
+
return schema4;
|
|
1122
|
+
if (typeof schema4 == "string")
|
|
1123
|
+
return (0, codegen_1._)`${schema4}`;
|
|
1124
1124
|
}
|
|
1125
1125
|
return (0, codegen_1._)`${topSchemaRef}${schemaPath}${(0, codegen_1.getProperty)(keyword)}`;
|
|
1126
1126
|
}
|
|
@@ -1401,10 +1401,10 @@ var require_boolSchema = __commonJS({
|
|
|
1401
1401
|
message: "boolean schema is false"
|
|
1402
1402
|
};
|
|
1403
1403
|
function topBoolOrEmptySchema(it) {
|
|
1404
|
-
const { gen: gen2, schema:
|
|
1405
|
-
if (
|
|
1404
|
+
const { gen: gen2, schema: schema4, validateName } = it;
|
|
1405
|
+
if (schema4 === false) {
|
|
1406
1406
|
falseSchemaError(it, false);
|
|
1407
|
-
} else if (typeof
|
|
1407
|
+
} else if (typeof schema4 == "object" && schema4.$async === true) {
|
|
1408
1408
|
gen2.return(names_1.default.data);
|
|
1409
1409
|
} else {
|
|
1410
1410
|
gen2.assign((0, codegen_1._)`${validateName}.errors`, null);
|
|
@@ -1413,8 +1413,8 @@ var require_boolSchema = __commonJS({
|
|
|
1413
1413
|
}
|
|
1414
1414
|
exports.topBoolOrEmptySchema = topBoolOrEmptySchema;
|
|
1415
1415
|
function boolOrEmptySchema(it, valid) {
|
|
1416
|
-
const { gen: gen2, schema:
|
|
1417
|
-
if (
|
|
1416
|
+
const { gen: gen2, schema: schema4 } = it;
|
|
1417
|
+
if (schema4 === false) {
|
|
1418
1418
|
gen2.var(valid, false);
|
|
1419
1419
|
falseSchemaError(it);
|
|
1420
1420
|
} else {
|
|
@@ -1476,18 +1476,18 @@ var require_applicability = __commonJS({
|
|
|
1476
1476
|
"use strict";
|
|
1477
1477
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1478
1478
|
exports.shouldUseRule = exports.shouldUseGroup = exports.schemaHasRulesForType = void 0;
|
|
1479
|
-
function schemaHasRulesForType({ schema:
|
|
1479
|
+
function schemaHasRulesForType({ schema: schema4, self }, type) {
|
|
1480
1480
|
const group = self.RULES.types[type];
|
|
1481
|
-
return group && group !== true && shouldUseGroup(
|
|
1481
|
+
return group && group !== true && shouldUseGroup(schema4, group);
|
|
1482
1482
|
}
|
|
1483
1483
|
exports.schemaHasRulesForType = schemaHasRulesForType;
|
|
1484
|
-
function shouldUseGroup(
|
|
1485
|
-
return group.rules.some((rule) => shouldUseRule(
|
|
1484
|
+
function shouldUseGroup(schema4, group) {
|
|
1485
|
+
return group.rules.some((rule) => shouldUseRule(schema4, rule));
|
|
1486
1486
|
}
|
|
1487
1487
|
exports.shouldUseGroup = shouldUseGroup;
|
|
1488
|
-
function shouldUseRule(
|
|
1488
|
+
function shouldUseRule(schema4, rule) {
|
|
1489
1489
|
var _a4;
|
|
1490
|
-
return
|
|
1490
|
+
return schema4[rule.keyword] !== void 0 || ((_a4 = rule.definition.implements) === null || _a4 === void 0 ? void 0 : _a4.some((kwd) => schema4[kwd] !== void 0));
|
|
1491
1491
|
}
|
|
1492
1492
|
exports.shouldUseRule = shouldUseRule;
|
|
1493
1493
|
}
|
|
@@ -1509,17 +1509,17 @@ var require_dataType = __commonJS({
|
|
|
1509
1509
|
DataType2[DataType2["Correct"] = 0] = "Correct";
|
|
1510
1510
|
DataType2[DataType2["Wrong"] = 1] = "Wrong";
|
|
1511
1511
|
})(DataType || (exports.DataType = DataType = {}));
|
|
1512
|
-
function getSchemaTypes(
|
|
1513
|
-
const types = getJSONTypes(
|
|
1512
|
+
function getSchemaTypes(schema4) {
|
|
1513
|
+
const types = getJSONTypes(schema4.type);
|
|
1514
1514
|
const hasNull = types.includes("null");
|
|
1515
1515
|
if (hasNull) {
|
|
1516
|
-
if (
|
|
1516
|
+
if (schema4.nullable === false)
|
|
1517
1517
|
throw new Error("type: null contradicts nullable: false");
|
|
1518
1518
|
} else {
|
|
1519
|
-
if (!types.length &&
|
|
1519
|
+
if (!types.length && schema4.nullable !== void 0) {
|
|
1520
1520
|
throw new Error('"nullable" cannot be used without "type"');
|
|
1521
1521
|
}
|
|
1522
|
-
if (
|
|
1522
|
+
if (schema4.nullable === true)
|
|
1523
1523
|
types.push("null");
|
|
1524
1524
|
}
|
|
1525
1525
|
return types;
|
|
@@ -1651,8 +1651,8 @@ var require_dataType = __commonJS({
|
|
|
1651
1651
|
}
|
|
1652
1652
|
exports.checkDataTypes = checkDataTypes;
|
|
1653
1653
|
var typeError = {
|
|
1654
|
-
message: ({ schema:
|
|
1655
|
-
params: ({ schema:
|
|
1654
|
+
message: ({ schema: schema4 }) => `must be ${schema4}`,
|
|
1655
|
+
params: ({ schema: schema4, schemaValue }) => typeof schema4 == "string" ? (0, codegen_1._)`{type: ${schema4}}` : (0, codegen_1._)`{type: ${schemaValue}}`
|
|
1656
1656
|
};
|
|
1657
1657
|
function reportTypeError(it) {
|
|
1658
1658
|
const cxt = getTypeErrorContext(it);
|
|
@@ -1660,16 +1660,16 @@ var require_dataType = __commonJS({
|
|
|
1660
1660
|
}
|
|
1661
1661
|
exports.reportTypeError = reportTypeError;
|
|
1662
1662
|
function getTypeErrorContext(it) {
|
|
1663
|
-
const { gen: gen2, data, schema:
|
|
1664
|
-
const schemaCode = (0, util_1.schemaRefOrVal)(it,
|
|
1663
|
+
const { gen: gen2, data, schema: schema4 } = it;
|
|
1664
|
+
const schemaCode = (0, util_1.schemaRefOrVal)(it, schema4, "type");
|
|
1665
1665
|
return {
|
|
1666
1666
|
gen: gen2,
|
|
1667
1667
|
keyword: "type",
|
|
1668
1668
|
data,
|
|
1669
|
-
schema:
|
|
1669
|
+
schema: schema4.type,
|
|
1670
1670
|
schemaCode,
|
|
1671
1671
|
schemaValue: schemaCode,
|
|
1672
|
-
parentSchema:
|
|
1672
|
+
parentSchema: schema4,
|
|
1673
1673
|
params: {},
|
|
1674
1674
|
it
|
|
1675
1675
|
};
|
|
@@ -1822,15 +1822,15 @@ var require_code2 = __commonJS({
|
|
|
1822
1822
|
}
|
|
1823
1823
|
exports.validateArray = validateArray;
|
|
1824
1824
|
function validateUnion(cxt) {
|
|
1825
|
-
const { gen: gen2, schema:
|
|
1826
|
-
if (!Array.isArray(
|
|
1825
|
+
const { gen: gen2, schema: schema4, keyword, it } = cxt;
|
|
1826
|
+
if (!Array.isArray(schema4))
|
|
1827
1827
|
throw new Error("ajv implementation error");
|
|
1828
|
-
const alwaysValid =
|
|
1828
|
+
const alwaysValid = schema4.some((sch) => (0, util_1.alwaysValidSchema)(it, sch));
|
|
1829
1829
|
if (alwaysValid && !it.opts.unevaluated)
|
|
1830
1830
|
return;
|
|
1831
1831
|
const valid = gen2.let("valid", false);
|
|
1832
1832
|
const schValid = gen2.name("_valid");
|
|
1833
|
-
gen2.block(() =>
|
|
1833
|
+
gen2.block(() => schema4.forEach((_sch, i2) => {
|
|
1834
1834
|
const schCxt = cxt.subschema({
|
|
1835
1835
|
keyword,
|
|
1836
1836
|
schemaProp: i2,
|
|
@@ -1858,8 +1858,8 @@ var require_keyword = __commonJS({
|
|
|
1858
1858
|
var code_1 = require_code2();
|
|
1859
1859
|
var errors_1 = require_errors();
|
|
1860
1860
|
function macroKeywordCode(cxt, def) {
|
|
1861
|
-
const { gen: gen2, keyword, schema:
|
|
1862
|
-
const macroSchema = def.macro.call(it.self,
|
|
1861
|
+
const { gen: gen2, keyword, schema: schema4, parentSchema, it } = cxt;
|
|
1862
|
+
const macroSchema = def.macro.call(it.self, schema4, parentSchema, it);
|
|
1863
1863
|
const schemaRef = useKeyword(gen2, keyword, macroSchema);
|
|
1864
1864
|
if (it.opts.validateSchema !== false)
|
|
1865
1865
|
it.self.validateSchema(macroSchema, true);
|
|
@@ -1876,9 +1876,9 @@ var require_keyword = __commonJS({
|
|
|
1876
1876
|
exports.macroKeywordCode = macroKeywordCode;
|
|
1877
1877
|
function funcKeywordCode(cxt, def) {
|
|
1878
1878
|
var _a4;
|
|
1879
|
-
const { gen: gen2, keyword, schema:
|
|
1879
|
+
const { gen: gen2, keyword, schema: schema4, parentSchema, $data, it } = cxt;
|
|
1880
1880
|
checkAsyncKeyword(it, def);
|
|
1881
|
-
const validate6 = !$data && def.compile ? def.compile.call(it.self,
|
|
1881
|
+
const validate6 = !$data && def.compile ? def.compile.call(it.self, schema4, parentSchema, it) : def.validate;
|
|
1882
1882
|
const validateRef = useKeyword(gen2, keyword, validate6);
|
|
1883
1883
|
const valid = gen2.let("valid");
|
|
1884
1884
|
cxt.block$data(valid, validateKeyword);
|
|
@@ -1938,20 +1938,20 @@ var require_keyword = __commonJS({
|
|
|
1938
1938
|
throw new Error(`keyword "${keyword}" failed to compile`);
|
|
1939
1939
|
return gen2.scopeValue("keyword", typeof result2 == "function" ? { ref: result2 } : { ref: result2, code: (0, codegen_1.stringify)(result2) });
|
|
1940
1940
|
}
|
|
1941
|
-
function validSchemaType(
|
|
1942
|
-
return !schemaType.length || schemaType.some((st) => st === "array" ? Array.isArray(
|
|
1941
|
+
function validSchemaType(schema4, schemaType, allowUndefined = false) {
|
|
1942
|
+
return !schemaType.length || schemaType.some((st) => st === "array" ? Array.isArray(schema4) : st === "object" ? schema4 && typeof schema4 == "object" && !Array.isArray(schema4) : typeof schema4 == st || allowUndefined && typeof schema4 == "undefined");
|
|
1943
1943
|
}
|
|
1944
1944
|
exports.validSchemaType = validSchemaType;
|
|
1945
|
-
function validateKeywordUsage({ schema:
|
|
1945
|
+
function validateKeywordUsage({ schema: schema4, opts, self, errSchemaPath }, def, keyword) {
|
|
1946
1946
|
if (Array.isArray(def.keyword) ? !def.keyword.includes(keyword) : def.keyword !== keyword) {
|
|
1947
1947
|
throw new Error("ajv implementation error");
|
|
1948
1948
|
}
|
|
1949
1949
|
const deps = def.dependencies;
|
|
1950
|
-
if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(
|
|
1950
|
+
if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema4, kwd))) {
|
|
1951
1951
|
throw new Error(`parent schema must have dependencies of ${keyword}: ${deps.join(",")}`);
|
|
1952
1952
|
}
|
|
1953
1953
|
if (def.validateSchema) {
|
|
1954
|
-
const valid = def.validateSchema(
|
|
1954
|
+
const valid = def.validateSchema(schema4[keyword]);
|
|
1955
1955
|
if (!valid) {
|
|
1956
1956
|
const msg = `keyword "${keyword}" value is invalid at path "${errSchemaPath}": ` + self.errorsText(def.validateSchema.errors);
|
|
1957
1957
|
if (opts.validateSchema === "log")
|
|
@@ -1973,8 +1973,8 @@ var require_subschema = __commonJS({
|
|
|
1973
1973
|
exports.extendSubschemaMode = exports.extendSubschemaData = exports.getSubschema = void 0;
|
|
1974
1974
|
var codegen_1 = require_codegen();
|
|
1975
1975
|
var util_1 = require_util();
|
|
1976
|
-
function getSubschema(it, { keyword, schemaProp, schema:
|
|
1977
|
-
if (keyword !== void 0 &&
|
|
1976
|
+
function getSubschema(it, { keyword, schemaProp, schema: schema4, schemaPath, errSchemaPath, topSchemaRef }) {
|
|
1977
|
+
if (keyword !== void 0 && schema4 !== void 0) {
|
|
1978
1978
|
throw new Error('both "keyword" and "schema" passed, only one allowed');
|
|
1979
1979
|
}
|
|
1980
1980
|
if (keyword !== void 0) {
|
|
@@ -1989,12 +1989,12 @@ var require_subschema = __commonJS({
|
|
|
1989
1989
|
errSchemaPath: `${it.errSchemaPath}/${keyword}/${(0, util_1.escapeFragment)(schemaProp)}`
|
|
1990
1990
|
};
|
|
1991
1991
|
}
|
|
1992
|
-
if (
|
|
1992
|
+
if (schema4 !== void 0) {
|
|
1993
1993
|
if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
|
|
1994
1994
|
throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
|
|
1995
1995
|
}
|
|
1996
1996
|
return {
|
|
1997
|
-
schema:
|
|
1997
|
+
schema: schema4,
|
|
1998
1998
|
schemaPath,
|
|
1999
1999
|
topSchemaRef,
|
|
2000
2000
|
errSchemaPath
|
|
@@ -2087,7 +2087,7 @@ var require_fast_deep_equal = __commonJS({
|
|
|
2087
2087
|
var require_json_schema_traverse = __commonJS({
|
|
2088
2088
|
"../../node_modules/.pnpm/json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js"(exports, module) {
|
|
2089
2089
|
"use strict";
|
|
2090
|
-
var traverse = module.exports = function(
|
|
2090
|
+
var traverse = module.exports = function(schema4, opts, cb) {
|
|
2091
2091
|
if (typeof opts == "function") {
|
|
2092
2092
|
cb = opts;
|
|
2093
2093
|
opts = {};
|
|
@@ -2097,7 +2097,7 @@ var require_json_schema_traverse = __commonJS({
|
|
|
2097
2097
|
};
|
|
2098
2098
|
var post = cb.post || function() {
|
|
2099
2099
|
};
|
|
2100
|
-
_traverse(opts, pre, post,
|
|
2100
|
+
_traverse(opts, pre, post, schema4, "", schema4);
|
|
2101
2101
|
};
|
|
2102
2102
|
traverse.keywords = {
|
|
2103
2103
|
additionalItems: true,
|
|
@@ -2143,26 +2143,26 @@ var require_json_schema_traverse = __commonJS({
|
|
|
2143
2143
|
maxProperties: true,
|
|
2144
2144
|
minProperties: true
|
|
2145
2145
|
};
|
|
2146
|
-
function _traverse(opts, pre, post,
|
|
2147
|
-
if (
|
|
2148
|
-
pre(
|
|
2149
|
-
for (var key in
|
|
2150
|
-
var sch =
|
|
2146
|
+
function _traverse(opts, pre, post, schema4, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
|
|
2147
|
+
if (schema4 && typeof schema4 == "object" && !Array.isArray(schema4)) {
|
|
2148
|
+
pre(schema4, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
|
|
2149
|
+
for (var key in schema4) {
|
|
2150
|
+
var sch = schema4[key];
|
|
2151
2151
|
if (Array.isArray(sch)) {
|
|
2152
2152
|
if (key in traverse.arrayKeywords) {
|
|
2153
2153
|
for (var i2 = 0; i2 < sch.length; i2++)
|
|
2154
|
-
_traverse(opts, pre, post, sch[i2], jsonPtr + "/" + key + "/" + i2, rootSchema, jsonPtr, key,
|
|
2154
|
+
_traverse(opts, pre, post, sch[i2], jsonPtr + "/" + key + "/" + i2, rootSchema, jsonPtr, key, schema4, i2);
|
|
2155
2155
|
}
|
|
2156
2156
|
} else if (key in traverse.propsKeywords) {
|
|
2157
2157
|
if (sch && typeof sch == "object") {
|
|
2158
2158
|
for (var prop in sch)
|
|
2159
|
-
_traverse(opts, pre, post, sch[prop], jsonPtr + "/" + key + "/" + escapeJsonPtr(prop), rootSchema, jsonPtr, key,
|
|
2159
|
+
_traverse(opts, pre, post, sch[prop], jsonPtr + "/" + key + "/" + escapeJsonPtr(prop), rootSchema, jsonPtr, key, schema4, prop);
|
|
2160
2160
|
}
|
|
2161
2161
|
} else if (key in traverse.keywords || opts.allKeys && !(key in traverse.skipKeywords)) {
|
|
2162
|
-
_traverse(opts, pre, post, sch, jsonPtr + "/" + key, rootSchema, jsonPtr, key,
|
|
2162
|
+
_traverse(opts, pre, post, sch, jsonPtr + "/" + key, rootSchema, jsonPtr, key, schema4);
|
|
2163
2163
|
}
|
|
2164
2164
|
}
|
|
2165
|
-
post(
|
|
2165
|
+
post(schema4, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
|
|
2166
2166
|
}
|
|
2167
2167
|
}
|
|
2168
2168
|
function escapeJsonPtr(str) {
|
|
@@ -2198,14 +2198,14 @@ var require_resolve = __commonJS({
|
|
|
2198
2198
|
"enum",
|
|
2199
2199
|
"const"
|
|
2200
2200
|
]);
|
|
2201
|
-
function inlineRef(
|
|
2202
|
-
if (typeof
|
|
2201
|
+
function inlineRef(schema4, limit = true) {
|
|
2202
|
+
if (typeof schema4 == "boolean")
|
|
2203
2203
|
return true;
|
|
2204
2204
|
if (limit === true)
|
|
2205
|
-
return !hasRef(
|
|
2205
|
+
return !hasRef(schema4);
|
|
2206
2206
|
if (!limit)
|
|
2207
2207
|
return false;
|
|
2208
|
-
return countKeys(
|
|
2208
|
+
return countKeys(schema4) <= limit;
|
|
2209
2209
|
}
|
|
2210
2210
|
exports.inlineRef = inlineRef;
|
|
2211
2211
|
var REF_KEYWORDS = /* @__PURE__ */ new Set([
|
|
@@ -2215,11 +2215,11 @@ var require_resolve = __commonJS({
|
|
|
2215
2215
|
"$dynamicRef",
|
|
2216
2216
|
"$dynamicAnchor"
|
|
2217
2217
|
]);
|
|
2218
|
-
function hasRef(
|
|
2219
|
-
for (const key in
|
|
2218
|
+
function hasRef(schema4) {
|
|
2219
|
+
for (const key in schema4) {
|
|
2220
2220
|
if (REF_KEYWORDS.has(key))
|
|
2221
2221
|
return true;
|
|
2222
|
-
const sch =
|
|
2222
|
+
const sch = schema4[key];
|
|
2223
2223
|
if (Array.isArray(sch) && sch.some(hasRef))
|
|
2224
2224
|
return true;
|
|
2225
2225
|
if (typeof sch == "object" && hasRef(sch))
|
|
@@ -2227,16 +2227,16 @@ var require_resolve = __commonJS({
|
|
|
2227
2227
|
}
|
|
2228
2228
|
return false;
|
|
2229
2229
|
}
|
|
2230
|
-
function countKeys(
|
|
2230
|
+
function countKeys(schema4) {
|
|
2231
2231
|
let count = 0;
|
|
2232
|
-
for (const key in
|
|
2232
|
+
for (const key in schema4) {
|
|
2233
2233
|
if (key === "$ref")
|
|
2234
2234
|
return Infinity;
|
|
2235
2235
|
count++;
|
|
2236
2236
|
if (SIMPLE_INLINED.has(key))
|
|
2237
2237
|
continue;
|
|
2238
|
-
if (typeof
|
|
2239
|
-
(0, util_1.eachItem)(
|
|
2238
|
+
if (typeof schema4[key] == "object") {
|
|
2239
|
+
(0, util_1.eachItem)(schema4[key], (sch) => count += countKeys(sch));
|
|
2240
2240
|
}
|
|
2241
2241
|
if (count === Infinity)
|
|
2242
2242
|
return Infinity;
|
|
@@ -2266,16 +2266,16 @@ var require_resolve = __commonJS({
|
|
|
2266
2266
|
}
|
|
2267
2267
|
exports.resolveUrl = resolveUrl;
|
|
2268
2268
|
var ANCHOR = /^[a-z_][-a-z0-9._]*$/i;
|
|
2269
|
-
function getSchemaRefs(
|
|
2270
|
-
if (typeof
|
|
2269
|
+
function getSchemaRefs(schema4, baseId) {
|
|
2270
|
+
if (typeof schema4 == "boolean")
|
|
2271
2271
|
return {};
|
|
2272
2272
|
const { schemaId, uriResolver } = this.opts;
|
|
2273
|
-
const schId = normalizeId(
|
|
2273
|
+
const schId = normalizeId(schema4[schemaId] || baseId);
|
|
2274
2274
|
const baseIds = { "": schId };
|
|
2275
2275
|
const pathPrefix = getFullPath(uriResolver, schId, false);
|
|
2276
2276
|
const localRefs = {};
|
|
2277
2277
|
const schemaRefs = /* @__PURE__ */ new Set();
|
|
2278
|
-
traverse(
|
|
2278
|
+
traverse(schema4, { allKeys: true }, (sch, jsonPtr, _, parentJsonPtr) => {
|
|
2279
2279
|
if (parentJsonPtr === void 0)
|
|
2280
2280
|
return;
|
|
2281
2281
|
const fullPath = pathPrefix + jsonPtr;
|
|
@@ -2356,15 +2356,15 @@ var require_validate = __commonJS({
|
|
|
2356
2356
|
validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
|
|
2357
2357
|
}
|
|
2358
2358
|
exports.validateFunctionCode = validateFunctionCode;
|
|
2359
|
-
function validateFunction({ gen: gen2, validateName, schema:
|
|
2359
|
+
function validateFunction({ gen: gen2, validateName, schema: schema4, schemaEnv, opts }, body) {
|
|
2360
2360
|
if (opts.code.es5) {
|
|
2361
2361
|
gen2.func(validateName, (0, codegen_1._)`${names_1.default.data}, ${names_1.default.valCxt}`, schemaEnv.$async, () => {
|
|
2362
|
-
gen2.code((0, codegen_1._)`"use strict"; ${funcSourceUrl(
|
|
2362
|
+
gen2.code((0, codegen_1._)`"use strict"; ${funcSourceUrl(schema4, opts)}`);
|
|
2363
2363
|
destructureValCxtES5(gen2, opts);
|
|
2364
2364
|
gen2.code(body);
|
|
2365
2365
|
});
|
|
2366
2366
|
} else {
|
|
2367
|
-
gen2.func(validateName, (0, codegen_1._)`${names_1.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen2.code(funcSourceUrl(
|
|
2367
|
+
gen2.func(validateName, (0, codegen_1._)`${names_1.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen2.code(funcSourceUrl(schema4, opts)).code(body));
|
|
2368
2368
|
}
|
|
2369
2369
|
}
|
|
2370
2370
|
function destructureValCxt(opts) {
|
|
@@ -2388,9 +2388,9 @@ var require_validate = __commonJS({
|
|
|
2388
2388
|
});
|
|
2389
2389
|
}
|
|
2390
2390
|
function topSchemaObjCode(it) {
|
|
2391
|
-
const { schema:
|
|
2391
|
+
const { schema: schema4, opts, gen: gen2 } = it;
|
|
2392
2392
|
validateFunction(it, () => {
|
|
2393
|
-
if (opts.$comment &&
|
|
2393
|
+
if (opts.$comment && schema4.$comment)
|
|
2394
2394
|
commentKeyword(it);
|
|
2395
2395
|
checkNoDefault(it);
|
|
2396
2396
|
gen2.let(names_1.default.vErrors, null);
|
|
@@ -2408,8 +2408,8 @@ var require_validate = __commonJS({
|
|
|
2408
2408
|
gen2.if((0, codegen_1._)`${it.evaluated}.dynamicProps`, () => gen2.assign((0, codegen_1._)`${it.evaluated}.props`, (0, codegen_1._)`undefined`));
|
|
2409
2409
|
gen2.if((0, codegen_1._)`${it.evaluated}.dynamicItems`, () => gen2.assign((0, codegen_1._)`${it.evaluated}.items`, (0, codegen_1._)`undefined`));
|
|
2410
2410
|
}
|
|
2411
|
-
function funcSourceUrl(
|
|
2412
|
-
const schId = typeof
|
|
2411
|
+
function funcSourceUrl(schema4, opts) {
|
|
2412
|
+
const schId = typeof schema4 == "object" && schema4[opts.schemaId];
|
|
2413
2413
|
return schId && (opts.code.source || opts.code.process) ? (0, codegen_1._)`/*# sourceURL=${schId} */` : codegen_1.nil;
|
|
2414
2414
|
}
|
|
2415
2415
|
function subschemaCode(it, valid) {
|
|
@@ -2422,10 +2422,10 @@ var require_validate = __commonJS({
|
|
|
2422
2422
|
}
|
|
2423
2423
|
(0, boolSchema_1.boolOrEmptySchema)(it, valid);
|
|
2424
2424
|
}
|
|
2425
|
-
function schemaCxtHasRules({ schema:
|
|
2426
|
-
if (typeof
|
|
2427
|
-
return !
|
|
2428
|
-
for (const key in
|
|
2425
|
+
function schemaCxtHasRules({ schema: schema4, self }) {
|
|
2426
|
+
if (typeof schema4 == "boolean")
|
|
2427
|
+
return !schema4;
|
|
2428
|
+
for (const key in schema4)
|
|
2429
2429
|
if (self.RULES.all[key])
|
|
2430
2430
|
return true;
|
|
2431
2431
|
return false;
|
|
@@ -2434,8 +2434,8 @@ var require_validate = __commonJS({
|
|
|
2434
2434
|
return typeof it.schema != "boolean";
|
|
2435
2435
|
}
|
|
2436
2436
|
function subSchemaObjCode(it, valid) {
|
|
2437
|
-
const { schema:
|
|
2438
|
-
if (opts.$comment &&
|
|
2437
|
+
const { schema: schema4, gen: gen2, opts } = it;
|
|
2438
|
+
if (opts.$comment && schema4.$comment)
|
|
2439
2439
|
commentKeyword(it);
|
|
2440
2440
|
updateContext(it);
|
|
2441
2441
|
checkAsyncSchema(it);
|
|
@@ -2455,14 +2455,14 @@ var require_validate = __commonJS({
|
|
|
2455
2455
|
schemaKeywords(it, types, !checkedTypes, errsCount);
|
|
2456
2456
|
}
|
|
2457
2457
|
function checkRefsAndKeywords(it) {
|
|
2458
|
-
const { schema:
|
|
2459
|
-
if (
|
|
2458
|
+
const { schema: schema4, errSchemaPath, opts, self } = it;
|
|
2459
|
+
if (schema4.$ref && opts.ignoreKeywordsWithRef && (0, util_1.schemaHasRulesButRef)(schema4, self.RULES)) {
|
|
2460
2460
|
self.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
|
|
2461
2461
|
}
|
|
2462
2462
|
}
|
|
2463
2463
|
function checkNoDefault(it) {
|
|
2464
|
-
const { schema:
|
|
2465
|
-
if (
|
|
2464
|
+
const { schema: schema4, opts } = it;
|
|
2465
|
+
if (schema4.default !== void 0 && opts.useDefaults && opts.strictSchema) {
|
|
2466
2466
|
(0, util_1.checkStrictMode)(it, "default is ignored in the schema root");
|
|
2467
2467
|
}
|
|
2468
2468
|
}
|
|
@@ -2475,8 +2475,8 @@ var require_validate = __commonJS({
|
|
|
2475
2475
|
if (it.schema.$async && !it.schemaEnv.$async)
|
|
2476
2476
|
throw new Error("async schema in sync schema");
|
|
2477
2477
|
}
|
|
2478
|
-
function commentKeyword({ gen: gen2, schemaEnv, schema:
|
|
2479
|
-
const msg =
|
|
2478
|
+
function commentKeyword({ gen: gen2, schemaEnv, schema: schema4, errSchemaPath, opts }) {
|
|
2479
|
+
const msg = schema4.$comment;
|
|
2480
2480
|
if (opts.$comment === true) {
|
|
2481
2481
|
gen2.code((0, codegen_1._)`${names_1.default.self}.logger.log(${msg})`);
|
|
2482
2482
|
} else if (typeof opts.$comment == "function") {
|
|
@@ -2503,9 +2503,9 @@ var require_validate = __commonJS({
|
|
|
2503
2503
|
gen2.assign((0, codegen_1._)`${evaluated}.items`, items);
|
|
2504
2504
|
}
|
|
2505
2505
|
function schemaKeywords(it, types, typeErrors, errsCount) {
|
|
2506
|
-
const { gen: gen2, schema:
|
|
2506
|
+
const { gen: gen2, schema: schema4, data, allErrors, opts, self } = it;
|
|
2507
2507
|
const { RULES } = self;
|
|
2508
|
-
if (
|
|
2508
|
+
if (schema4.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1.schemaHasRulesButRef)(schema4, RULES))) {
|
|
2509
2509
|
gen2.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
|
|
2510
2510
|
return;
|
|
2511
2511
|
}
|
|
@@ -2517,7 +2517,7 @@ var require_validate = __commonJS({
|
|
|
2517
2517
|
groupKeywords(RULES.post);
|
|
2518
2518
|
});
|
|
2519
2519
|
function groupKeywords(group) {
|
|
2520
|
-
if (!(0, applicability_1.shouldUseGroup)(
|
|
2520
|
+
if (!(0, applicability_1.shouldUseGroup)(schema4, group))
|
|
2521
2521
|
return;
|
|
2522
2522
|
if (group.type) {
|
|
2523
2523
|
gen2.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
|
|
@@ -2535,12 +2535,12 @@ var require_validate = __commonJS({
|
|
|
2535
2535
|
}
|
|
2536
2536
|
}
|
|
2537
2537
|
function iterateKeywords(it, group) {
|
|
2538
|
-
const { gen: gen2, schema:
|
|
2538
|
+
const { gen: gen2, schema: schema4, opts: { useDefaults } } = it;
|
|
2539
2539
|
if (useDefaults)
|
|
2540
2540
|
(0, defaults_1.assignDefaults)(it, group.type);
|
|
2541
2541
|
gen2.block(() => {
|
|
2542
2542
|
for (const rule of group.rules) {
|
|
2543
|
-
if ((0, applicability_1.shouldUseRule)(
|
|
2543
|
+
if ((0, applicability_1.shouldUseRule)(schema4, rule)) {
|
|
2544
2544
|
keywordCode(it, rule.keyword, rule.definition, group.type);
|
|
2545
2545
|
}
|
|
2546
2546
|
}
|
|
@@ -2885,17 +2885,17 @@ var require_compile = __commonJS({
|
|
|
2885
2885
|
var _a4;
|
|
2886
2886
|
this.refs = {};
|
|
2887
2887
|
this.dynamicAnchors = {};
|
|
2888
|
-
let
|
|
2888
|
+
let schema4;
|
|
2889
2889
|
if (typeof env.schema == "object")
|
|
2890
|
-
|
|
2890
|
+
schema4 = env.schema;
|
|
2891
2891
|
this.schema = env.schema;
|
|
2892
2892
|
this.schemaId = env.schemaId;
|
|
2893
2893
|
this.root = env.root || this;
|
|
2894
|
-
this.baseId = (_a4 = env.baseId) !== null && _a4 !== void 0 ? _a4 : (0, resolve_1.normalizeId)(
|
|
2894
|
+
this.baseId = (_a4 = env.baseId) !== null && _a4 !== void 0 ? _a4 : (0, resolve_1.normalizeId)(schema4 === null || schema4 === void 0 ? void 0 : schema4[env.schemaId || "$id"]);
|
|
2895
2895
|
this.schemaPath = env.schemaPath;
|
|
2896
2896
|
this.localRefs = env.localRefs;
|
|
2897
2897
|
this.meta = env.meta;
|
|
2898
|
-
this.$async =
|
|
2898
|
+
this.$async = schema4 === null || schema4 === void 0 ? void 0 : schema4.$async;
|
|
2899
2899
|
this.refs = {};
|
|
2900
2900
|
}
|
|
2901
2901
|
};
|
|
@@ -2994,10 +2994,10 @@ var require_compile = __commonJS({
|
|
|
2994
2994
|
return schOrFunc;
|
|
2995
2995
|
let _sch = resolve4.call(this, root, ref);
|
|
2996
2996
|
if (_sch === void 0) {
|
|
2997
|
-
const
|
|
2997
|
+
const schema4 = (_a4 = root.localRefs) === null || _a4 === void 0 ? void 0 : _a4[ref];
|
|
2998
2998
|
const { schemaId } = this.opts;
|
|
2999
|
-
if (
|
|
3000
|
-
_sch = new SchemaEnv({ schema:
|
|
2999
|
+
if (schema4)
|
|
3000
|
+
_sch = new SchemaEnv({ schema: schema4, schemaId, root, baseId });
|
|
3001
3001
|
}
|
|
3002
3002
|
if (_sch === void 0)
|
|
3003
3003
|
return;
|
|
@@ -3045,12 +3045,12 @@ var require_compile = __commonJS({
|
|
|
3045
3045
|
if (!schOrRef.validate)
|
|
3046
3046
|
compileSchema.call(this, schOrRef);
|
|
3047
3047
|
if (id === (0, resolve_1.normalizeId)(ref)) {
|
|
3048
|
-
const { schema:
|
|
3048
|
+
const { schema: schema4 } = schOrRef;
|
|
3049
3049
|
const { schemaId } = this.opts;
|
|
3050
|
-
const schId =
|
|
3050
|
+
const schId = schema4[schemaId];
|
|
3051
3051
|
if (schId)
|
|
3052
3052
|
baseId = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schId);
|
|
3053
|
-
return new SchemaEnv({ schema:
|
|
3053
|
+
return new SchemaEnv({ schema: schema4, schemaId, root, baseId });
|
|
3054
3054
|
}
|
|
3055
3055
|
return getJsonPointer.call(this, p, schOrRef);
|
|
3056
3056
|
}
|
|
@@ -3062,29 +3062,29 @@ var require_compile = __commonJS({
|
|
|
3062
3062
|
"dependencies",
|
|
3063
3063
|
"definitions"
|
|
3064
3064
|
]);
|
|
3065
|
-
function getJsonPointer(parsedRef, { baseId, schema:
|
|
3065
|
+
function getJsonPointer(parsedRef, { baseId, schema: schema4, root }) {
|
|
3066
3066
|
var _a4;
|
|
3067
3067
|
if (((_a4 = parsedRef.fragment) === null || _a4 === void 0 ? void 0 : _a4[0]) !== "/")
|
|
3068
3068
|
return;
|
|
3069
3069
|
for (const part of parsedRef.fragment.slice(1).split("/")) {
|
|
3070
|
-
if (typeof
|
|
3070
|
+
if (typeof schema4 === "boolean")
|
|
3071
3071
|
return;
|
|
3072
|
-
const partSchema =
|
|
3072
|
+
const partSchema = schema4[(0, util_1.unescapeFragment)(part)];
|
|
3073
3073
|
if (partSchema === void 0)
|
|
3074
3074
|
return;
|
|
3075
|
-
|
|
3076
|
-
const schId = typeof
|
|
3075
|
+
schema4 = partSchema;
|
|
3076
|
+
const schId = typeof schema4 === "object" && schema4[this.opts.schemaId];
|
|
3077
3077
|
if (!PREVENT_SCOPE_CHANGE.has(part) && schId) {
|
|
3078
3078
|
baseId = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schId);
|
|
3079
3079
|
}
|
|
3080
3080
|
}
|
|
3081
3081
|
let env;
|
|
3082
|
-
if (typeof
|
|
3083
|
-
const $ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId,
|
|
3082
|
+
if (typeof schema4 != "boolean" && schema4.$ref && !(0, util_1.schemaHasRulesButRef)(schema4, this.RULES)) {
|
|
3083
|
+
const $ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schema4.$ref);
|
|
3084
3084
|
env = resolveSchema.call(this, root, $ref);
|
|
3085
3085
|
}
|
|
3086
3086
|
const { schemaId } = this.opts;
|
|
3087
|
-
env = env || new SchemaEnv({ schema:
|
|
3087
|
+
env = env || new SchemaEnv({ schema: schema4, schemaId, root, baseId });
|
|
3088
3088
|
if (env.schema !== env.root.schema)
|
|
3089
3089
|
return env;
|
|
3090
3090
|
return void 0;
|
|
@@ -4126,16 +4126,16 @@ var require_core = __commonJS({
|
|
|
4126
4126
|
this.errors = v.errors;
|
|
4127
4127
|
return valid;
|
|
4128
4128
|
}
|
|
4129
|
-
compile(
|
|
4130
|
-
const sch = this._addSchema(
|
|
4129
|
+
compile(schema4, _meta) {
|
|
4130
|
+
const sch = this._addSchema(schema4, _meta);
|
|
4131
4131
|
return sch.validate || this._compileSchemaEnv(sch);
|
|
4132
4132
|
}
|
|
4133
|
-
compileAsync(
|
|
4133
|
+
compileAsync(schema4, meta3) {
|
|
4134
4134
|
if (typeof this.opts.loadSchema != "function") {
|
|
4135
4135
|
throw new Error("options.loadSchema should be a function");
|
|
4136
4136
|
}
|
|
4137
4137
|
const { loadSchema } = this.opts;
|
|
4138
|
-
return runCompileAsync.call(this,
|
|
4138
|
+
return runCompileAsync.call(this, schema4, meta3);
|
|
4139
4139
|
async function runCompileAsync(_schema, _meta) {
|
|
4140
4140
|
await loadMetaSchema.call(this, _schema.$schema);
|
|
4141
4141
|
const sch = this._addSchema(_schema, _meta);
|
|
@@ -4181,37 +4181,37 @@ var require_core = __commonJS({
|
|
|
4181
4181
|
}
|
|
4182
4182
|
}
|
|
4183
4183
|
// Adds schema to the instance
|
|
4184
|
-
addSchema(
|
|
4185
|
-
if (Array.isArray(
|
|
4186
|
-
for (const sch of
|
|
4184
|
+
addSchema(schema4, key, _meta, _validateSchema = this.opts.validateSchema) {
|
|
4185
|
+
if (Array.isArray(schema4)) {
|
|
4186
|
+
for (const sch of schema4)
|
|
4187
4187
|
this.addSchema(sch, void 0, _meta, _validateSchema);
|
|
4188
4188
|
return this;
|
|
4189
4189
|
}
|
|
4190
4190
|
let id;
|
|
4191
|
-
if (typeof
|
|
4191
|
+
if (typeof schema4 === "object") {
|
|
4192
4192
|
const { schemaId } = this.opts;
|
|
4193
|
-
id =
|
|
4193
|
+
id = schema4[schemaId];
|
|
4194
4194
|
if (id !== void 0 && typeof id != "string") {
|
|
4195
4195
|
throw new Error(`schema ${schemaId} must be string`);
|
|
4196
4196
|
}
|
|
4197
4197
|
}
|
|
4198
4198
|
key = (0, resolve_1.normalizeId)(key || id);
|
|
4199
4199
|
this._checkUnique(key);
|
|
4200
|
-
this.schemas[key] = this._addSchema(
|
|
4200
|
+
this.schemas[key] = this._addSchema(schema4, _meta, key, _validateSchema, true);
|
|
4201
4201
|
return this;
|
|
4202
4202
|
}
|
|
4203
4203
|
// Add schema that will be used to validate other schemas
|
|
4204
4204
|
// options in META_IGNORE_OPTIONS are alway set to false
|
|
4205
|
-
addMetaSchema(
|
|
4206
|
-
this.addSchema(
|
|
4205
|
+
addMetaSchema(schema4, key, _validateSchema = this.opts.validateSchema) {
|
|
4206
|
+
this.addSchema(schema4, key, true, _validateSchema);
|
|
4207
4207
|
return this;
|
|
4208
4208
|
}
|
|
4209
4209
|
// Validate schema against its meta-schema
|
|
4210
|
-
validateSchema(
|
|
4211
|
-
if (typeof
|
|
4210
|
+
validateSchema(schema4, throwOrLogError) {
|
|
4211
|
+
if (typeof schema4 == "boolean")
|
|
4212
4212
|
return true;
|
|
4213
4213
|
let $schema;
|
|
4214
|
-
$schema =
|
|
4214
|
+
$schema = schema4.$schema;
|
|
4215
4215
|
if ($schema !== void 0 && typeof $schema != "string") {
|
|
4216
4216
|
throw new Error("$schema must be a string");
|
|
4217
4217
|
}
|
|
@@ -4221,7 +4221,7 @@ var require_core = __commonJS({
|
|
|
4221
4221
|
this.errors = null;
|
|
4222
4222
|
return true;
|
|
4223
4223
|
}
|
|
4224
|
-
const valid = this.validate($schema,
|
|
4224
|
+
const valid = this.validate($schema, schema4);
|
|
4225
4225
|
if (!valid && throwOrLogError) {
|
|
4226
4226
|
const message = "schema is invalid: " + this.errorsText();
|
|
4227
4227
|
if (this.opts.validateSchema === "log")
|
|
@@ -4364,9 +4364,9 @@ var require_core = __commonJS({
|
|
|
4364
4364
|
if (typeof rule != "object")
|
|
4365
4365
|
continue;
|
|
4366
4366
|
const { $data } = rule.definition;
|
|
4367
|
-
const
|
|
4368
|
-
if ($data &&
|
|
4369
|
-
keywords[key] = schemaOrData(
|
|
4367
|
+
const schema4 = keywords[key];
|
|
4368
|
+
if ($data && schema4)
|
|
4369
|
+
keywords[key] = schemaOrData(schema4);
|
|
4370
4370
|
}
|
|
4371
4371
|
}
|
|
4372
4372
|
return metaSchema;
|
|
@@ -4384,23 +4384,23 @@ var require_core = __commonJS({
|
|
|
4384
4384
|
}
|
|
4385
4385
|
}
|
|
4386
4386
|
}
|
|
4387
|
-
_addSchema(
|
|
4387
|
+
_addSchema(schema4, meta3, baseId, validateSchema = this.opts.validateSchema, addSchema = this.opts.addUsedSchema) {
|
|
4388
4388
|
let id;
|
|
4389
4389
|
const { schemaId } = this.opts;
|
|
4390
|
-
if (typeof
|
|
4391
|
-
id =
|
|
4390
|
+
if (typeof schema4 == "object") {
|
|
4391
|
+
id = schema4[schemaId];
|
|
4392
4392
|
} else {
|
|
4393
4393
|
if (this.opts.jtd)
|
|
4394
4394
|
throw new Error("schema must be object");
|
|
4395
|
-
else if (typeof
|
|
4395
|
+
else if (typeof schema4 != "boolean")
|
|
4396
4396
|
throw new Error("schema must be object or boolean");
|
|
4397
4397
|
}
|
|
4398
|
-
let sch = this._cache.get(
|
|
4398
|
+
let sch = this._cache.get(schema4);
|
|
4399
4399
|
if (sch !== void 0)
|
|
4400
4400
|
return sch;
|
|
4401
4401
|
baseId = (0, resolve_1.normalizeId)(id || baseId);
|
|
4402
|
-
const localRefs = resolve_1.getSchemaRefs.call(this,
|
|
4403
|
-
sch = new compile_1.SchemaEnv({ schema:
|
|
4402
|
+
const localRefs = resolve_1.getSchemaRefs.call(this, schema4, baseId);
|
|
4403
|
+
sch = new compile_1.SchemaEnv({ schema: schema4, schemaId, meta: meta3, baseId, localRefs });
|
|
4404
4404
|
this._cache.set(sch.schema, sch);
|
|
4405
4405
|
if (addSchema && !baseId.startsWith("#")) {
|
|
4406
4406
|
if (baseId)
|
|
@@ -4408,7 +4408,7 @@ var require_core = __commonJS({
|
|
|
4408
4408
|
this.refs[baseId] = sch;
|
|
4409
4409
|
}
|
|
4410
4410
|
if (validateSchema)
|
|
4411
|
-
this.validateSchema(
|
|
4411
|
+
this.validateSchema(schema4, true);
|
|
4412
4412
|
return sch;
|
|
4413
4413
|
}
|
|
4414
4414
|
_checkUnique(id) {
|
|
@@ -4562,8 +4562,8 @@ var require_core = __commonJS({
|
|
|
4562
4562
|
var $dataRef = {
|
|
4563
4563
|
$ref: "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"
|
|
4564
4564
|
};
|
|
4565
|
-
function schemaOrData(
|
|
4566
|
-
return { anyOf: [
|
|
4565
|
+
function schemaOrData(schema4) {
|
|
4566
|
+
return { anyOf: [schema4, $dataRef] };
|
|
4567
4567
|
}
|
|
4568
4568
|
}
|
|
4569
4569
|
});
|
|
@@ -4863,7 +4863,7 @@ var require_pattern = __commonJS({
|
|
|
4863
4863
|
$data: true,
|
|
4864
4864
|
error: error51,
|
|
4865
4865
|
code(cxt) {
|
|
4866
|
-
const { gen: gen2, data, $data, schema:
|
|
4866
|
+
const { gen: gen2, data, $data, schema: schema4, schemaCode, it } = cxt;
|
|
4867
4867
|
const u = it.opts.unicodeRegExp ? "u" : "";
|
|
4868
4868
|
if ($data) {
|
|
4869
4869
|
const { regExp } = it.opts.code;
|
|
@@ -4872,7 +4872,7 @@ var require_pattern = __commonJS({
|
|
|
4872
4872
|
gen2.try(() => gen2.assign(valid, (0, codegen_1._)`${regExpCode}(${schemaCode}, ${u}).test(${data})`), () => gen2.assign(valid, false));
|
|
4873
4873
|
cxt.fail$data((0, codegen_1._)`!${valid}`);
|
|
4874
4874
|
} else {
|
|
4875
|
-
const regExp = (0, code_1.usePattern)(cxt,
|
|
4875
|
+
const regExp = (0, code_1.usePattern)(cxt, schema4);
|
|
4876
4876
|
cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
|
|
4877
4877
|
}
|
|
4878
4878
|
}
|
|
@@ -4929,11 +4929,11 @@ var require_required = __commonJS({
|
|
|
4929
4929
|
$data: true,
|
|
4930
4930
|
error: error51,
|
|
4931
4931
|
code(cxt) {
|
|
4932
|
-
const { gen: gen2, schema:
|
|
4932
|
+
const { gen: gen2, schema: schema4, schemaCode, data, $data, it } = cxt;
|
|
4933
4933
|
const { opts } = it;
|
|
4934
|
-
if (!$data &&
|
|
4934
|
+
if (!$data && schema4.length === 0)
|
|
4935
4935
|
return;
|
|
4936
|
-
const useLoop =
|
|
4936
|
+
const useLoop = schema4.length >= opts.loopRequired;
|
|
4937
4937
|
if (it.allErrors)
|
|
4938
4938
|
allErrorsMode();
|
|
4939
4939
|
else
|
|
@@ -4941,7 +4941,7 @@ var require_required = __commonJS({
|
|
|
4941
4941
|
if (opts.strictRequired) {
|
|
4942
4942
|
const props = cxt.parentSchema.properties;
|
|
4943
4943
|
const { definedProperties } = cxt.it;
|
|
4944
|
-
for (const requiredKey of
|
|
4944
|
+
for (const requiredKey of schema4) {
|
|
4945
4945
|
if ((props === null || props === void 0 ? void 0 : props[requiredKey]) === void 0 && !definedProperties.has(requiredKey)) {
|
|
4946
4946
|
const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
|
|
4947
4947
|
const msg = `required property "${requiredKey}" is not defined at "${schemaPath}" (strictRequired)`;
|
|
@@ -4953,7 +4953,7 @@ var require_required = __commonJS({
|
|
|
4953
4953
|
if (useLoop || $data) {
|
|
4954
4954
|
cxt.block$data(codegen_1.nil, loopAllRequired);
|
|
4955
4955
|
} else {
|
|
4956
|
-
for (const prop of
|
|
4956
|
+
for (const prop of schema4) {
|
|
4957
4957
|
(0, code_1.checkReportMissingProp)(cxt, prop);
|
|
4958
4958
|
}
|
|
4959
4959
|
}
|
|
@@ -4965,7 +4965,7 @@ var require_required = __commonJS({
|
|
|
4965
4965
|
cxt.block$data(valid, () => loopUntilMissing(missing, valid));
|
|
4966
4966
|
cxt.ok(valid);
|
|
4967
4967
|
} else {
|
|
4968
|
-
gen2.if((0, code_1.checkMissingProp)(cxt,
|
|
4968
|
+
gen2.if((0, code_1.checkMissingProp)(cxt, schema4, missing));
|
|
4969
4969
|
(0, code_1.reportMissingProp)(cxt, missing);
|
|
4970
4970
|
gen2.else();
|
|
4971
4971
|
}
|
|
@@ -5052,8 +5052,8 @@ var require_uniqueItems = __commonJS({
|
|
|
5052
5052
|
$data: true,
|
|
5053
5053
|
error: error51,
|
|
5054
5054
|
code(cxt) {
|
|
5055
|
-
const { gen: gen2, data, $data, schema:
|
|
5056
|
-
if (!$data && !
|
|
5055
|
+
const { gen: gen2, data, $data, schema: schema4, parentSchema, schemaCode, it } = cxt;
|
|
5056
|
+
if (!$data && !schema4)
|
|
5057
5057
|
return;
|
|
5058
5058
|
const valid = gen2.let("valid");
|
|
5059
5059
|
const itemTypes = parentSchema.items ? (0, dataType_1.getSchemaTypes)(parentSchema.items) : [];
|
|
@@ -5116,11 +5116,11 @@ var require_const = __commonJS({
|
|
|
5116
5116
|
$data: true,
|
|
5117
5117
|
error: error51,
|
|
5118
5118
|
code(cxt) {
|
|
5119
|
-
const { gen: gen2, data, $data, schemaCode, schema:
|
|
5120
|
-
if ($data ||
|
|
5119
|
+
const { gen: gen2, data, $data, schemaCode, schema: schema4 } = cxt;
|
|
5120
|
+
if ($data || schema4 && typeof schema4 == "object") {
|
|
5121
5121
|
cxt.fail$data((0, codegen_1._)`!${(0, util_1.useFunc)(gen2, equal_1.default)}(${data}, ${schemaCode})`);
|
|
5122
5122
|
} else {
|
|
5123
|
-
cxt.fail((0, codegen_1._)`${
|
|
5123
|
+
cxt.fail((0, codegen_1._)`${schema4} !== ${data}`);
|
|
5124
5124
|
}
|
|
5125
5125
|
}
|
|
5126
5126
|
};
|
|
@@ -5146,10 +5146,10 @@ var require_enum = __commonJS({
|
|
|
5146
5146
|
$data: true,
|
|
5147
5147
|
error: error51,
|
|
5148
5148
|
code(cxt) {
|
|
5149
|
-
const { gen: gen2, data, $data, schema:
|
|
5150
|
-
if (!$data &&
|
|
5149
|
+
const { gen: gen2, data, $data, schema: schema4, schemaCode, it } = cxt;
|
|
5150
|
+
if (!$data && schema4.length === 0)
|
|
5151
5151
|
throw new Error("enum must have non-empty array");
|
|
5152
|
-
const useLoop =
|
|
5152
|
+
const useLoop = schema4.length >= it.opts.loopEnum;
|
|
5153
5153
|
let eql;
|
|
5154
5154
|
const getEql = () => eql !== null && eql !== void 0 ? eql : eql = (0, util_1.useFunc)(gen2, equal_1.default);
|
|
5155
5155
|
let valid;
|
|
@@ -5157,10 +5157,10 @@ var require_enum = __commonJS({
|
|
|
5157
5157
|
valid = gen2.let("valid");
|
|
5158
5158
|
cxt.block$data(valid, loopEnum);
|
|
5159
5159
|
} else {
|
|
5160
|
-
if (!Array.isArray(
|
|
5160
|
+
if (!Array.isArray(schema4))
|
|
5161
5161
|
throw new Error("ajv implementation error");
|
|
5162
5162
|
const vSchema = gen2.const("vSchema", schemaCode);
|
|
5163
|
-
valid = (0, codegen_1.or)(...
|
|
5163
|
+
valid = (0, codegen_1.or)(...schema4.map((_x, i2) => equalCode(vSchema, i2)));
|
|
5164
5164
|
}
|
|
5165
5165
|
cxt.pass(valid);
|
|
5166
5166
|
function loopEnum() {
|
|
@@ -5168,7 +5168,7 @@ var require_enum = __commonJS({
|
|
|
5168
5168
|
gen2.forOf("v", schemaCode, (v) => gen2.if((0, codegen_1._)`${getEql()}(${data}, ${v})`, () => gen2.assign(valid, true).break()));
|
|
5169
5169
|
}
|
|
5170
5170
|
function equalCode(vSchema, i2) {
|
|
5171
|
-
const sch =
|
|
5171
|
+
const sch = schema4[i2];
|
|
5172
5172
|
return typeof sch === "object" && sch !== null ? (0, codegen_1._)`${getEql()}(${data}, ${vSchema}[${i2}])` : (0, codegen_1._)`${data} === ${sch}`;
|
|
5173
5173
|
}
|
|
5174
5174
|
}
|
|
@@ -5244,13 +5244,13 @@ var require_additionalItems = __commonJS({
|
|
|
5244
5244
|
}
|
|
5245
5245
|
};
|
|
5246
5246
|
function validateAdditionalItems(cxt, items) {
|
|
5247
|
-
const { gen: gen2, schema:
|
|
5247
|
+
const { gen: gen2, schema: schema4, data, keyword, it } = cxt;
|
|
5248
5248
|
it.items = true;
|
|
5249
5249
|
const len = gen2.const("len", (0, codegen_1._)`${data}.length`);
|
|
5250
|
-
if (
|
|
5250
|
+
if (schema4 === false) {
|
|
5251
5251
|
cxt.setParams({ len: items.length });
|
|
5252
5252
|
cxt.pass((0, codegen_1._)`${len} <= ${items.length}`);
|
|
5253
|
-
} else if (typeof
|
|
5253
|
+
} else if (typeof schema4 == "object" && !(0, util_1.alwaysValidSchema)(it, schema4)) {
|
|
5254
5254
|
const valid = gen2.var("valid", (0, codegen_1._)`${len} <= ${items.length}`);
|
|
5255
5255
|
gen2.if((0, codegen_1.not)(valid), () => validateItems(valid));
|
|
5256
5256
|
cxt.ok(valid);
|
|
@@ -5283,11 +5283,11 @@ var require_items = __commonJS({
|
|
|
5283
5283
|
schemaType: ["object", "array", "boolean"],
|
|
5284
5284
|
before: "uniqueItems",
|
|
5285
5285
|
code(cxt) {
|
|
5286
|
-
const { schema:
|
|
5287
|
-
if (Array.isArray(
|
|
5288
|
-
return validateTuple(cxt, "additionalItems",
|
|
5286
|
+
const { schema: schema4, it } = cxt;
|
|
5287
|
+
if (Array.isArray(schema4))
|
|
5288
|
+
return validateTuple(cxt, "additionalItems", schema4);
|
|
5289
5289
|
it.items = true;
|
|
5290
|
-
if ((0, util_1.alwaysValidSchema)(it,
|
|
5290
|
+
if ((0, util_1.alwaysValidSchema)(it, schema4))
|
|
5291
5291
|
return;
|
|
5292
5292
|
cxt.ok((0, code_1.validateArray)(cxt));
|
|
5293
5293
|
}
|
|
@@ -5362,10 +5362,10 @@ var require_items2020 = __commonJS({
|
|
|
5362
5362
|
before: "uniqueItems",
|
|
5363
5363
|
error: error51,
|
|
5364
5364
|
code(cxt) {
|
|
5365
|
-
const { schema:
|
|
5365
|
+
const { schema: schema4, parentSchema, it } = cxt;
|
|
5366
5366
|
const { prefixItems } = parentSchema;
|
|
5367
5367
|
it.items = true;
|
|
5368
|
-
if ((0, util_1.alwaysValidSchema)(it,
|
|
5368
|
+
if ((0, util_1.alwaysValidSchema)(it, schema4))
|
|
5369
5369
|
return;
|
|
5370
5370
|
if (prefixItems)
|
|
5371
5371
|
(0, additionalItems_1.validateAdditionalItems)(cxt, prefixItems);
|
|
@@ -5396,7 +5396,7 @@ var require_contains = __commonJS({
|
|
|
5396
5396
|
trackErrors: true,
|
|
5397
5397
|
error: error51,
|
|
5398
5398
|
code(cxt) {
|
|
5399
|
-
const { gen: gen2, schema:
|
|
5399
|
+
const { gen: gen2, schema: schema4, parentSchema, data, it } = cxt;
|
|
5400
5400
|
let min;
|
|
5401
5401
|
let max2;
|
|
5402
5402
|
const { minContains, maxContains } = parentSchema;
|
|
@@ -5417,7 +5417,7 @@ var require_contains = __commonJS({
|
|
|
5417
5417
|
cxt.fail();
|
|
5418
5418
|
return;
|
|
5419
5419
|
}
|
|
5420
|
-
if ((0, util_1.alwaysValidSchema)(it,
|
|
5420
|
+
if ((0, util_1.alwaysValidSchema)(it, schema4)) {
|
|
5421
5421
|
let cond = (0, codegen_1._)`${len} >= ${min}`;
|
|
5422
5422
|
if (max2 !== void 0)
|
|
5423
5423
|
cond = (0, codegen_1._)`${cond} && ${len} <= ${max2}`;
|
|
@@ -5502,14 +5502,14 @@ var require_dependencies = __commonJS({
|
|
|
5502
5502
|
validateSchemaDeps(cxt, schDeps);
|
|
5503
5503
|
}
|
|
5504
5504
|
};
|
|
5505
|
-
function splitDependencies({ schema:
|
|
5505
|
+
function splitDependencies({ schema: schema4 }) {
|
|
5506
5506
|
const propertyDeps = {};
|
|
5507
5507
|
const schemaDeps = {};
|
|
5508
|
-
for (const key in
|
|
5508
|
+
for (const key in schema4) {
|
|
5509
5509
|
if (key === "__proto__")
|
|
5510
5510
|
continue;
|
|
5511
|
-
const deps = Array.isArray(
|
|
5512
|
-
deps[key] =
|
|
5511
|
+
const deps = Array.isArray(schema4[key]) ? propertyDeps : schemaDeps;
|
|
5512
|
+
deps[key] = schema4[key];
|
|
5513
5513
|
}
|
|
5514
5514
|
return [propertyDeps, schemaDeps];
|
|
5515
5515
|
}
|
|
@@ -5582,8 +5582,8 @@ var require_propertyNames = __commonJS({
|
|
|
5582
5582
|
schemaType: ["object", "boolean"],
|
|
5583
5583
|
error: error51,
|
|
5584
5584
|
code(cxt) {
|
|
5585
|
-
const { gen: gen2, schema:
|
|
5586
|
-
if ((0, util_1.alwaysValidSchema)(it,
|
|
5585
|
+
const { gen: gen2, schema: schema4, data, it } = cxt;
|
|
5586
|
+
if ((0, util_1.alwaysValidSchema)(it, schema4))
|
|
5587
5587
|
return;
|
|
5588
5588
|
const valid = gen2.name("valid");
|
|
5589
5589
|
gen2.forIn("key", data, (key) => {
|
|
@@ -5629,12 +5629,12 @@ var require_additionalProperties = __commonJS({
|
|
|
5629
5629
|
trackErrors: true,
|
|
5630
5630
|
error: error51,
|
|
5631
5631
|
code(cxt) {
|
|
5632
|
-
const { gen: gen2, schema:
|
|
5632
|
+
const { gen: gen2, schema: schema4, parentSchema, data, errsCount, it } = cxt;
|
|
5633
5633
|
if (!errsCount)
|
|
5634
5634
|
throw new Error("ajv implementation error");
|
|
5635
5635
|
const { allErrors, opts } = it;
|
|
5636
5636
|
it.props = true;
|
|
5637
|
-
if (opts.removeAdditional !== "all" && (0, util_1.alwaysValidSchema)(it,
|
|
5637
|
+
if (opts.removeAdditional !== "all" && (0, util_1.alwaysValidSchema)(it, schema4))
|
|
5638
5638
|
return;
|
|
5639
5639
|
const props = (0, code_1.allSchemaProperties)(parentSchema.properties);
|
|
5640
5640
|
const patProps = (0, code_1.allSchemaProperties)(parentSchema.patternProperties);
|
|
@@ -5667,18 +5667,18 @@ var require_additionalProperties = __commonJS({
|
|
|
5667
5667
|
gen2.code((0, codegen_1._)`delete ${data}[${key}]`);
|
|
5668
5668
|
}
|
|
5669
5669
|
function additionalPropertyCode(key) {
|
|
5670
|
-
if (opts.removeAdditional === "all" || opts.removeAdditional &&
|
|
5670
|
+
if (opts.removeAdditional === "all" || opts.removeAdditional && schema4 === false) {
|
|
5671
5671
|
deleteAdditional(key);
|
|
5672
5672
|
return;
|
|
5673
5673
|
}
|
|
5674
|
-
if (
|
|
5674
|
+
if (schema4 === false) {
|
|
5675
5675
|
cxt.setParams({ additionalProperty: key });
|
|
5676
5676
|
cxt.error();
|
|
5677
5677
|
if (!allErrors)
|
|
5678
5678
|
gen2.break();
|
|
5679
5679
|
return;
|
|
5680
5680
|
}
|
|
5681
|
-
if (typeof
|
|
5681
|
+
if (typeof schema4 == "object" && !(0, util_1.alwaysValidSchema)(it, schema4)) {
|
|
5682
5682
|
const valid = gen2.name("valid");
|
|
5683
5683
|
if (opts.removeAdditional === "failing") {
|
|
5684
5684
|
applyAdditionalSchema(key, valid, false);
|
|
@@ -5728,18 +5728,18 @@ var require_properties = __commonJS({
|
|
|
5728
5728
|
type: "object",
|
|
5729
5729
|
schemaType: "object",
|
|
5730
5730
|
code(cxt) {
|
|
5731
|
-
const { gen: gen2, schema:
|
|
5731
|
+
const { gen: gen2, schema: schema4, parentSchema, data, it } = cxt;
|
|
5732
5732
|
if (it.opts.removeAdditional === "all" && parentSchema.additionalProperties === void 0) {
|
|
5733
5733
|
additionalProperties_1.default.code(new validate_1.KeywordCxt(it, additionalProperties_1.default, "additionalProperties"));
|
|
5734
5734
|
}
|
|
5735
|
-
const allProps = (0, code_1.allSchemaProperties)(
|
|
5735
|
+
const allProps = (0, code_1.allSchemaProperties)(schema4);
|
|
5736
5736
|
for (const prop of allProps) {
|
|
5737
5737
|
it.definedProperties.add(prop);
|
|
5738
5738
|
}
|
|
5739
5739
|
if (it.opts.unevaluated && allProps.length && it.props !== true) {
|
|
5740
5740
|
it.props = util_1.mergeEvaluated.props(gen2, (0, util_1.toHash)(allProps), it.props);
|
|
5741
5741
|
}
|
|
5742
|
-
const properties = allProps.filter((p) => !(0, util_1.alwaysValidSchema)(it,
|
|
5742
|
+
const properties = allProps.filter((p) => !(0, util_1.alwaysValidSchema)(it, schema4[p]));
|
|
5743
5743
|
if (properties.length === 0)
|
|
5744
5744
|
return;
|
|
5745
5745
|
const valid = gen2.name("valid");
|
|
@@ -5757,7 +5757,7 @@ var require_properties = __commonJS({
|
|
|
5757
5757
|
cxt.ok(valid);
|
|
5758
5758
|
}
|
|
5759
5759
|
function hasDefault(prop) {
|
|
5760
|
-
return it.opts.useDefaults && !it.compositeRule &&
|
|
5760
|
+
return it.opts.useDefaults && !it.compositeRule && schema4[prop].default !== void 0;
|
|
5761
5761
|
}
|
|
5762
5762
|
function applyPropertySchema(prop) {
|
|
5763
5763
|
cxt.subschema({
|
|
@@ -5786,10 +5786,10 @@ var require_patternProperties = __commonJS({
|
|
|
5786
5786
|
type: "object",
|
|
5787
5787
|
schemaType: "object",
|
|
5788
5788
|
code(cxt) {
|
|
5789
|
-
const { gen: gen2, schema:
|
|
5789
|
+
const { gen: gen2, schema: schema4, data, parentSchema, it } = cxt;
|
|
5790
5790
|
const { opts } = it;
|
|
5791
|
-
const patterns = (0, code_1.allSchemaProperties)(
|
|
5792
|
-
const alwaysValidPatterns = patterns.filter((p) => (0, util_1.alwaysValidSchema)(it,
|
|
5791
|
+
const patterns = (0, code_1.allSchemaProperties)(schema4);
|
|
5792
|
+
const alwaysValidPatterns = patterns.filter((p) => (0, util_1.alwaysValidSchema)(it, schema4[p]));
|
|
5793
5793
|
if (patterns.length === 0 || alwaysValidPatterns.length === patterns.length && (!it.opts.unevaluated || it.props === true)) {
|
|
5794
5794
|
return;
|
|
5795
5795
|
}
|
|
@@ -5857,8 +5857,8 @@ var require_not = __commonJS({
|
|
|
5857
5857
|
schemaType: ["object", "boolean"],
|
|
5858
5858
|
trackErrors: true,
|
|
5859
5859
|
code(cxt) {
|
|
5860
|
-
const { gen: gen2, schema:
|
|
5861
|
-
if ((0, util_1.alwaysValidSchema)(it,
|
|
5860
|
+
const { gen: gen2, schema: schema4, it } = cxt;
|
|
5861
|
+
if ((0, util_1.alwaysValidSchema)(it, schema4)) {
|
|
5862
5862
|
cxt.fail();
|
|
5863
5863
|
return;
|
|
5864
5864
|
}
|
|
@@ -5911,12 +5911,12 @@ var require_oneOf = __commonJS({
|
|
|
5911
5911
|
trackErrors: true,
|
|
5912
5912
|
error: error51,
|
|
5913
5913
|
code(cxt) {
|
|
5914
|
-
const { gen: gen2, schema:
|
|
5915
|
-
if (!Array.isArray(
|
|
5914
|
+
const { gen: gen2, schema: schema4, parentSchema, it } = cxt;
|
|
5915
|
+
if (!Array.isArray(schema4))
|
|
5916
5916
|
throw new Error("ajv implementation error");
|
|
5917
5917
|
if (it.opts.discriminator && parentSchema.discriminator)
|
|
5918
5918
|
return;
|
|
5919
|
-
const schArr =
|
|
5919
|
+
const schArr = schema4;
|
|
5920
5920
|
const valid = gen2.let("valid", false);
|
|
5921
5921
|
const passing = gen2.let("passing", null);
|
|
5922
5922
|
const schValid = gen2.name("_valid");
|
|
@@ -5962,11 +5962,11 @@ var require_allOf = __commonJS({
|
|
|
5962
5962
|
keyword: "allOf",
|
|
5963
5963
|
schemaType: "array",
|
|
5964
5964
|
code(cxt) {
|
|
5965
|
-
const { gen: gen2, schema:
|
|
5966
|
-
if (!Array.isArray(
|
|
5965
|
+
const { gen: gen2, schema: schema4, it } = cxt;
|
|
5966
|
+
if (!Array.isArray(schema4))
|
|
5967
5967
|
throw new Error("ajv implementation error");
|
|
5968
5968
|
const valid = gen2.name("valid");
|
|
5969
|
-
|
|
5969
|
+
schema4.forEach((sch, i2) => {
|
|
5970
5970
|
if ((0, util_1.alwaysValidSchema)(it, sch))
|
|
5971
5971
|
return;
|
|
5972
5972
|
const schCxt = cxt.subschema({ keyword: "allOf", schemaProp: i2 }, valid);
|
|
@@ -6041,8 +6041,8 @@ var require_if = __commonJS({
|
|
|
6041
6041
|
}
|
|
6042
6042
|
};
|
|
6043
6043
|
function hasSchema(it, keyword) {
|
|
6044
|
-
const
|
|
6045
|
-
return
|
|
6044
|
+
const schema4 = it.schema[keyword];
|
|
6045
|
+
return schema4 !== void 0 && !(0, util_1.alwaysValidSchema)(it, schema4);
|
|
6046
6046
|
}
|
|
6047
6047
|
exports.default = def;
|
|
6048
6048
|
}
|
|
@@ -6131,7 +6131,7 @@ var require_format = __commonJS({
|
|
|
6131
6131
|
$data: true,
|
|
6132
6132
|
error: error51,
|
|
6133
6133
|
code(cxt, ruleType) {
|
|
6134
|
-
const { gen: gen2, data, $data, schema:
|
|
6134
|
+
const { gen: gen2, data, $data, schema: schema4, schemaCode, it } = cxt;
|
|
6135
6135
|
const { opts, errSchemaPath, schemaEnv, self } = it;
|
|
6136
6136
|
if (!opts.validateFormats)
|
|
6137
6137
|
return;
|
|
@@ -6161,7 +6161,7 @@ var require_format = __commonJS({
|
|
|
6161
6161
|
}
|
|
6162
6162
|
}
|
|
6163
6163
|
function validateFormat() {
|
|
6164
|
-
const formatDef = self.formats[
|
|
6164
|
+
const formatDef = self.formats[schema4];
|
|
6165
6165
|
if (!formatDef) {
|
|
6166
6166
|
unknownFormat();
|
|
6167
6167
|
return;
|
|
@@ -6178,12 +6178,12 @@ var require_format = __commonJS({
|
|
|
6178
6178
|
}
|
|
6179
6179
|
throw new Error(unknownMsg());
|
|
6180
6180
|
function unknownMsg() {
|
|
6181
|
-
return `unknown format "${
|
|
6181
|
+
return `unknown format "${schema4}" ignored in schema at path "${errSchemaPath}"`;
|
|
6182
6182
|
}
|
|
6183
6183
|
}
|
|
6184
6184
|
function getFormat(fmtDef) {
|
|
6185
|
-
const code = fmtDef instanceof RegExp ? (0, codegen_1.regexpCode)(fmtDef) : opts.code.formats ? (0, codegen_1._)`${opts.code.formats}${(0, codegen_1.getProperty)(
|
|
6186
|
-
const fmt = gen2.scopeValue("formats", { key:
|
|
6185
|
+
const code = fmtDef instanceof RegExp ? (0, codegen_1.regexpCode)(fmtDef) : opts.code.formats ? (0, codegen_1._)`${opts.code.formats}${(0, codegen_1.getProperty)(schema4)}` : void 0;
|
|
6186
|
+
const fmt = gen2.scopeValue("formats", { key: schema4, ref: fmtDef, code });
|
|
6187
6187
|
if (typeof fmtDef == "object" && !(fmtDef instanceof RegExp)) {
|
|
6188
6188
|
return [fmtDef.type || "string", fmtDef.validate, (0, codegen_1._)`${fmt}.validate`];
|
|
6189
6189
|
}
|
|
@@ -6294,15 +6294,15 @@ var require_discriminator = __commonJS({
|
|
|
6294
6294
|
schemaType: "object",
|
|
6295
6295
|
error: error51,
|
|
6296
6296
|
code(cxt) {
|
|
6297
|
-
const { gen: gen2, data, schema:
|
|
6297
|
+
const { gen: gen2, data, schema: schema4, parentSchema, it } = cxt;
|
|
6298
6298
|
const { oneOf } = parentSchema;
|
|
6299
6299
|
if (!it.opts.discriminator) {
|
|
6300
6300
|
throw new Error("discriminator: requires discriminator option");
|
|
6301
6301
|
}
|
|
6302
|
-
const tagName =
|
|
6302
|
+
const tagName = schema4.propertyName;
|
|
6303
6303
|
if (typeof tagName != "string")
|
|
6304
6304
|
throw new Error("discriminator: requires propertyName");
|
|
6305
|
-
if (
|
|
6305
|
+
if (schema4.mapping)
|
|
6306
6306
|
throw new Error("discriminator: mapping is not supported");
|
|
6307
6307
|
if (!oneOf)
|
|
6308
6308
|
throw new Error("discriminator: requires oneOf keyword");
|
|
@@ -6606,6 +6606,66 @@ var require_ajv = __commonJS({
|
|
|
6606
6606
|
}
|
|
6607
6607
|
});
|
|
6608
6608
|
|
|
6609
|
+
// src/cli-error.ts
|
|
6610
|
+
var CliAuthorityError, CliProductionUnavailableError, BrowserOpenError, PUBLIC_RECOVERY_COMMAND, CliRecoveryBlockedError, CliSkillSourceError, CliSkillPublicationError;
|
|
6611
|
+
var init_cli_error = __esm({
|
|
6612
|
+
"src/cli-error.ts"() {
|
|
6613
|
+
"use strict";
|
|
6614
|
+
CliAuthorityError = class extends Error {
|
|
6615
|
+
code = "MCP_CLI_WALLET_MISMATCH";
|
|
6616
|
+
constructor(code = "MCP_CLI_WALLET_MISMATCH") {
|
|
6617
|
+
super(code);
|
|
6618
|
+
this.name = "CliAuthorityError";
|
|
6619
|
+
}
|
|
6620
|
+
};
|
|
6621
|
+
CliProductionUnavailableError = class extends Error {
|
|
6622
|
+
code = "PRODUCTION_NOT_AVAILABLE";
|
|
6623
|
+
constructor() {
|
|
6624
|
+
super("PRODUCTION_NOT_AVAILABLE");
|
|
6625
|
+
this.name = "CliProductionUnavailableError";
|
|
6626
|
+
}
|
|
6627
|
+
};
|
|
6628
|
+
BrowserOpenError = class extends Error {
|
|
6629
|
+
code = "BROWSER_OPEN_FAILED";
|
|
6630
|
+
constructor() {
|
|
6631
|
+
super("BROWSER_OPEN_FAILED");
|
|
6632
|
+
this.name = "BrowserOpenError";
|
|
6633
|
+
}
|
|
6634
|
+
};
|
|
6635
|
+
PUBLIC_RECOVERY_COMMAND = /^(?:finch purchase (?:submit|recover-approval) [0-9a-f-]+(?: --transaction-hash 0x[0-9a-f]{64})?|finch task recover [0-9a-f-]+ (?:publish|award|reclaim)|finch skill recover (?:publication|intent) [0-9a-f]{64})$/u;
|
|
6636
|
+
CliRecoveryBlockedError = class extends Error {
|
|
6637
|
+
code = "CLI_RECOVERY_BLOCKED";
|
|
6638
|
+
recoveryCommands;
|
|
6639
|
+
constructor(recoveryCommands) {
|
|
6640
|
+
if (recoveryCommands.length === 0 || recoveryCommands.some((command) => !PUBLIC_RECOVERY_COMMAND.test(command))) {
|
|
6641
|
+
throw new TypeError("Recovery commands must contain only supported public recovery syntax.");
|
|
6642
|
+
}
|
|
6643
|
+
super("CLI_RECOVERY_BLOCKED");
|
|
6644
|
+
this.name = "CliRecoveryBlockedError";
|
|
6645
|
+
this.recoveryCommands = Object.freeze([...new Set(recoveryCommands)].sort());
|
|
6646
|
+
}
|
|
6647
|
+
};
|
|
6648
|
+
CliSkillSourceError = class extends TypeError {
|
|
6649
|
+
constructor(diagnosticCode, details, message) {
|
|
6650
|
+
super(message);
|
|
6651
|
+
this.diagnosticCode = diagnosticCode;
|
|
6652
|
+
this.details = details;
|
|
6653
|
+
this.name = "CliSkillSourceError";
|
|
6654
|
+
}
|
|
6655
|
+
diagnosticCode;
|
|
6656
|
+
details;
|
|
6657
|
+
};
|
|
6658
|
+
CliSkillPublicationError = class extends Error {
|
|
6659
|
+
constructor(diagnostic, cause) {
|
|
6660
|
+
super(cause instanceof Error ? cause.message : "Skill publication failed.", { cause });
|
|
6661
|
+
this.diagnostic = diagnostic;
|
|
6662
|
+
this.name = "CliSkillPublicationError";
|
|
6663
|
+
}
|
|
6664
|
+
diagnostic;
|
|
6665
|
+
};
|
|
6666
|
+
}
|
|
6667
|
+
});
|
|
6668
|
+
|
|
6609
6669
|
// ../../packages/skill-content/src/crypto.ts
|
|
6610
6670
|
async function sha256Hex(bytes) {
|
|
6611
6671
|
const digest = await crypto.subtle.digest("SHA-256", bytes);
|
|
@@ -10424,8 +10484,31 @@ function assertSkillPath(path2) {
|
|
|
10424
10484
|
throw new RangeError(`Unsafe Skill package path: ${path2}`);
|
|
10425
10485
|
}
|
|
10426
10486
|
}
|
|
10487
|
+
function diagnosticPath(bytes) {
|
|
10488
|
+
try {
|
|
10489
|
+
const path2 = new TextDecoder("utf-8", { fatal: true }).decode(bytes).replace(/\/$/u, "");
|
|
10490
|
+
assertSkillPath(path2);
|
|
10491
|
+
return { path: path2 };
|
|
10492
|
+
} catch {
|
|
10493
|
+
return {};
|
|
10494
|
+
}
|
|
10495
|
+
}
|
|
10427
10496
|
function importZip(bytes, maxEntries = MAX_SKILL_IMPORT_FILES) {
|
|
10428
|
-
|
|
10497
|
+
try {
|
|
10498
|
+
return readZip(bytes, maxEntries);
|
|
10499
|
+
} catch (error51) {
|
|
10500
|
+
if (error51 instanceof SkillZipSymlinkError || error51 instanceof SkillZipInvalidError) throw error51;
|
|
10501
|
+
if (error51 instanceof RangeError || error51 instanceof TypeError) throw new SkillZipInvalidError(error51.message);
|
|
10502
|
+
throw error51;
|
|
10503
|
+
}
|
|
10504
|
+
}
|
|
10505
|
+
function readZip(bytes, maxEntries) {
|
|
10506
|
+
if (bytes.length > MAX_SKILL_IMPORT_BYTES) throw new SkillZipInvalidError(
|
|
10507
|
+
"ZIP import size exceeds the 10 MiB limit.",
|
|
10508
|
+
"archive_too_large",
|
|
10509
|
+
{ actualBytes: bytes.length, maxBytes: MAX_SKILL_IMPORT_BYTES, sizeBasis: "archive" }
|
|
10510
|
+
);
|
|
10511
|
+
if (bytes.length < 22) throw new SkillZipInvalidError("ZIP import is truncated.");
|
|
10429
10512
|
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
10430
10513
|
const u162 = (at) => view.getUint16(at, true);
|
|
10431
10514
|
const u322 = (at) => view.getUint32(at, true);
|
|
@@ -10459,21 +10542,36 @@ function importZip(bytes, maxEntries = MAX_SKILL_IMPORT_FILES) {
|
|
|
10459
10542
|
throw new RangeError("ZIP entry is truncated, encrypted, or uses unsupported compression.");
|
|
10460
10543
|
}
|
|
10461
10544
|
const nameBytes = bytes.subarray(cursor + 46, cursor + 46 + nameSize);
|
|
10462
|
-
if (!(flags & 2048) && nameBytes.some((value) => value > 127)) throw new
|
|
10463
|
-
|
|
10545
|
+
if (!(flags & 2048) && nameBytes.some((value) => value > 127)) throw new SkillZipInvalidError(
|
|
10546
|
+
"ZIP paths must declare UTF-8 for non-ASCII names.",
|
|
10547
|
+
"utf8_flag_missing",
|
|
10548
|
+
diagnosticPath(nameBytes)
|
|
10549
|
+
);
|
|
10550
|
+
let name;
|
|
10551
|
+
try {
|
|
10552
|
+
name = new TextDecoder("utf-8", { fatal: true }).decode(nameBytes);
|
|
10553
|
+
} catch {
|
|
10554
|
+
throw new SkillZipInvalidError("ZIP path bytes must be valid UTF-8.", "filename_encoding_invalid");
|
|
10555
|
+
}
|
|
10464
10556
|
const directory = name.endsWith("/");
|
|
10465
10557
|
const path2 = directory ? name.slice(0, -1) : name;
|
|
10466
10558
|
assertSkillPath(path2);
|
|
10467
10559
|
if (names.has(path2)) throw new RangeError(`Duplicate ZIP path: ${path2}`);
|
|
10468
10560
|
names.add(path2);
|
|
10469
10561
|
const unixType = u322(cursor + 38) >>> 16 & 61440;
|
|
10562
|
+
if (u162(cursor + 4) >>> 8 === 3 && unixType === 40960) throw new SkillZipSymlinkError(path2);
|
|
10470
10563
|
if (u162(cursor + 4) >>> 8 === 3 && unixType !== 0 && unixType !== (directory ? 16384 : 32768)) {
|
|
10471
10564
|
throw new RangeError(`ZIP path must be a regular file or directory, not a symbolic link: ${path2}`);
|
|
10472
10565
|
}
|
|
10473
10566
|
total += expanded;
|
|
10474
|
-
if (total > MAX_SKILL_IMPORT_BYTES
|
|
10475
|
-
|
|
10476
|
-
|
|
10567
|
+
if (total > MAX_SKILL_IMPORT_BYTES) throw new SkillZipInvalidError(
|
|
10568
|
+
"ZIP expanded content exceeds the 10 MiB limit.",
|
|
10569
|
+
"expanded_content_too_large",
|
|
10570
|
+
{ actualBytes: total, maxBytes: MAX_SKILL_IMPORT_BYTES, sizeBasis: "declared_expanded", path: path2 }
|
|
10571
|
+
);
|
|
10572
|
+
if (size5 > MAX_SKILL_IMPORT_BYTES || directory && expanded !== 0) throw new SkillZipInvalidError(
|
|
10573
|
+
"ZIP entry exceeds the compressed size limit or declares directory content."
|
|
10574
|
+
);
|
|
10477
10575
|
const local = u322(cursor + 42);
|
|
10478
10576
|
if (local + 30 > central || u322(local) !== 67324752 || u162(local + 6) !== flags || u162(local + 8) !== method2) {
|
|
10479
10577
|
throw new RangeError("ZIP local header does not match its directory.");
|
|
@@ -10514,7 +10612,11 @@ function importZip(bytes, maxEntries = MAX_SKILL_IMPORT_FILES) {
|
|
|
10514
10612
|
written += chunk.length;
|
|
10515
10613
|
});
|
|
10516
10614
|
for (let at = 0; at < compressed.length; at += 256) {
|
|
10517
|
-
|
|
10615
|
+
try {
|
|
10616
|
+
inflate.push(compressed.subarray(at, at + 256), at + 256 >= compressed.length);
|
|
10617
|
+
} catch {
|
|
10618
|
+
throw new SkillZipInvalidError("ZIP DEFLATE stream is invalid.");
|
|
10619
|
+
}
|
|
10518
10620
|
}
|
|
10519
10621
|
if (written !== entry2.expanded) throw new RangeError("ZIP expanded size does not match its directory.");
|
|
10520
10622
|
}
|
|
@@ -10522,7 +10624,7 @@ function importZip(bytes, maxEntries = MAX_SKILL_IMPORT_FILES) {
|
|
|
10522
10624
|
return { path: entry2.path, content };
|
|
10523
10625
|
});
|
|
10524
10626
|
}
|
|
10525
|
-
var MAX_SKILL_IMPORT_BYTES, MAX_SKILL_IMPORT_FILES;
|
|
10627
|
+
var MAX_SKILL_IMPORT_BYTES, MAX_SKILL_IMPORT_FILES, SkillZipSymlinkError, SkillZipInvalidError;
|
|
10526
10628
|
var init_zip_import = __esm({
|
|
10527
10629
|
"../../packages/skill-content/src/zip-import.ts"() {
|
|
10528
10630
|
"use strict";
|
|
@@ -10530,10 +10632,32 @@ var init_zip_import = __esm({
|
|
|
10530
10632
|
init_zip();
|
|
10531
10633
|
MAX_SKILL_IMPORT_BYTES = 10 * 1024 * 1024;
|
|
10532
10634
|
MAX_SKILL_IMPORT_FILES = 1024;
|
|
10635
|
+
SkillZipSymlinkError = class extends RangeError {
|
|
10636
|
+
constructor(path2) {
|
|
10637
|
+
super(`ZIP path must be a regular file or directory, not a symbolic link: ${path2}`);
|
|
10638
|
+
this.path = path2;
|
|
10639
|
+
this.name = "SkillZipSymlinkError";
|
|
10640
|
+
}
|
|
10641
|
+
path;
|
|
10642
|
+
};
|
|
10643
|
+
SkillZipInvalidError = class extends RangeError {
|
|
10644
|
+
constructor(message, reason = "invalid_archive", details = {}) {
|
|
10645
|
+
super(message);
|
|
10646
|
+
this.reason = reason;
|
|
10647
|
+
this.details = details;
|
|
10648
|
+
this.name = "SkillZipInvalidError";
|
|
10649
|
+
}
|
|
10650
|
+
reason;
|
|
10651
|
+
details;
|
|
10652
|
+
};
|
|
10533
10653
|
}
|
|
10534
10654
|
});
|
|
10535
10655
|
|
|
10536
10656
|
// ../../packages/skill-content/src/packaging.ts
|
|
10657
|
+
function isExcludedSkillPath(path2) {
|
|
10658
|
+
const parts = path2.replaceAll("\\", "/").split("/").filter(Boolean).map((part) => part.toLowerCase());
|
|
10659
|
+
return parts.some((part) => EXCLUDED_PATH_PARTS.has(part)) || EXCLUDED_FILENAMES.some((pattern) => pattern.test(parts.at(-1) ?? ""));
|
|
10660
|
+
}
|
|
10537
10661
|
function filterPublishableFiles(files) {
|
|
10538
10662
|
const included = [];
|
|
10539
10663
|
const excluded = [];
|
|
@@ -10543,9 +10667,7 @@ function filterPublishableFiles(files) {
|
|
|
10543
10667
|
if (names.has(file2.path)) throw new RangeError(`Duplicate Skill package path: ${file2.path}`);
|
|
10544
10668
|
names.add(file2.path);
|
|
10545
10669
|
const parts = file2.path.replaceAll("\\", "/").split("/").filter(Boolean);
|
|
10546
|
-
const
|
|
10547
|
-
const filename = foldedParts.at(-1) ?? "";
|
|
10548
|
-
const blocked = foldedParts.some((part) => EXCLUDED_PATH_PARTS.has(part)) || EXCLUDED_FILENAMES.some((pattern) => pattern.test(filename));
|
|
10670
|
+
const blocked = isExcludedSkillPath(file2.path);
|
|
10549
10671
|
if (blocked) excluded.push(file2.path);
|
|
10550
10672
|
else included.push({ path: parts.join("/"), content: file2.content });
|
|
10551
10673
|
}
|
|
@@ -10561,7 +10683,7 @@ function packageRoot(files) {
|
|
|
10561
10683
|
return files.every((file2) => file2.path.startsWith(prefix)) ? prefix : "";
|
|
10562
10684
|
}
|
|
10563
10685
|
function locatePrimaryDocument(files) {
|
|
10564
|
-
if (files.length === 0) throw new
|
|
10686
|
+
if (files.length === 0) throw new SkillPrimaryDocumentError("The Skill package contains no primary Markdown document.");
|
|
10565
10687
|
const root = packageRoot(files);
|
|
10566
10688
|
const atRoot = new Map(files.filter((file2) => file2.path.startsWith(root) && !file2.path.slice(root.length).includes("/")).map((file2) => [file2.path.slice(root.length), file2]));
|
|
10567
10689
|
for (const candidate of ["SKILL.md", "README.md"]) {
|
|
@@ -10570,7 +10692,7 @@ function locatePrimaryDocument(files) {
|
|
|
10570
10692
|
}
|
|
10571
10693
|
const markdown = [...atRoot.entries()].filter(([name]) => /\.(?:md|markdown)$/iu.test(name));
|
|
10572
10694
|
if (markdown.length === 1) return markdown[0][1];
|
|
10573
|
-
throw new
|
|
10695
|
+
throw new SkillPrimaryDocumentError(
|
|
10574
10696
|
"A Skill must carry one primary Markdown document: add SKILL.md or README.md at the package root, or keep exactly one root-level Markdown file."
|
|
10575
10697
|
);
|
|
10576
10698
|
}
|
|
@@ -10579,7 +10701,7 @@ async function primaryDocument(files) {
|
|
|
10579
10701
|
try {
|
|
10580
10702
|
new TextDecoder("utf-8", { fatal: true }).decode(found.content);
|
|
10581
10703
|
} catch {
|
|
10582
|
-
throw new
|
|
10704
|
+
throw new SkillPrimaryDocumentError(`The primary Markdown document ${found.path} is not valid UTF-8.`);
|
|
10583
10705
|
}
|
|
10584
10706
|
return { path: found.path, mdHash: await sha256Hex(found.content) };
|
|
10585
10707
|
}
|
|
@@ -10592,7 +10714,7 @@ async function archivePackage(files, buildArchive) {
|
|
|
10592
10714
|
async function prepareRootPackage(files, buildArchive) {
|
|
10593
10715
|
return { ...await archivePackage(files, buildArchive), contentKeyBase64: toBase64(generateContentKey()) };
|
|
10594
10716
|
}
|
|
10595
|
-
var EXCLUDED_PATH_PARTS, EXCLUDED_FILENAMES;
|
|
10717
|
+
var EXCLUDED_PATH_PARTS, EXCLUDED_FILENAMES, SkillPrimaryDocumentError;
|
|
10596
10718
|
var init_packaging = __esm({
|
|
10597
10719
|
"../../packages/skill-content/src/packaging.ts"() {
|
|
10598
10720
|
"use strict";
|
|
@@ -10600,6 +10722,8 @@ var init_packaging = __esm({
|
|
|
10600
10722
|
init_zip_import();
|
|
10601
10723
|
EXCLUDED_PATH_PARTS = /* @__PURE__ */ new Set([".git", "node_modules", ".next", ".nuxt", ".svelte-kit", ".cache", ".turbo", "coverage", "dist", "build", "out", "target", "__pycache__", ".venv", "venv", ".aws", ".ssh", "__macosx"]);
|
|
10602
10724
|
EXCLUDED_FILENAMES = [/^\.env($|\.)/u, /^\.(npmrc|pypirc|netrc|ds_store)$/u, /^\._/u, /^id_(rsa|ed25519|ecdsa)$/u, /\.(pem|p12|keystore|key)$/u];
|
|
10725
|
+
SkillPrimaryDocumentError = class extends RangeError {
|
|
10726
|
+
};
|
|
10603
10727
|
}
|
|
10604
10728
|
});
|
|
10605
10729
|
|
|
@@ -10697,7 +10821,7 @@ async function buildSkillRoot(input) {
|
|
|
10697
10821
|
if (contentKey !== null) encrypted[file2.path] = { ciphertext: cid.toString(), plaintextHash: await sha256Hex(file2.content) };
|
|
10698
10822
|
}
|
|
10699
10823
|
if (!md) throw new RangeError("SkillRoot primary document is missing.");
|
|
10700
|
-
const
|
|
10824
|
+
const manifest4 = jsonBytes({
|
|
10701
10825
|
schemaVersion: "1.0",
|
|
10702
10826
|
name: input.name,
|
|
10703
10827
|
skillVersion: String(input.version),
|
|
@@ -10706,7 +10830,7 @@ async function buildSkillRoot(input) {
|
|
|
10706
10830
|
});
|
|
10707
10831
|
const root = {
|
|
10708
10832
|
md,
|
|
10709
|
-
manifest: await put(
|
|
10833
|
+
manifest: await put(manifest4),
|
|
10710
10834
|
entry: { ...md, profile: ENTRY_PROFILE },
|
|
10711
10835
|
...Object.keys(files).length ? { files } : {},
|
|
10712
10836
|
...input.previousHash === void 0 ? {} : { prev: hashCID(input.previousHash, 113) }
|
|
@@ -10720,7 +10844,7 @@ async function buildSkillRoot(input) {
|
|
|
10720
10844
|
const proof = {
|
|
10721
10845
|
scheme: SKILL_ROOT_SCHEME,
|
|
10722
10846
|
root: toBase64(rootBytes),
|
|
10723
|
-
manifest: toBase64(
|
|
10847
|
+
manifest: toBase64(manifest4),
|
|
10724
10848
|
...confidentiality === void 0 ? {} : { confidentiality: toBase64(confidentiality) }
|
|
10725
10849
|
};
|
|
10726
10850
|
const packageHash = await sha256Hex(rootBytes);
|
|
@@ -10757,8 +10881,8 @@ async function verifySkillRootProof(proof, packageHash, version6, previousHash)
|
|
|
10757
10881
|
const paths = Object.keys(refs);
|
|
10758
10882
|
if (paths.length > MAX_SKILL_IMPORT_FILES || paths.some((name) => paths.some((other) => other.startsWith(`${name}/`)))) throw new RangeError("SkillRoot file paths exceed limits or conflict.");
|
|
10759
10883
|
if (!refs[executable.path]?.equals(executable.cid)) throw new RangeError("SkillRoot entrypoint is outside the committed files.");
|
|
10760
|
-
const
|
|
10761
|
-
if (
|
|
10884
|
+
const manifest4 = await authenticatedJSON(proof.manifest, CID.asCID(root.manifest));
|
|
10885
|
+
if (manifest4.schemaVersion !== "1.0" || typeof manifest4.name !== "string" || typeof manifest4.summary !== "string" || manifest4.skillVersion !== String(version6) || manifest4.entrypoint !== executable.path) throw new RangeError("Invalid SkillRoot manifest.");
|
|
10762
10886
|
const hashes = /* @__PURE__ */ Object.create(null);
|
|
10763
10887
|
if (root.confidentiality === void 0) {
|
|
10764
10888
|
if (proof.confidentiality !== void 0) throw new RangeError("Public SkillRoot declares encrypted transport.");
|
|
@@ -10781,8 +10905,8 @@ async function verifySkillRootProof(proof, packageHash, version6, previousHash)
|
|
|
10781
10905
|
mdHash: hashes[md.path],
|
|
10782
10906
|
primaryPath: md.path,
|
|
10783
10907
|
plaintext: root.confidentiality === void 0,
|
|
10784
|
-
name:
|
|
10785
|
-
summary:
|
|
10908
|
+
name: manifest4.name,
|
|
10909
|
+
summary: manifest4.summary,
|
|
10786
10910
|
fileHashes: hashes
|
|
10787
10911
|
};
|
|
10788
10912
|
}
|
|
@@ -11026,8 +11150,8 @@ function buildManifest(entries, presentation, documents) {
|
|
|
11026
11150
|
...normalizedDocuments === void 0 ? {} : { documents: normalizedDocuments }
|
|
11027
11151
|
};
|
|
11028
11152
|
}
|
|
11029
|
-
function serializeManifest(
|
|
11030
|
-
return new TextEncoder().encode(JSON.stringify(
|
|
11153
|
+
function serializeManifest(manifest4) {
|
|
11154
|
+
return new TextEncoder().encode(JSON.stringify(manifest4));
|
|
11031
11155
|
}
|
|
11032
11156
|
function parseManifest(bytes) {
|
|
11033
11157
|
let value;
|
|
@@ -11049,21 +11173,22 @@ function parseManifest(bytes) {
|
|
|
11049
11173
|
return null;
|
|
11050
11174
|
}
|
|
11051
11175
|
}
|
|
11052
|
-
function packageForVersion(
|
|
11053
|
-
return
|
|
11176
|
+
function packageForVersion(manifest4, version6) {
|
|
11177
|
+
return manifest4.versions.find((entry2) => entry2.version === version6) ?? null;
|
|
11054
11178
|
}
|
|
11055
|
-
function withVersion(
|
|
11056
|
-
return buildManifest([...
|
|
11179
|
+
function withVersion(manifest4, entry2) {
|
|
11180
|
+
return buildManifest([...manifest4?.versions ?? [], entry2], manifest4?.presentation, manifest4?.documents);
|
|
11057
11181
|
}
|
|
11058
|
-
function withPresentation(
|
|
11059
|
-
return buildManifest(
|
|
11182
|
+
function withPresentation(manifest4, presentation) {
|
|
11183
|
+
return buildManifest(manifest4.versions, presentation, manifest4.documents);
|
|
11060
11184
|
}
|
|
11061
|
-
var SKILL_MANIFEST_SCHEME, SKILL_DETAIL_KINDS, DETAIL_MEDIA_TYPES, DETAIL_HASH, DETAIL_ASSET_PATH, DETAIL_IPFS_URI, DETAIL_STORAGE_URI, DETAIL_BUCKET_BY_KIND;
|
|
11185
|
+
var MAX_SKILL_MANIFEST_BYTES, SKILL_MANIFEST_SCHEME, SKILL_DETAIL_KINDS, DETAIL_MEDIA_TYPES, DETAIL_HASH, DETAIL_ASSET_PATH, DETAIL_IPFS_URI, DETAIL_STORAGE_URI, DETAIL_BUCKET_BY_KIND;
|
|
11062
11186
|
var init_manifest = __esm({
|
|
11063
11187
|
"../../packages/skill-content/src/manifest.ts"() {
|
|
11064
11188
|
"use strict";
|
|
11065
11189
|
init_static_detail();
|
|
11066
11190
|
init_skill_root();
|
|
11191
|
+
MAX_SKILL_MANIFEST_BYTES = 3 * 1024 * 1024;
|
|
11067
11192
|
SKILL_MANIFEST_SCHEME = "finch-skill-versions-v1";
|
|
11068
11193
|
SKILL_DETAIL_KINDS = ["information", "instruction", "benchmark", "showcase"];
|
|
11069
11194
|
DETAIL_MEDIA_TYPES = /* @__PURE__ */ new Map([
|
|
@@ -11894,7 +12019,7 @@ function decodeAgentCliMcpAuthorizationRequest(requestToken) {
|
|
|
11894
12019
|
}
|
|
11895
12020
|
return requestUrl;
|
|
11896
12021
|
}
|
|
11897
|
-
var booleanSchema, timestampSchema, agentCliMcpAuthorizationRequestTokenPrefix, agentCliMcpAuthorizationRequestMaximumUrlBytes, agentCliMcpAuthorizationRequestMaximumPayloadCharacters, base64UrlAlphabet, AGENT_CLI_MCP_AUTHORIZATION_REQUEST_TOKEN, LOCAL_SIGNING_ABANDON_CONTRACT, localSigningAbandonReceiptSchema, authorizationBase, browserAuthorizationBase, signingStatusSchema, agentCliSigningIntentSchema, browserPublicationSigningIntentSchema, agentCliSigningApproveRequestSchema, agentCliSigningDenyRequestSchema, agentCliSigningDecisionResponseSchema, agentCliCredentialClaimSchema, agentCliCredentialSetupSchema, agentCliCredentialFulfillmentReceiptSchema, CLI_AGENTON_CREDENTIAL_MATERIAL_DOWNLOAD_CONTRACT, AGENT_CLI_V1_HTTP_OPERATIONS, AGENT_CLI_OUTPUT_CONTRACT, agentCliErrorEnvelopeSchema, cliHttpErrorCodes, agentCliLocalErrorCodes, nullableCliStringSchema, cliLocalErrorEnvelopeSchema, AGENT_CLI_RECOVERY_CONTRACT;
|
|
12022
|
+
var booleanSchema, timestampSchema, agentCliMcpAuthorizationRequestTokenPrefix, agentCliMcpAuthorizationRequestMaximumUrlBytes, agentCliMcpAuthorizationRequestMaximumPayloadCharacters, base64UrlAlphabet, AGENT_CLI_MCP_AUTHORIZATION_REQUEST_TOKEN, LOCAL_SIGNING_ABANDON_CONTRACT, localSigningAbandonReceiptSchema, authorizationBase, browserAuthorizationBase, signingStatusSchema, agentCliSigningIntentSchema, browserPublicationSigningIntentSchema, browserPurchaseSigningIntentSchema, agentCliSigningApproveRequestSchema, agentCliSigningDenyRequestSchema, agentCliSigningDecisionResponseSchema, agentCliCredentialClaimSchema, agentCliCredentialSetupSchema, agentCliCredentialFulfillmentReceiptSchema, CLI_AGENTON_CREDENTIAL_MATERIAL_DOWNLOAD_CONTRACT, AGENT_CLI_V1_HTTP_OPERATIONS, AGENT_CLI_OUTPUT_CONTRACT, agentCliErrorEnvelopeSchema, cliHttpErrorCodes, agentCliLocalErrorCodes, nullableCliStringSchema, cliLocalErrorEnvelopeSchema, AGENT_CLI_RECOVERY_CONTRACT;
|
|
11898
12023
|
var init_agent_cli = __esm({
|
|
11899
12024
|
"../../packages/agent-market-contracts/src/v1/agent-cli.ts"() {
|
|
11900
12025
|
"use strict";
|
|
@@ -12003,6 +12128,20 @@ var init_agent_cli = __esm({
|
|
|
12003
12128
|
approvable: booleanSchema,
|
|
12004
12129
|
deniable: booleanSchema
|
|
12005
12130
|
});
|
|
12131
|
+
browserPurchaseSigningIntentSchema = strictObjectSchema({
|
|
12132
|
+
signingRequestId: canonicalUuidSchema,
|
|
12133
|
+
operationId: canonicalUuidSchema,
|
|
12134
|
+
actionKind: { const: "local_purchase" },
|
|
12135
|
+
status: signingStatusSchema,
|
|
12136
|
+
authorization: strictObjectSchema({
|
|
12137
|
+
...browserAuthorizationBase,
|
|
12138
|
+
actionKind: { const: "local_purchase" },
|
|
12139
|
+
authorizedMethod: { const: "finch.agent_market.local_purchase.v1" }
|
|
12140
|
+
}),
|
|
12141
|
+
plan: localPurchasePlanV1Schema,
|
|
12142
|
+
approvable: booleanSchema,
|
|
12143
|
+
deniable: booleanSchema
|
|
12144
|
+
});
|
|
12006
12145
|
agentCliSigningApproveRequestSchema = strictObjectSchema({
|
|
12007
12146
|
signature: { type: "string", pattern: "^0x[0-9a-fA-F]{130}$" }
|
|
12008
12147
|
});
|
|
@@ -12693,9 +12832,6 @@ function parseAgentMarketAuthorization(input) {
|
|
|
12693
12832
|
if (candidate.audience !== "agent_cli" && candidate.audience !== "web" || candidate.nativeValueAtomic !== "0") {
|
|
12694
12833
|
return reject4("Authorization must target agent_cli or web with zero native value.");
|
|
12695
12834
|
}
|
|
12696
|
-
if (candidate.audience === "web" && candidate.actionKind !== "publication") {
|
|
12697
|
-
return reject4("Browser authorization is restricted to publication.");
|
|
12698
|
-
}
|
|
12699
12835
|
if (typeof candidate.walletAddress !== "string" || !EVM_ADDRESS_PATTERN2.test(candidate.walletAddress)) {
|
|
12700
12836
|
return reject4("walletAddress must be a lowercase EVM address.");
|
|
12701
12837
|
}
|
|
@@ -16234,18 +16370,18 @@ var init_operations = __esm({
|
|
|
16234
16370
|
});
|
|
16235
16371
|
|
|
16236
16372
|
// ../../packages/agent-market-contracts/src/v1/mcp.ts
|
|
16237
|
-
function bodyVariants(
|
|
16238
|
-
if (
|
|
16239
|
-
const candidate =
|
|
16373
|
+
function bodyVariants(schema4) {
|
|
16374
|
+
if (schema4 === void 0) return [{}];
|
|
16375
|
+
const candidate = schema4;
|
|
16240
16376
|
if (candidate.oneOf !== void 0) return candidate.oneOf.flatMap((variant) => bodyVariants(variant));
|
|
16241
16377
|
return [candidate];
|
|
16242
16378
|
}
|
|
16243
16379
|
function unionProperties(variants) {
|
|
16244
16380
|
const candidates = /* @__PURE__ */ new Map();
|
|
16245
16381
|
for (const { properties } of variants) {
|
|
16246
|
-
for (const [field,
|
|
16382
|
+
for (const [field, schema4] of Object.entries(properties ?? {})) {
|
|
16247
16383
|
const alternatives = candidates.get(field) ?? /* @__PURE__ */ new Map();
|
|
16248
|
-
alternatives.set(JSON.stringify(
|
|
16384
|
+
alternatives.set(JSON.stringify(schema4), schema4);
|
|
16249
16385
|
candidates.set(field, alternatives);
|
|
16250
16386
|
}
|
|
16251
16387
|
}
|
|
@@ -16351,12 +16487,12 @@ var init_mcp = __esm({
|
|
|
16351
16487
|
});
|
|
16352
16488
|
|
|
16353
16489
|
// ../../packages/agent-market-contracts/src/v1/openapi.ts
|
|
16354
|
-
function mediaTypeContent(contentType,
|
|
16355
|
-
return { content: { [contentType]: { schema:
|
|
16490
|
+
function mediaTypeContent(contentType, schema4) {
|
|
16491
|
+
return { content: { [contentType]: { schema: schema4 } } };
|
|
16356
16492
|
}
|
|
16357
16493
|
function responseHeaderObjects(schemas) {
|
|
16358
16494
|
return Object.fromEntries(
|
|
16359
|
-
Object.entries(schemas).map(([name,
|
|
16495
|
+
Object.entries(schemas).map(([name, schema4]) => [name, { schema: schema4 }])
|
|
16360
16496
|
);
|
|
16361
16497
|
}
|
|
16362
16498
|
function operationParameters(http3) {
|
|
@@ -16366,16 +16502,16 @@ function operationParameters(http3) {
|
|
|
16366
16502
|
required: true,
|
|
16367
16503
|
schema: canonicalUuidSchema
|
|
16368
16504
|
}));
|
|
16369
|
-
for (const [name,
|
|
16505
|
+
for (const [name, schema4] of Object.entries(http3.querySchema?.properties ?? {})) {
|
|
16370
16506
|
parameters.push({
|
|
16371
16507
|
name,
|
|
16372
16508
|
in: "query",
|
|
16373
16509
|
required: http3.querySchema?.required?.includes(name) ?? false,
|
|
16374
|
-
schema:
|
|
16510
|
+
schema: schema4
|
|
16375
16511
|
});
|
|
16376
16512
|
}
|
|
16377
|
-
for (const [name,
|
|
16378
|
-
parameters.push({ name, in: "header", required: true, schema:
|
|
16513
|
+
for (const [name, schema4] of Object.entries(http3.requestHeaders ?? {})) {
|
|
16514
|
+
parameters.push({ name, in: "header", required: true, schema: schema4 });
|
|
16379
16515
|
}
|
|
16380
16516
|
if (http3.idempotencyRequired) parameters.push({ $ref: "#/components/parameters/IdempotencyKey" });
|
|
16381
16517
|
if (http3.ifMatchRequired) parameters.push({ $ref: "#/components/parameters/IfMatch" });
|
|
@@ -16909,24 +17045,24 @@ var init_schemas = __esm({
|
|
|
16909
17045
|
function operation2(value) {
|
|
16910
17046
|
return Object.freeze(value);
|
|
16911
17047
|
}
|
|
16912
|
-
function schemaFields(
|
|
16913
|
-
if (
|
|
16914
|
-
const shape =
|
|
17048
|
+
function schemaFields(schema4) {
|
|
17049
|
+
if (schema4 === void 0) return {};
|
|
17050
|
+
const shape = schema4;
|
|
16915
17051
|
return Object.freeze(Object.assign(
|
|
16916
17052
|
{},
|
|
16917
17053
|
shape.properties ?? {},
|
|
16918
17054
|
...(shape.oneOf ?? []).map((variant) => schemaFields(variant))
|
|
16919
17055
|
));
|
|
16920
17056
|
}
|
|
16921
|
-
function requiredFields(
|
|
16922
|
-
return
|
|
17057
|
+
function requiredFields(schema4) {
|
|
17058
|
+
return schema4?.required ?? [];
|
|
16923
17059
|
}
|
|
16924
17060
|
function inputSchema(fields, required4, body) {
|
|
16925
|
-
const
|
|
17061
|
+
const schema4 = strictObjectSchema2(fields, required4);
|
|
16926
17062
|
const variants = body?.oneOf ?? [];
|
|
16927
|
-
if (variants.length === 0) return
|
|
17063
|
+
if (variants.length === 0) return schema4;
|
|
16928
17064
|
return Object.freeze({
|
|
16929
|
-
...
|
|
17065
|
+
...schema4,
|
|
16930
17066
|
oneOf: variants.map((variant) => Object.freeze({ required: requiredFields(variant) }))
|
|
16931
17067
|
});
|
|
16932
17068
|
}
|
|
@@ -17229,8 +17365,8 @@ function mergeDefs(...defs) {
|
|
|
17229
17365
|
}
|
|
17230
17366
|
return Object.defineProperties({}, mergedDescriptors);
|
|
17231
17367
|
}
|
|
17232
|
-
function cloneDef(
|
|
17233
|
-
return mergeDefs(
|
|
17368
|
+
function cloneDef(schema4) {
|
|
17369
|
+
return mergeDefs(schema4._zod.def);
|
|
17234
17370
|
}
|
|
17235
17371
|
function getElementAtPath(obj, path2) {
|
|
17236
17372
|
if (!path2)
|
|
@@ -17371,14 +17507,14 @@ function optionalKeys(shape) {
|
|
|
17371
17507
|
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
|
|
17372
17508
|
});
|
|
17373
17509
|
}
|
|
17374
|
-
function pick(
|
|
17375
|
-
const currDef =
|
|
17510
|
+
function pick(schema4, mask) {
|
|
17511
|
+
const currDef = schema4._zod.def;
|
|
17376
17512
|
const checks = currDef.checks;
|
|
17377
17513
|
const hasChecks = checks && checks.length > 0;
|
|
17378
17514
|
if (hasChecks) {
|
|
17379
17515
|
throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
17380
17516
|
}
|
|
17381
|
-
const def = mergeDefs(
|
|
17517
|
+
const def = mergeDefs(schema4._zod.def, {
|
|
17382
17518
|
get shape() {
|
|
17383
17519
|
const newShape = {};
|
|
17384
17520
|
for (const key in mask) {
|
|
@@ -17394,18 +17530,18 @@ function pick(schema3, mask) {
|
|
|
17394
17530
|
},
|
|
17395
17531
|
checks: []
|
|
17396
17532
|
});
|
|
17397
|
-
return clone(
|
|
17533
|
+
return clone(schema4, def);
|
|
17398
17534
|
}
|
|
17399
|
-
function omit(
|
|
17400
|
-
const currDef =
|
|
17535
|
+
function omit(schema4, mask) {
|
|
17536
|
+
const currDef = schema4._zod.def;
|
|
17401
17537
|
const checks = currDef.checks;
|
|
17402
17538
|
const hasChecks = checks && checks.length > 0;
|
|
17403
17539
|
if (hasChecks) {
|
|
17404
17540
|
throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
17405
17541
|
}
|
|
17406
|
-
const def = mergeDefs(
|
|
17542
|
+
const def = mergeDefs(schema4._zod.def, {
|
|
17407
17543
|
get shape() {
|
|
17408
|
-
const newShape = { ...
|
|
17544
|
+
const newShape = { ...schema4._zod.def.shape };
|
|
17409
17545
|
for (const key in mask) {
|
|
17410
17546
|
if (!(key in currDef.shape)) {
|
|
17411
17547
|
throw new Error(`Unrecognized key: "${key}"`);
|
|
@@ -17419,43 +17555,43 @@ function omit(schema3, mask) {
|
|
|
17419
17555
|
},
|
|
17420
17556
|
checks: []
|
|
17421
17557
|
});
|
|
17422
|
-
return clone(
|
|
17558
|
+
return clone(schema4, def);
|
|
17423
17559
|
}
|
|
17424
|
-
function extend(
|
|
17560
|
+
function extend(schema4, shape) {
|
|
17425
17561
|
if (!isPlainObject(shape)) {
|
|
17426
17562
|
throw new Error("Invalid input to extend: expected a plain object");
|
|
17427
17563
|
}
|
|
17428
|
-
const checks =
|
|
17564
|
+
const checks = schema4._zod.def.checks;
|
|
17429
17565
|
const hasChecks = checks && checks.length > 0;
|
|
17430
17566
|
if (hasChecks) {
|
|
17431
|
-
const existingShape =
|
|
17567
|
+
const existingShape = schema4._zod.def.shape;
|
|
17432
17568
|
for (const key in shape) {
|
|
17433
17569
|
if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) {
|
|
17434
17570
|
throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
17435
17571
|
}
|
|
17436
17572
|
}
|
|
17437
17573
|
}
|
|
17438
|
-
const def = mergeDefs(
|
|
17574
|
+
const def = mergeDefs(schema4._zod.def, {
|
|
17439
17575
|
get shape() {
|
|
17440
|
-
const _shape = { ...
|
|
17576
|
+
const _shape = { ...schema4._zod.def.shape, ...shape };
|
|
17441
17577
|
assignProp(this, "shape", _shape);
|
|
17442
17578
|
return _shape;
|
|
17443
17579
|
}
|
|
17444
17580
|
});
|
|
17445
|
-
return clone(
|
|
17581
|
+
return clone(schema4, def);
|
|
17446
17582
|
}
|
|
17447
|
-
function safeExtend(
|
|
17583
|
+
function safeExtend(schema4, shape) {
|
|
17448
17584
|
if (!isPlainObject(shape)) {
|
|
17449
17585
|
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
17450
17586
|
}
|
|
17451
|
-
const def = mergeDefs(
|
|
17587
|
+
const def = mergeDefs(schema4._zod.def, {
|
|
17452
17588
|
get shape() {
|
|
17453
|
-
const _shape = { ...
|
|
17589
|
+
const _shape = { ...schema4._zod.def.shape, ...shape };
|
|
17454
17590
|
assignProp(this, "shape", _shape);
|
|
17455
17591
|
return _shape;
|
|
17456
17592
|
}
|
|
17457
17593
|
});
|
|
17458
|
-
return clone(
|
|
17594
|
+
return clone(schema4, def);
|
|
17459
17595
|
}
|
|
17460
17596
|
function merge(a, b) {
|
|
17461
17597
|
if (a._zod.def.checks?.length) {
|
|
@@ -17474,16 +17610,16 @@ function merge(a, b) {
|
|
|
17474
17610
|
});
|
|
17475
17611
|
return clone(a, def);
|
|
17476
17612
|
}
|
|
17477
|
-
function partial(Class2,
|
|
17478
|
-
const currDef =
|
|
17613
|
+
function partial(Class2, schema4, mask) {
|
|
17614
|
+
const currDef = schema4._zod.def;
|
|
17479
17615
|
const checks = currDef.checks;
|
|
17480
17616
|
const hasChecks = checks && checks.length > 0;
|
|
17481
17617
|
if (hasChecks) {
|
|
17482
17618
|
throw new Error(".partial() cannot be used on object schemas containing refinements");
|
|
17483
17619
|
}
|
|
17484
|
-
const def = mergeDefs(
|
|
17620
|
+
const def = mergeDefs(schema4._zod.def, {
|
|
17485
17621
|
get shape() {
|
|
17486
|
-
const oldShape =
|
|
17622
|
+
const oldShape = schema4._zod.def.shape;
|
|
17487
17623
|
const shape = { ...oldShape };
|
|
17488
17624
|
if (mask) {
|
|
17489
17625
|
for (const key in mask) {
|
|
@@ -17510,12 +17646,12 @@ function partial(Class2, schema3, mask) {
|
|
|
17510
17646
|
},
|
|
17511
17647
|
checks: []
|
|
17512
17648
|
});
|
|
17513
|
-
return clone(
|
|
17649
|
+
return clone(schema4, def);
|
|
17514
17650
|
}
|
|
17515
|
-
function required(Class2,
|
|
17516
|
-
const def = mergeDefs(
|
|
17651
|
+
function required(Class2, schema4, mask) {
|
|
17652
|
+
const def = mergeDefs(schema4._zod.def, {
|
|
17517
17653
|
get shape() {
|
|
17518
|
-
const oldShape =
|
|
17654
|
+
const oldShape = schema4._zod.def.shape;
|
|
17519
17655
|
const shape = { ...oldShape };
|
|
17520
17656
|
if (mask) {
|
|
17521
17657
|
for (const key in mask) {
|
|
@@ -17541,7 +17677,7 @@ function required(Class2, schema3, mask) {
|
|
|
17541
17677
|
return shape;
|
|
17542
17678
|
}
|
|
17543
17679
|
});
|
|
17544
|
-
return clone(
|
|
17680
|
+
return clone(schema4, def);
|
|
17545
17681
|
}
|
|
17546
17682
|
function aborted(x2, startIndex = 0) {
|
|
17547
17683
|
if (x2.aborted === true)
|
|
@@ -17921,9 +18057,9 @@ var init_parse = __esm({
|
|
|
17921
18057
|
init_core();
|
|
17922
18058
|
init_errors2();
|
|
17923
18059
|
init_util();
|
|
17924
|
-
_parse = (_Err) => (
|
|
18060
|
+
_parse = (_Err) => (schema4, value, _ctx, _params) => {
|
|
17925
18061
|
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
17926
|
-
const result2 =
|
|
18062
|
+
const result2 = schema4._zod.run({ value, issues: [] }, ctx);
|
|
17927
18063
|
if (result2 instanceof Promise) {
|
|
17928
18064
|
throw new $ZodAsyncError();
|
|
17929
18065
|
}
|
|
@@ -17935,9 +18071,9 @@ var init_parse = __esm({
|
|
|
17935
18071
|
return result2.value;
|
|
17936
18072
|
};
|
|
17937
18073
|
parse = /* @__PURE__ */ _parse($ZodRealError);
|
|
17938
|
-
_parseAsync = (_Err) => async (
|
|
18074
|
+
_parseAsync = (_Err) => async (schema4, value, _ctx, params) => {
|
|
17939
18075
|
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
17940
|
-
let result2 =
|
|
18076
|
+
let result2 = schema4._zod.run({ value, issues: [] }, ctx);
|
|
17941
18077
|
if (result2 instanceof Promise)
|
|
17942
18078
|
result2 = await result2;
|
|
17943
18079
|
if (result2.issues.length) {
|
|
@@ -17948,9 +18084,9 @@ var init_parse = __esm({
|
|
|
17948
18084
|
return result2.value;
|
|
17949
18085
|
};
|
|
17950
18086
|
parseAsync = /* @__PURE__ */ _parseAsync($ZodRealError);
|
|
17951
|
-
_safeParse = (_Err) => (
|
|
18087
|
+
_safeParse = (_Err) => (schema4, value, _ctx) => {
|
|
17952
18088
|
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
17953
|
-
const result2 =
|
|
18089
|
+
const result2 = schema4._zod.run({ value, issues: [] }, ctx);
|
|
17954
18090
|
if (result2 instanceof Promise) {
|
|
17955
18091
|
throw new $ZodAsyncError();
|
|
17956
18092
|
}
|
|
@@ -17960,9 +18096,9 @@ var init_parse = __esm({
|
|
|
17960
18096
|
} : { success: true, data: result2.value };
|
|
17961
18097
|
};
|
|
17962
18098
|
safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
17963
|
-
_safeParseAsync = (_Err) => async (
|
|
18099
|
+
_safeParseAsync = (_Err) => async (schema4, value, _ctx) => {
|
|
17964
18100
|
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
17965
|
-
let result2 =
|
|
18101
|
+
let result2 = schema4._zod.run({ value, issues: [] }, ctx);
|
|
17966
18102
|
if (result2 instanceof Promise)
|
|
17967
18103
|
result2 = await result2;
|
|
17968
18104
|
return result2.issues.length ? {
|
|
@@ -17971,40 +18107,40 @@ var init_parse = __esm({
|
|
|
17971
18107
|
} : { success: true, data: result2.value };
|
|
17972
18108
|
};
|
|
17973
18109
|
safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
17974
|
-
_encode = (_Err) => (
|
|
18110
|
+
_encode = (_Err) => (schema4, value, _ctx) => {
|
|
17975
18111
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
17976
|
-
return _parse(_Err)(
|
|
18112
|
+
return _parse(_Err)(schema4, value, ctx);
|
|
17977
18113
|
};
|
|
17978
18114
|
encode5 = /* @__PURE__ */ _encode($ZodRealError);
|
|
17979
|
-
_decode = (_Err) => (
|
|
17980
|
-
return _parse(_Err)(
|
|
18115
|
+
_decode = (_Err) => (schema4, value, _ctx) => {
|
|
18116
|
+
return _parse(_Err)(schema4, value, _ctx);
|
|
17981
18117
|
};
|
|
17982
18118
|
decode7 = /* @__PURE__ */ _decode($ZodRealError);
|
|
17983
|
-
_encodeAsync = (_Err) => async (
|
|
18119
|
+
_encodeAsync = (_Err) => async (schema4, value, _ctx) => {
|
|
17984
18120
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
17985
|
-
return _parseAsync(_Err)(
|
|
18121
|
+
return _parseAsync(_Err)(schema4, value, ctx);
|
|
17986
18122
|
};
|
|
17987
18123
|
encodeAsync = /* @__PURE__ */ _encodeAsync($ZodRealError);
|
|
17988
|
-
_decodeAsync = (_Err) => async (
|
|
17989
|
-
return _parseAsync(_Err)(
|
|
18124
|
+
_decodeAsync = (_Err) => async (schema4, value, _ctx) => {
|
|
18125
|
+
return _parseAsync(_Err)(schema4, value, _ctx);
|
|
17990
18126
|
};
|
|
17991
18127
|
decodeAsync = /* @__PURE__ */ _decodeAsync($ZodRealError);
|
|
17992
|
-
_safeEncode = (_Err) => (
|
|
18128
|
+
_safeEncode = (_Err) => (schema4, value, _ctx) => {
|
|
17993
18129
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
17994
|
-
return _safeParse(_Err)(
|
|
18130
|
+
return _safeParse(_Err)(schema4, value, ctx);
|
|
17995
18131
|
};
|
|
17996
18132
|
safeEncode = /* @__PURE__ */ _safeEncode($ZodRealError);
|
|
17997
|
-
_safeDecode = (_Err) => (
|
|
17998
|
-
return _safeParse(_Err)(
|
|
18133
|
+
_safeDecode = (_Err) => (schema4, value, _ctx) => {
|
|
18134
|
+
return _safeParse(_Err)(schema4, value, _ctx);
|
|
17999
18135
|
};
|
|
18000
18136
|
safeDecode = /* @__PURE__ */ _safeDecode($ZodRealError);
|
|
18001
|
-
_safeEncodeAsync = (_Err) => async (
|
|
18137
|
+
_safeEncodeAsync = (_Err) => async (schema4, value, _ctx) => {
|
|
18002
18138
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
18003
|
-
return _safeParseAsync(_Err)(
|
|
18139
|
+
return _safeParseAsync(_Err)(schema4, value, ctx);
|
|
18004
18140
|
};
|
|
18005
18141
|
safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync($ZodRealError);
|
|
18006
|
-
_safeDecodeAsync = (_Err) => async (
|
|
18007
|
-
return _safeParseAsync(_Err)(
|
|
18142
|
+
_safeDecodeAsync = (_Err) => async (schema4, value, _ctx) => {
|
|
18143
|
+
return _safeParseAsync(_Err)(schema4, value, _ctx);
|
|
18008
18144
|
};
|
|
18009
18145
|
safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
|
|
18010
18146
|
}
|
|
@@ -19893,9 +20029,9 @@ var init_schemas2 = __esm({
|
|
|
19893
20029
|
for (const key of normalized.keys) {
|
|
19894
20030
|
const id = ids[key];
|
|
19895
20031
|
const k = esc(key);
|
|
19896
|
-
const
|
|
19897
|
-
const isOptionalIn =
|
|
19898
|
-
const isOptionalOut =
|
|
20032
|
+
const schema4 = shape[key];
|
|
20033
|
+
const isOptionalIn = schema4?._zod?.optin === "optional";
|
|
20034
|
+
const isOptionalOut = schema4?._zod?.optout === "optional";
|
|
19899
20035
|
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
19900
20036
|
if (isOptionalIn && isOptionalOut) {
|
|
19901
20037
|
doc.write(`
|
|
@@ -27225,11 +27361,11 @@ var init_registries = __esm({
|
|
|
27225
27361
|
this._map = /* @__PURE__ */ new WeakMap();
|
|
27226
27362
|
this._idmap = /* @__PURE__ */ new Map();
|
|
27227
27363
|
}
|
|
27228
|
-
add(
|
|
27364
|
+
add(schema4, ..._meta) {
|
|
27229
27365
|
const meta3 = _meta[0];
|
|
27230
|
-
this._map.set(
|
|
27366
|
+
this._map.set(schema4, meta3);
|
|
27231
27367
|
if (meta3 && typeof meta3 === "object" && "id" in meta3) {
|
|
27232
|
-
this._idmap.set(meta3.id,
|
|
27368
|
+
this._idmap.set(meta3.id, schema4);
|
|
27233
27369
|
}
|
|
27234
27370
|
return this;
|
|
27235
27371
|
}
|
|
@@ -27238,26 +27374,26 @@ var init_registries = __esm({
|
|
|
27238
27374
|
this._idmap = /* @__PURE__ */ new Map();
|
|
27239
27375
|
return this;
|
|
27240
27376
|
}
|
|
27241
|
-
remove(
|
|
27242
|
-
const meta3 = this._map.get(
|
|
27377
|
+
remove(schema4) {
|
|
27378
|
+
const meta3 = this._map.get(schema4);
|
|
27243
27379
|
if (meta3 && typeof meta3 === "object" && "id" in meta3) {
|
|
27244
27380
|
this._idmap.delete(meta3.id);
|
|
27245
27381
|
}
|
|
27246
|
-
this._map.delete(
|
|
27382
|
+
this._map.delete(schema4);
|
|
27247
27383
|
return this;
|
|
27248
27384
|
}
|
|
27249
|
-
get(
|
|
27250
|
-
const p =
|
|
27385
|
+
get(schema4) {
|
|
27386
|
+
const p = schema4._zod.parent;
|
|
27251
27387
|
if (p) {
|
|
27252
27388
|
const pm = { ...this.get(p) ?? {} };
|
|
27253
27389
|
delete pm.id;
|
|
27254
|
-
const f = { ...pm, ...this._map.get(
|
|
27390
|
+
const f = { ...pm, ...this._map.get(schema4) };
|
|
27255
27391
|
return Object.keys(f).length ? f : void 0;
|
|
27256
27392
|
}
|
|
27257
|
-
return this._map.get(
|
|
27393
|
+
return this._map.get(schema4);
|
|
27258
27394
|
}
|
|
27259
|
-
has(
|
|
27260
|
-
return this._map.has(
|
|
27395
|
+
has(schema4) {
|
|
27396
|
+
return this._map.has(schema4);
|
|
27261
27397
|
}
|
|
27262
27398
|
};
|
|
27263
27399
|
(_a3 = globalThis).__zod_globalRegistry ?? (_a3.__zod_globalRegistry = registry());
|
|
@@ -27902,11 +28038,11 @@ function _endsWith(suffix, params) {
|
|
|
27902
28038
|
});
|
|
27903
28039
|
}
|
|
27904
28040
|
// @__NO_SIDE_EFFECTS__
|
|
27905
|
-
function _property(property,
|
|
28041
|
+
function _property(property, schema4, params) {
|
|
27906
28042
|
return new $ZodCheckProperty({
|
|
27907
28043
|
check: "property",
|
|
27908
28044
|
property,
|
|
27909
|
-
schema:
|
|
28045
|
+
schema: schema4,
|
|
27910
28046
|
...normalizeParams(params)
|
|
27911
28047
|
});
|
|
27912
28048
|
}
|
|
@@ -28154,23 +28290,23 @@ function _promise(Class2, innerType) {
|
|
|
28154
28290
|
function _custom(Class2, fn, _params) {
|
|
28155
28291
|
const norm = normalizeParams(_params);
|
|
28156
28292
|
norm.abort ?? (norm.abort = true);
|
|
28157
|
-
const
|
|
28293
|
+
const schema4 = new Class2({
|
|
28158
28294
|
type: "custom",
|
|
28159
28295
|
check: "custom",
|
|
28160
28296
|
fn,
|
|
28161
28297
|
...norm
|
|
28162
28298
|
});
|
|
28163
|
-
return
|
|
28299
|
+
return schema4;
|
|
28164
28300
|
}
|
|
28165
28301
|
// @__NO_SIDE_EFFECTS__
|
|
28166
28302
|
function _refine(Class2, fn, _params) {
|
|
28167
|
-
const
|
|
28303
|
+
const schema4 = new Class2({
|
|
28168
28304
|
type: "custom",
|
|
28169
28305
|
check: "custom",
|
|
28170
28306
|
fn,
|
|
28171
28307
|
...normalizeParams(_params)
|
|
28172
28308
|
});
|
|
28173
|
-
return
|
|
28309
|
+
return schema4;
|
|
28174
28310
|
}
|
|
28175
28311
|
// @__NO_SIDE_EFFECTS__
|
|
28176
28312
|
function _superRefine(fn, params) {
|
|
@@ -28335,40 +28471,40 @@ function initializeContext(params) {
|
|
|
28335
28471
|
external: params?.external ?? void 0
|
|
28336
28472
|
};
|
|
28337
28473
|
}
|
|
28338
|
-
function process2(
|
|
28474
|
+
function process2(schema4, ctx, _params = { path: [], schemaPath: [] }) {
|
|
28339
28475
|
var _a4;
|
|
28340
|
-
const def =
|
|
28341
|
-
const seen = ctx.seen.get(
|
|
28476
|
+
const def = schema4._zod.def;
|
|
28477
|
+
const seen = ctx.seen.get(schema4);
|
|
28342
28478
|
if (seen) {
|
|
28343
28479
|
seen.count++;
|
|
28344
|
-
const isCycle = _params.schemaPath.includes(
|
|
28480
|
+
const isCycle = _params.schemaPath.includes(schema4);
|
|
28345
28481
|
if (isCycle) {
|
|
28346
28482
|
seen.cycle = _params.path;
|
|
28347
28483
|
}
|
|
28348
28484
|
return seen.schema;
|
|
28349
28485
|
}
|
|
28350
28486
|
const result2 = { schema: {}, count: 1, cycle: void 0, path: _params.path };
|
|
28351
|
-
ctx.seen.set(
|
|
28352
|
-
const overrideSchema =
|
|
28487
|
+
ctx.seen.set(schema4, result2);
|
|
28488
|
+
const overrideSchema = schema4._zod.toJSONSchema?.();
|
|
28353
28489
|
if (overrideSchema) {
|
|
28354
28490
|
result2.schema = overrideSchema;
|
|
28355
28491
|
} else {
|
|
28356
28492
|
const params = {
|
|
28357
28493
|
..._params,
|
|
28358
|
-
schemaPath: [..._params.schemaPath,
|
|
28494
|
+
schemaPath: [..._params.schemaPath, schema4],
|
|
28359
28495
|
path: _params.path
|
|
28360
28496
|
};
|
|
28361
|
-
if (
|
|
28362
|
-
|
|
28497
|
+
if (schema4._zod.processJSONSchema) {
|
|
28498
|
+
schema4._zod.processJSONSchema(ctx, result2.schema, params);
|
|
28363
28499
|
} else {
|
|
28364
28500
|
const _json = result2.schema;
|
|
28365
28501
|
const processor = ctx.processors[def.type];
|
|
28366
28502
|
if (!processor) {
|
|
28367
28503
|
throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
|
|
28368
28504
|
}
|
|
28369
|
-
processor(
|
|
28505
|
+
processor(schema4, ctx, _json, params);
|
|
28370
28506
|
}
|
|
28371
|
-
const parent =
|
|
28507
|
+
const parent = schema4._zod.parent;
|
|
28372
28508
|
if (parent) {
|
|
28373
28509
|
if (!result2.ref)
|
|
28374
28510
|
result2.ref = parent;
|
|
@@ -28376,21 +28512,21 @@ function process2(schema3, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
28376
28512
|
ctx.seen.get(parent).isParent = true;
|
|
28377
28513
|
}
|
|
28378
28514
|
}
|
|
28379
|
-
const meta3 = ctx.metadataRegistry.get(
|
|
28515
|
+
const meta3 = ctx.metadataRegistry.get(schema4);
|
|
28380
28516
|
if (meta3)
|
|
28381
28517
|
Object.assign(result2.schema, meta3);
|
|
28382
|
-
if (ctx.io === "input" && isTransforming(
|
|
28518
|
+
if (ctx.io === "input" && isTransforming(schema4)) {
|
|
28383
28519
|
delete result2.schema.examples;
|
|
28384
28520
|
delete result2.schema.default;
|
|
28385
28521
|
}
|
|
28386
28522
|
if (ctx.io === "input" && "_prefault" in result2.schema)
|
|
28387
28523
|
(_a4 = result2.schema).default ?? (_a4.default = result2.schema._prefault);
|
|
28388
28524
|
delete result2.schema._prefault;
|
|
28389
|
-
const _result = ctx.seen.get(
|
|
28525
|
+
const _result = ctx.seen.get(schema4);
|
|
28390
28526
|
return _result.schema;
|
|
28391
28527
|
}
|
|
28392
|
-
function extractDefs(ctx,
|
|
28393
|
-
const root = ctx.seen.get(
|
|
28528
|
+
function extractDefs(ctx, schema4) {
|
|
28529
|
+
const root = ctx.seen.get(schema4);
|
|
28394
28530
|
if (!root)
|
|
28395
28531
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
28396
28532
|
const idToSchema = /* @__PURE__ */ new Map();
|
|
@@ -28433,11 +28569,11 @@ function extractDefs(ctx, schema3) {
|
|
|
28433
28569
|
seen.def = { ...seen.schema };
|
|
28434
28570
|
if (defId)
|
|
28435
28571
|
seen.defId = defId;
|
|
28436
|
-
const
|
|
28437
|
-
for (const key in
|
|
28438
|
-
delete
|
|
28572
|
+
const schema5 = seen.schema;
|
|
28573
|
+
for (const key in schema5) {
|
|
28574
|
+
delete schema5[key];
|
|
28439
28575
|
}
|
|
28440
|
-
|
|
28576
|
+
schema5.$ref = ref;
|
|
28441
28577
|
};
|
|
28442
28578
|
if (ctx.cycles === "throw") {
|
|
28443
28579
|
for (const entry2 of ctx.seen.entries()) {
|
|
@@ -28451,13 +28587,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
28451
28587
|
}
|
|
28452
28588
|
for (const entry2 of ctx.seen.entries()) {
|
|
28453
28589
|
const seen = entry2[1];
|
|
28454
|
-
if (
|
|
28590
|
+
if (schema4 === entry2[0]) {
|
|
28455
28591
|
extractToDef(entry2);
|
|
28456
28592
|
continue;
|
|
28457
28593
|
}
|
|
28458
28594
|
if (ctx.external) {
|
|
28459
28595
|
const ext = ctx.external.registry.get(entry2[0])?.id;
|
|
28460
|
-
if (
|
|
28596
|
+
if (schema4 !== entry2[0] && ext) {
|
|
28461
28597
|
extractToDef(entry2);
|
|
28462
28598
|
continue;
|
|
28463
28599
|
}
|
|
@@ -28479,16 +28615,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
28479
28615
|
}
|
|
28480
28616
|
}
|
|
28481
28617
|
}
|
|
28482
|
-
function finalize(ctx,
|
|
28483
|
-
const root = ctx.seen.get(
|
|
28618
|
+
function finalize(ctx, schema4) {
|
|
28619
|
+
const root = ctx.seen.get(schema4);
|
|
28484
28620
|
if (!root)
|
|
28485
28621
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
28486
28622
|
const flattenRef = (zodSchema) => {
|
|
28487
28623
|
const seen = ctx.seen.get(zodSchema);
|
|
28488
28624
|
if (seen.ref === null)
|
|
28489
28625
|
return;
|
|
28490
|
-
const
|
|
28491
|
-
const _cached = { ...
|
|
28626
|
+
const schema5 = seen.def ?? seen.schema;
|
|
28627
|
+
const _cached = { ...schema5 };
|
|
28492
28628
|
const ref = seen.ref;
|
|
28493
28629
|
seen.ref = null;
|
|
28494
28630
|
if (ref) {
|
|
@@ -28496,28 +28632,28 @@ function finalize(ctx, schema3) {
|
|
|
28496
28632
|
const refSeen = ctx.seen.get(ref);
|
|
28497
28633
|
const refSchema = refSeen.schema;
|
|
28498
28634
|
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
|
28499
|
-
|
|
28500
|
-
|
|
28635
|
+
schema5.allOf = schema5.allOf ?? [];
|
|
28636
|
+
schema5.allOf.push(refSchema);
|
|
28501
28637
|
} else {
|
|
28502
|
-
Object.assign(
|
|
28638
|
+
Object.assign(schema5, refSchema);
|
|
28503
28639
|
}
|
|
28504
|
-
Object.assign(
|
|
28640
|
+
Object.assign(schema5, _cached);
|
|
28505
28641
|
const isParentRef = zodSchema._zod.parent === ref;
|
|
28506
28642
|
if (isParentRef) {
|
|
28507
|
-
for (const key in
|
|
28643
|
+
for (const key in schema5) {
|
|
28508
28644
|
if (key === "$ref" || key === "allOf")
|
|
28509
28645
|
continue;
|
|
28510
28646
|
if (!(key in _cached)) {
|
|
28511
|
-
delete
|
|
28647
|
+
delete schema5[key];
|
|
28512
28648
|
}
|
|
28513
28649
|
}
|
|
28514
28650
|
}
|
|
28515
28651
|
if (refSchema.$ref && refSeen.def) {
|
|
28516
|
-
for (const key in
|
|
28652
|
+
for (const key in schema5) {
|
|
28517
28653
|
if (key === "$ref" || key === "allOf")
|
|
28518
28654
|
continue;
|
|
28519
|
-
if (key in refSeen.def && JSON.stringify(
|
|
28520
|
-
delete
|
|
28655
|
+
if (key in refSeen.def && JSON.stringify(schema5[key]) === JSON.stringify(refSeen.def[key])) {
|
|
28656
|
+
delete schema5[key];
|
|
28521
28657
|
}
|
|
28522
28658
|
}
|
|
28523
28659
|
}
|
|
@@ -28527,13 +28663,13 @@ function finalize(ctx, schema3) {
|
|
|
28527
28663
|
flattenRef(parent);
|
|
28528
28664
|
const parentSeen = ctx.seen.get(parent);
|
|
28529
28665
|
if (parentSeen?.schema.$ref) {
|
|
28530
|
-
|
|
28666
|
+
schema5.$ref = parentSeen.schema.$ref;
|
|
28531
28667
|
if (parentSeen.def) {
|
|
28532
|
-
for (const key in
|
|
28668
|
+
for (const key in schema5) {
|
|
28533
28669
|
if (key === "$ref" || key === "allOf")
|
|
28534
28670
|
continue;
|
|
28535
|
-
if (key in parentSeen.def && JSON.stringify(
|
|
28536
|
-
delete
|
|
28671
|
+
if (key in parentSeen.def && JSON.stringify(schema5[key]) === JSON.stringify(parentSeen.def[key])) {
|
|
28672
|
+
delete schema5[key];
|
|
28537
28673
|
}
|
|
28538
28674
|
}
|
|
28539
28675
|
}
|
|
@@ -28541,7 +28677,7 @@ function finalize(ctx, schema3) {
|
|
|
28541
28677
|
}
|
|
28542
28678
|
ctx.override({
|
|
28543
28679
|
zodSchema,
|
|
28544
|
-
jsonSchema:
|
|
28680
|
+
jsonSchema: schema5,
|
|
28545
28681
|
path: seen.path ?? []
|
|
28546
28682
|
});
|
|
28547
28683
|
};
|
|
@@ -28559,13 +28695,13 @@ function finalize(ctx, schema3) {
|
|
|
28559
28695
|
} else {
|
|
28560
28696
|
}
|
|
28561
28697
|
if (ctx.external?.uri) {
|
|
28562
|
-
const id = ctx.external.registry.get(
|
|
28698
|
+
const id = ctx.external.registry.get(schema4)?.id;
|
|
28563
28699
|
if (!id)
|
|
28564
28700
|
throw new Error("Schema is missing an `id` property");
|
|
28565
28701
|
result2.$id = ctx.external.uri(id);
|
|
28566
28702
|
}
|
|
28567
28703
|
Object.assign(result2, root.def ?? root.schema);
|
|
28568
|
-
const rootMetaId = ctx.metadataRegistry.get(
|
|
28704
|
+
const rootMetaId = ctx.metadataRegistry.get(schema4)?.id;
|
|
28569
28705
|
if (rootMetaId !== void 0 && result2.id === rootMetaId)
|
|
28570
28706
|
delete result2.id;
|
|
28571
28707
|
const defs = ctx.external?.defs ?? {};
|
|
@@ -28591,10 +28727,10 @@ function finalize(ctx, schema3) {
|
|
|
28591
28727
|
const finalized = JSON.parse(JSON.stringify(result2));
|
|
28592
28728
|
Object.defineProperty(finalized, "~standard", {
|
|
28593
28729
|
value: {
|
|
28594
|
-
...
|
|
28730
|
+
...schema4["~standard"],
|
|
28595
28731
|
jsonSchema: {
|
|
28596
|
-
input: createStandardJSONSchemaMethod(
|
|
28597
|
-
output: createStandardJSONSchemaMethod(
|
|
28732
|
+
input: createStandardJSONSchemaMethod(schema4, "input", ctx.processors),
|
|
28733
|
+
output: createStandardJSONSchemaMethod(schema4, "output", ctx.processors)
|
|
28598
28734
|
}
|
|
28599
28735
|
},
|
|
28600
28736
|
enumerable: false,
|
|
@@ -28662,18 +28798,18 @@ var createToJSONSchemaMethod, createStandardJSONSchemaMethod;
|
|
|
28662
28798
|
var init_to_json_schema = __esm({
|
|
28663
28799
|
"../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/to-json-schema.js"() {
|
|
28664
28800
|
init_registries();
|
|
28665
|
-
createToJSONSchemaMethod = (
|
|
28801
|
+
createToJSONSchemaMethod = (schema4, processors = {}) => (params) => {
|
|
28666
28802
|
const ctx = initializeContext({ ...params, processors });
|
|
28667
|
-
process2(
|
|
28668
|
-
extractDefs(ctx,
|
|
28669
|
-
return finalize(ctx,
|
|
28803
|
+
process2(schema4, ctx);
|
|
28804
|
+
extractDefs(ctx, schema4);
|
|
28805
|
+
return finalize(ctx, schema4);
|
|
28670
28806
|
};
|
|
28671
|
-
createStandardJSONSchemaMethod = (
|
|
28807
|
+
createStandardJSONSchemaMethod = (schema4, io, processors = {}) => (params) => {
|
|
28672
28808
|
const { libraryOptions, target } = params ?? {};
|
|
28673
28809
|
const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
|
|
28674
|
-
process2(
|
|
28675
|
-
extractDefs(ctx,
|
|
28676
|
-
return finalize(ctx,
|
|
28810
|
+
process2(schema4, ctx);
|
|
28811
|
+
extractDefs(ctx, schema4);
|
|
28812
|
+
return finalize(ctx, schema4);
|
|
28677
28813
|
};
|
|
28678
28814
|
}
|
|
28679
28815
|
});
|
|
@@ -28685,8 +28821,8 @@ function toJSONSchema(input, params) {
|
|
|
28685
28821
|
const ctx2 = initializeContext({ ...params, processors: allProcessors });
|
|
28686
28822
|
const defs = {};
|
|
28687
28823
|
for (const entry2 of registry2._idmap.entries()) {
|
|
28688
|
-
const [_,
|
|
28689
|
-
process2(
|
|
28824
|
+
const [_, schema4] = entry2;
|
|
28825
|
+
process2(schema4, ctx2);
|
|
28690
28826
|
}
|
|
28691
28827
|
const schemas = {};
|
|
28692
28828
|
const external = {
|
|
@@ -28696,9 +28832,9 @@ function toJSONSchema(input, params) {
|
|
|
28696
28832
|
};
|
|
28697
28833
|
ctx2.external = external;
|
|
28698
28834
|
for (const entry2 of registry2._idmap.entries()) {
|
|
28699
|
-
const [key,
|
|
28700
|
-
extractDefs(ctx2,
|
|
28701
|
-
schemas[key] = finalize(ctx2,
|
|
28835
|
+
const [key, schema4] = entry2;
|
|
28836
|
+
extractDefs(ctx2, schema4);
|
|
28837
|
+
schemas[key] = finalize(ctx2, schema4);
|
|
28702
28838
|
}
|
|
28703
28839
|
if (Object.keys(defs).length > 0) {
|
|
28704
28840
|
const defsSegment = ctx2.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
@@ -28726,10 +28862,10 @@ var init_json_schema_processors = __esm({
|
|
|
28726
28862
|
regex: ""
|
|
28727
28863
|
// do not set
|
|
28728
28864
|
};
|
|
28729
|
-
stringProcessor = (
|
|
28865
|
+
stringProcessor = (schema4, ctx, _json, _params) => {
|
|
28730
28866
|
const json2 = _json;
|
|
28731
28867
|
json2.type = "string";
|
|
28732
|
-
const { minimum, maximum, format: format3, patterns, contentEncoding } =
|
|
28868
|
+
const { minimum, maximum, format: format3, patterns, contentEncoding } = schema4._zod.bag;
|
|
28733
28869
|
if (typeof minimum === "number")
|
|
28734
28870
|
json2.minLength = minimum;
|
|
28735
28871
|
if (typeof maximum === "number")
|
|
@@ -28758,9 +28894,9 @@ var init_json_schema_processors = __esm({
|
|
|
28758
28894
|
}
|
|
28759
28895
|
}
|
|
28760
28896
|
};
|
|
28761
|
-
numberProcessor = (
|
|
28897
|
+
numberProcessor = (schema4, ctx, _json, _params) => {
|
|
28762
28898
|
const json2 = _json;
|
|
28763
|
-
const { minimum, maximum, format: format3, multipleOf, exclusiveMaximum, exclusiveMinimum } =
|
|
28899
|
+
const { minimum, maximum, format: format3, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema4._zod.bag;
|
|
28764
28900
|
if (typeof format3 === "string" && format3.includes("int"))
|
|
28765
28901
|
json2.type = "integer";
|
|
28766
28902
|
else
|
|
@@ -28835,8 +28971,8 @@ var init_json_schema_processors = __esm({
|
|
|
28835
28971
|
throw new Error("Date cannot be represented in JSON Schema");
|
|
28836
28972
|
}
|
|
28837
28973
|
};
|
|
28838
|
-
enumProcessor = (
|
|
28839
|
-
const def =
|
|
28974
|
+
enumProcessor = (schema4, _ctx, json2, _params) => {
|
|
28975
|
+
const def = schema4._zod.def;
|
|
28840
28976
|
const values = getEnumValues(def.entries);
|
|
28841
28977
|
if (values.every((v) => typeof v === "number"))
|
|
28842
28978
|
json2.type = "number";
|
|
@@ -28844,8 +28980,8 @@ var init_json_schema_processors = __esm({
|
|
|
28844
28980
|
json2.type = "string";
|
|
28845
28981
|
json2.enum = values;
|
|
28846
28982
|
};
|
|
28847
|
-
literalProcessor = (
|
|
28848
|
-
const def =
|
|
28983
|
+
literalProcessor = (schema4, ctx, json2, _params) => {
|
|
28984
|
+
const def = schema4._zod.def;
|
|
28849
28985
|
const vals = [];
|
|
28850
28986
|
for (const val of def.values) {
|
|
28851
28987
|
if (val === void 0) {
|
|
@@ -28889,22 +29025,22 @@ var init_json_schema_processors = __esm({
|
|
|
28889
29025
|
throw new Error("NaN cannot be represented in JSON Schema");
|
|
28890
29026
|
}
|
|
28891
29027
|
};
|
|
28892
|
-
templateLiteralProcessor = (
|
|
29028
|
+
templateLiteralProcessor = (schema4, _ctx, json2, _params) => {
|
|
28893
29029
|
const _json = json2;
|
|
28894
|
-
const pattern =
|
|
29030
|
+
const pattern = schema4._zod.pattern;
|
|
28895
29031
|
if (!pattern)
|
|
28896
29032
|
throw new Error("Pattern not found in template literal");
|
|
28897
29033
|
_json.type = "string";
|
|
28898
29034
|
_json.pattern = pattern.source;
|
|
28899
29035
|
};
|
|
28900
|
-
fileProcessor = (
|
|
29036
|
+
fileProcessor = (schema4, _ctx, json2, _params) => {
|
|
28901
29037
|
const _json = json2;
|
|
28902
29038
|
const file2 = {
|
|
28903
29039
|
type: "string",
|
|
28904
29040
|
format: "binary",
|
|
28905
29041
|
contentEncoding: "binary"
|
|
28906
29042
|
};
|
|
28907
|
-
const { minimum, maximum, mime } =
|
|
29043
|
+
const { minimum, maximum, mime } = schema4._zod.bag;
|
|
28908
29044
|
if (minimum !== void 0)
|
|
28909
29045
|
file2.minLength = minimum;
|
|
28910
29046
|
if (maximum !== void 0)
|
|
@@ -28949,10 +29085,10 @@ var init_json_schema_processors = __esm({
|
|
|
28949
29085
|
throw new Error("Set cannot be represented in JSON Schema");
|
|
28950
29086
|
}
|
|
28951
29087
|
};
|
|
28952
|
-
arrayProcessor = (
|
|
29088
|
+
arrayProcessor = (schema4, ctx, _json, params) => {
|
|
28953
29089
|
const json2 = _json;
|
|
28954
|
-
const def =
|
|
28955
|
-
const { minimum, maximum } =
|
|
29090
|
+
const def = schema4._zod.def;
|
|
29091
|
+
const { minimum, maximum } = schema4._zod.bag;
|
|
28956
29092
|
if (typeof minimum === "number")
|
|
28957
29093
|
json2.minItems = minimum;
|
|
28958
29094
|
if (typeof maximum === "number")
|
|
@@ -28963,9 +29099,9 @@ var init_json_schema_processors = __esm({
|
|
|
28963
29099
|
path: [...params.path, "items"]
|
|
28964
29100
|
});
|
|
28965
29101
|
};
|
|
28966
|
-
objectProcessor = (
|
|
29102
|
+
objectProcessor = (schema4, ctx, _json, params) => {
|
|
28967
29103
|
const json2 = _json;
|
|
28968
|
-
const def =
|
|
29104
|
+
const def = schema4._zod.def;
|
|
28969
29105
|
json2.type = "object";
|
|
28970
29106
|
json2.properties = {};
|
|
28971
29107
|
const shape = def.shape;
|
|
@@ -28999,8 +29135,8 @@ var init_json_schema_processors = __esm({
|
|
|
28999
29135
|
});
|
|
29000
29136
|
}
|
|
29001
29137
|
};
|
|
29002
|
-
unionProcessor = (
|
|
29003
|
-
const def =
|
|
29138
|
+
unionProcessor = (schema4, ctx, json2, params) => {
|
|
29139
|
+
const def = schema4._zod.def;
|
|
29004
29140
|
const isExclusive = def.inclusive === false;
|
|
29005
29141
|
const options = def.options.map((x2, i2) => process2(x2, ctx, {
|
|
29006
29142
|
...params,
|
|
@@ -29012,8 +29148,8 @@ var init_json_schema_processors = __esm({
|
|
|
29012
29148
|
json2.anyOf = options;
|
|
29013
29149
|
}
|
|
29014
29150
|
};
|
|
29015
|
-
intersectionProcessor = (
|
|
29016
|
-
const def =
|
|
29151
|
+
intersectionProcessor = (schema4, ctx, json2, params) => {
|
|
29152
|
+
const def = schema4._zod.def;
|
|
29017
29153
|
const a = process2(def.left, ctx, {
|
|
29018
29154
|
...params,
|
|
29019
29155
|
path: [...params.path, "allOf", 0]
|
|
@@ -29029,9 +29165,9 @@ var init_json_schema_processors = __esm({
|
|
|
29029
29165
|
];
|
|
29030
29166
|
json2.allOf = allOf;
|
|
29031
29167
|
};
|
|
29032
|
-
tupleProcessor = (
|
|
29168
|
+
tupleProcessor = (schema4, ctx, _json, params) => {
|
|
29033
29169
|
const json2 = _json;
|
|
29034
|
-
const def =
|
|
29170
|
+
const def = schema4._zod.def;
|
|
29035
29171
|
json2.type = "array";
|
|
29036
29172
|
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
29037
29173
|
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
@@ -29065,15 +29201,15 @@ var init_json_schema_processors = __esm({
|
|
|
29065
29201
|
json2.additionalItems = rest;
|
|
29066
29202
|
}
|
|
29067
29203
|
}
|
|
29068
|
-
const { minimum, maximum } =
|
|
29204
|
+
const { minimum, maximum } = schema4._zod.bag;
|
|
29069
29205
|
if (typeof minimum === "number")
|
|
29070
29206
|
json2.minItems = minimum;
|
|
29071
29207
|
if (typeof maximum === "number")
|
|
29072
29208
|
json2.maxItems = maximum;
|
|
29073
29209
|
};
|
|
29074
|
-
recordProcessor = (
|
|
29210
|
+
recordProcessor = (schema4, ctx, _json, params) => {
|
|
29075
29211
|
const json2 = _json;
|
|
29076
|
-
const def =
|
|
29212
|
+
const def = schema4._zod.def;
|
|
29077
29213
|
json2.type = "object";
|
|
29078
29214
|
const keyType = def.keyType;
|
|
29079
29215
|
const keyBag = keyType._zod.bag;
|
|
@@ -29107,10 +29243,10 @@ var init_json_schema_processors = __esm({
|
|
|
29107
29243
|
}
|
|
29108
29244
|
}
|
|
29109
29245
|
};
|
|
29110
|
-
nullableProcessor = (
|
|
29111
|
-
const def =
|
|
29246
|
+
nullableProcessor = (schema4, ctx, json2, params) => {
|
|
29247
|
+
const def = schema4._zod.def;
|
|
29112
29248
|
const inner = process2(def.innerType, ctx, params);
|
|
29113
|
-
const seen = ctx.seen.get(
|
|
29249
|
+
const seen = ctx.seen.get(schema4);
|
|
29114
29250
|
if (ctx.target === "openapi-3.0") {
|
|
29115
29251
|
seen.ref = def.innerType;
|
|
29116
29252
|
json2.nullable = true;
|
|
@@ -29118,31 +29254,31 @@ var init_json_schema_processors = __esm({
|
|
|
29118
29254
|
json2.anyOf = [inner, { type: "null" }];
|
|
29119
29255
|
}
|
|
29120
29256
|
};
|
|
29121
|
-
nonoptionalProcessor = (
|
|
29122
|
-
const def =
|
|
29257
|
+
nonoptionalProcessor = (schema4, ctx, _json, params) => {
|
|
29258
|
+
const def = schema4._zod.def;
|
|
29123
29259
|
process2(def.innerType, ctx, params);
|
|
29124
|
-
const seen = ctx.seen.get(
|
|
29260
|
+
const seen = ctx.seen.get(schema4);
|
|
29125
29261
|
seen.ref = def.innerType;
|
|
29126
29262
|
};
|
|
29127
|
-
defaultProcessor = (
|
|
29128
|
-
const def =
|
|
29263
|
+
defaultProcessor = (schema4, ctx, json2, params) => {
|
|
29264
|
+
const def = schema4._zod.def;
|
|
29129
29265
|
process2(def.innerType, ctx, params);
|
|
29130
|
-
const seen = ctx.seen.get(
|
|
29266
|
+
const seen = ctx.seen.get(schema4);
|
|
29131
29267
|
seen.ref = def.innerType;
|
|
29132
29268
|
json2.default = JSON.parse(JSON.stringify(def.defaultValue));
|
|
29133
29269
|
};
|
|
29134
|
-
prefaultProcessor = (
|
|
29135
|
-
const def =
|
|
29270
|
+
prefaultProcessor = (schema4, ctx, json2, params) => {
|
|
29271
|
+
const def = schema4._zod.def;
|
|
29136
29272
|
process2(def.innerType, ctx, params);
|
|
29137
|
-
const seen = ctx.seen.get(
|
|
29273
|
+
const seen = ctx.seen.get(schema4);
|
|
29138
29274
|
seen.ref = def.innerType;
|
|
29139
29275
|
if (ctx.io === "input")
|
|
29140
29276
|
json2._prefault = JSON.parse(JSON.stringify(def.defaultValue));
|
|
29141
29277
|
};
|
|
29142
|
-
catchProcessor = (
|
|
29143
|
-
const def =
|
|
29278
|
+
catchProcessor = (schema4, ctx, json2, params) => {
|
|
29279
|
+
const def = schema4._zod.def;
|
|
29144
29280
|
process2(def.innerType, ctx, params);
|
|
29145
|
-
const seen = ctx.seen.get(
|
|
29281
|
+
const seen = ctx.seen.get(schema4);
|
|
29146
29282
|
seen.ref = def.innerType;
|
|
29147
29283
|
let catchValue;
|
|
29148
29284
|
try {
|
|
@@ -29152,37 +29288,37 @@ var init_json_schema_processors = __esm({
|
|
|
29152
29288
|
}
|
|
29153
29289
|
json2.default = catchValue;
|
|
29154
29290
|
};
|
|
29155
|
-
pipeProcessor = (
|
|
29156
|
-
const def =
|
|
29291
|
+
pipeProcessor = (schema4, ctx, _json, params) => {
|
|
29292
|
+
const def = schema4._zod.def;
|
|
29157
29293
|
const inIsTransform = def.in._zod.traits.has("$ZodTransform");
|
|
29158
29294
|
const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
|
|
29159
29295
|
process2(innerType, ctx, params);
|
|
29160
|
-
const seen = ctx.seen.get(
|
|
29296
|
+
const seen = ctx.seen.get(schema4);
|
|
29161
29297
|
seen.ref = innerType;
|
|
29162
29298
|
};
|
|
29163
|
-
readonlyProcessor = (
|
|
29164
|
-
const def =
|
|
29299
|
+
readonlyProcessor = (schema4, ctx, json2, params) => {
|
|
29300
|
+
const def = schema4._zod.def;
|
|
29165
29301
|
process2(def.innerType, ctx, params);
|
|
29166
|
-
const seen = ctx.seen.get(
|
|
29302
|
+
const seen = ctx.seen.get(schema4);
|
|
29167
29303
|
seen.ref = def.innerType;
|
|
29168
29304
|
json2.readOnly = true;
|
|
29169
29305
|
};
|
|
29170
|
-
promiseProcessor = (
|
|
29171
|
-
const def =
|
|
29306
|
+
promiseProcessor = (schema4, ctx, _json, params) => {
|
|
29307
|
+
const def = schema4._zod.def;
|
|
29172
29308
|
process2(def.innerType, ctx, params);
|
|
29173
|
-
const seen = ctx.seen.get(
|
|
29309
|
+
const seen = ctx.seen.get(schema4);
|
|
29174
29310
|
seen.ref = def.innerType;
|
|
29175
29311
|
};
|
|
29176
|
-
optionalProcessor = (
|
|
29177
|
-
const def =
|
|
29312
|
+
optionalProcessor = (schema4, ctx, _json, params) => {
|
|
29313
|
+
const def = schema4._zod.def;
|
|
29178
29314
|
process2(def.innerType, ctx, params);
|
|
29179
|
-
const seen = ctx.seen.get(
|
|
29315
|
+
const seen = ctx.seen.get(schema4);
|
|
29180
29316
|
seen.ref = def.innerType;
|
|
29181
29317
|
};
|
|
29182
|
-
lazyProcessor = (
|
|
29183
|
-
const innerType =
|
|
29318
|
+
lazyProcessor = (schema4, ctx, _json, params) => {
|
|
29319
|
+
const innerType = schema4._zod.innerType;
|
|
29184
29320
|
process2(innerType, ctx, params);
|
|
29185
|
-
const seen = ctx.seen.get(
|
|
29321
|
+
const seen = ctx.seen.get(schema4);
|
|
29186
29322
|
seen.ref = innerType;
|
|
29187
29323
|
};
|
|
29188
29324
|
allProcessors = {
|
|
@@ -29286,14 +29422,14 @@ var init_json_schema_generator = __esm({
|
|
|
29286
29422
|
* Process a schema to prepare it for JSON Schema generation.
|
|
29287
29423
|
* This must be called before emit().
|
|
29288
29424
|
*/
|
|
29289
|
-
process(
|
|
29290
|
-
return process2(
|
|
29425
|
+
process(schema4, _params = { path: [], schemaPath: [] }) {
|
|
29426
|
+
return process2(schema4, this.ctx, _params);
|
|
29291
29427
|
}
|
|
29292
29428
|
/**
|
|
29293
29429
|
* Emit the final JSON Schema after processing.
|
|
29294
29430
|
* Must call process() first.
|
|
29295
29431
|
*/
|
|
29296
|
-
emit(
|
|
29432
|
+
emit(schema4, _params) {
|
|
29297
29433
|
if (_params) {
|
|
29298
29434
|
if (_params.cycles)
|
|
29299
29435
|
this.ctx.cycles = _params.cycles;
|
|
@@ -29302,8 +29438,8 @@ var init_json_schema_generator = __esm({
|
|
|
29302
29438
|
if (_params.external)
|
|
29303
29439
|
this.ctx.external = _params.external;
|
|
29304
29440
|
}
|
|
29305
|
-
extractDefs(this.ctx,
|
|
29306
|
-
const result2 = finalize(this.ctx,
|
|
29441
|
+
extractDefs(this.ctx, schema4);
|
|
29442
|
+
const result2 = finalize(this.ctx, schema4);
|
|
29307
29443
|
const { "~standard": _, ...plainResult } = result2;
|
|
29308
29444
|
return plainResult;
|
|
29309
29445
|
}
|
|
@@ -30132,8 +30268,8 @@ function date3(params) {
|
|
|
30132
30268
|
function array(element, params) {
|
|
30133
30269
|
return _array(ZodArray, element, params);
|
|
30134
30270
|
}
|
|
30135
|
-
function keyof(
|
|
30136
|
-
const shape =
|
|
30271
|
+
function keyof(schema4) {
|
|
30272
|
+
const shape = schema4._zod.def.shape;
|
|
30137
30273
|
return _enum2(Object.keys(shape));
|
|
30138
30274
|
}
|
|
30139
30275
|
function object(shape, params) {
|
|
@@ -30448,11 +30584,11 @@ function json(params) {
|
|
|
30448
30584
|
});
|
|
30449
30585
|
return jsonSchema;
|
|
30450
30586
|
}
|
|
30451
|
-
function preprocess(fn,
|
|
30587
|
+
function preprocess(fn, schema4) {
|
|
30452
30588
|
return new ZodPreprocess({
|
|
30453
30589
|
type: "pipe",
|
|
30454
30590
|
in: transform(fn),
|
|
30455
|
-
out:
|
|
30591
|
+
out: schema4
|
|
30456
30592
|
});
|
|
30457
30593
|
}
|
|
30458
30594
|
var _installedGroups, ZodType, _ZodString, ZodString, ZodStringFormat, ZodEmail, ZodGUID, ZodUUID, ZodURL, ZodEmoji, ZodNanoID, ZodCUID, ZodCUID2, ZodULID, ZodXID, ZodKSUID, ZodIPv4, ZodMAC, ZodIPv6, ZodCIDRv4, ZodCIDRv6, ZodBase64, ZodBase64URL, ZodE164, ZodJWT, ZodCustomStringFormat, ZodNumber, ZodNumberFormat, ZodBoolean, ZodBigInt, ZodBigIntFormat, ZodSymbol, ZodUndefined, ZodNull, ZodAny, ZodUnknown, ZodNever, ZodVoid, ZodDate, ZodArray, ZodObject, ZodUnion, ZodXor, ZodDiscriminatedUnion, ZodIntersection, ZodTuple, ZodRecord, ZodMap, ZodSet, ZodEnum, ZodLiteral, ZodFile, ZodTransform, ZodOptional, ZodExactOptional, ZodNullable, ZodDefault, ZodPrefault, ZodNonOptional, ZodSuccess, ZodCatch, ZodNaN, ZodPipe, ZodCodec, ZodPreprocess, ZodReadonly, ZodTemplateLiteral, ZodLazy, ZodPromise, ZodFunction, ZodCustom, describe2, meta2, stringbool;
|
|
@@ -31276,8 +31412,8 @@ var init_compat = __esm({
|
|
|
31276
31412
|
});
|
|
31277
31413
|
|
|
31278
31414
|
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/from-json-schema.js
|
|
31279
|
-
function detectVersion(
|
|
31280
|
-
const $schema =
|
|
31415
|
+
function detectVersion(schema4, defaultTarget) {
|
|
31416
|
+
const $schema = schema4.$schema;
|
|
31281
31417
|
if ($schema === "https://json-schema.org/draft/2020-12/schema") {
|
|
31282
31418
|
return "draft-2020-12";
|
|
31283
31419
|
}
|
|
@@ -31307,27 +31443,27 @@ function resolveRef(ref, ctx) {
|
|
|
31307
31443
|
}
|
|
31308
31444
|
throw new Error(`Reference not found: ${ref}`);
|
|
31309
31445
|
}
|
|
31310
|
-
function convertBaseSchema(
|
|
31311
|
-
if (
|
|
31312
|
-
if (typeof
|
|
31446
|
+
function convertBaseSchema(schema4, ctx) {
|
|
31447
|
+
if (schema4.not !== void 0) {
|
|
31448
|
+
if (typeof schema4.not === "object" && Object.keys(schema4.not).length === 0) {
|
|
31313
31449
|
return z.never();
|
|
31314
31450
|
}
|
|
31315
31451
|
throw new Error("not is not supported in Zod (except { not: {} } for never)");
|
|
31316
31452
|
}
|
|
31317
|
-
if (
|
|
31453
|
+
if (schema4.unevaluatedItems !== void 0) {
|
|
31318
31454
|
throw new Error("unevaluatedItems is not supported");
|
|
31319
31455
|
}
|
|
31320
|
-
if (
|
|
31456
|
+
if (schema4.unevaluatedProperties !== void 0) {
|
|
31321
31457
|
throw new Error("unevaluatedProperties is not supported");
|
|
31322
31458
|
}
|
|
31323
|
-
if (
|
|
31459
|
+
if (schema4.if !== void 0 || schema4.then !== void 0 || schema4.else !== void 0) {
|
|
31324
31460
|
throw new Error("Conditional schemas (if/then/else) are not supported");
|
|
31325
31461
|
}
|
|
31326
|
-
if (
|
|
31462
|
+
if (schema4.dependentSchemas !== void 0 || schema4.dependentRequired !== void 0) {
|
|
31327
31463
|
throw new Error("dependentSchemas and dependentRequired are not supported");
|
|
31328
31464
|
}
|
|
31329
|
-
if (
|
|
31330
|
-
const refPath =
|
|
31465
|
+
if (schema4.$ref) {
|
|
31466
|
+
const refPath = schema4.$ref;
|
|
31331
31467
|
if (ctx.refs.has(refPath)) {
|
|
31332
31468
|
return ctx.refs.get(refPath);
|
|
31333
31469
|
}
|
|
@@ -31346,9 +31482,9 @@ function convertBaseSchema(schema3, ctx) {
|
|
|
31346
31482
|
ctx.processing.delete(refPath);
|
|
31347
31483
|
return zodSchema2;
|
|
31348
31484
|
}
|
|
31349
|
-
if (
|
|
31350
|
-
const enumValues =
|
|
31351
|
-
if (ctx.version === "openapi-3.0" &&
|
|
31485
|
+
if (schema4.enum !== void 0) {
|
|
31486
|
+
const enumValues = schema4.enum;
|
|
31487
|
+
if (ctx.version === "openapi-3.0" && schema4.nullable === true && enumValues.length === 1 && enumValues[0] === null) {
|
|
31352
31488
|
return z.null();
|
|
31353
31489
|
}
|
|
31354
31490
|
if (enumValues.length === 0) {
|
|
@@ -31366,13 +31502,13 @@ function convertBaseSchema(schema3, ctx) {
|
|
|
31366
31502
|
}
|
|
31367
31503
|
return z.union([literalSchemas[0], literalSchemas[1], ...literalSchemas.slice(2)]);
|
|
31368
31504
|
}
|
|
31369
|
-
if (
|
|
31370
|
-
return z.literal(
|
|
31505
|
+
if (schema4.const !== void 0) {
|
|
31506
|
+
return z.literal(schema4.const);
|
|
31371
31507
|
}
|
|
31372
|
-
const type =
|
|
31508
|
+
const type = schema4.type;
|
|
31373
31509
|
if (Array.isArray(type)) {
|
|
31374
31510
|
const typeSchemas = type.map((t) => {
|
|
31375
|
-
const typeSchema = { ...
|
|
31511
|
+
const typeSchema = { ...schema4, type: t };
|
|
31376
31512
|
return convertBaseSchema(typeSchema, ctx);
|
|
31377
31513
|
});
|
|
31378
31514
|
if (typeSchemas.length === 0) {
|
|
@@ -31390,8 +31526,8 @@ function convertBaseSchema(schema3, ctx) {
|
|
|
31390
31526
|
switch (type) {
|
|
31391
31527
|
case "string": {
|
|
31392
31528
|
let stringSchema = z.string();
|
|
31393
|
-
if (
|
|
31394
|
-
const format3 =
|
|
31529
|
+
if (schema4.format) {
|
|
31530
|
+
const format3 = schema4.format;
|
|
31395
31531
|
if (format3 === "email") {
|
|
31396
31532
|
stringSchema = stringSchema.check(z.email());
|
|
31397
31533
|
} else if (format3 === "uri" || format3 === "uri-reference") {
|
|
@@ -31440,14 +31576,14 @@ function convertBaseSchema(schema3, ctx) {
|
|
|
31440
31576
|
stringSchema = stringSchema.check(z.ksuid());
|
|
31441
31577
|
}
|
|
31442
31578
|
}
|
|
31443
|
-
if (typeof
|
|
31444
|
-
stringSchema = stringSchema.min(
|
|
31579
|
+
if (typeof schema4.minLength === "number") {
|
|
31580
|
+
stringSchema = stringSchema.min(schema4.minLength);
|
|
31445
31581
|
}
|
|
31446
|
-
if (typeof
|
|
31447
|
-
stringSchema = stringSchema.max(
|
|
31582
|
+
if (typeof schema4.maxLength === "number") {
|
|
31583
|
+
stringSchema = stringSchema.max(schema4.maxLength);
|
|
31448
31584
|
}
|
|
31449
|
-
if (
|
|
31450
|
-
stringSchema = stringSchema.regex(new RegExp(
|
|
31585
|
+
if (schema4.pattern) {
|
|
31586
|
+
stringSchema = stringSchema.regex(new RegExp(schema4.pattern));
|
|
31451
31587
|
}
|
|
31452
31588
|
zodSchema = stringSchema;
|
|
31453
31589
|
break;
|
|
@@ -31455,24 +31591,24 @@ function convertBaseSchema(schema3, ctx) {
|
|
|
31455
31591
|
case "number":
|
|
31456
31592
|
case "integer": {
|
|
31457
31593
|
let numberSchema = type === "integer" ? z.number().int() : z.number();
|
|
31458
|
-
if (typeof
|
|
31459
|
-
numberSchema = numberSchema.min(
|
|
31594
|
+
if (typeof schema4.minimum === "number") {
|
|
31595
|
+
numberSchema = numberSchema.min(schema4.minimum);
|
|
31460
31596
|
}
|
|
31461
|
-
if (typeof
|
|
31462
|
-
numberSchema = numberSchema.max(
|
|
31597
|
+
if (typeof schema4.maximum === "number") {
|
|
31598
|
+
numberSchema = numberSchema.max(schema4.maximum);
|
|
31463
31599
|
}
|
|
31464
|
-
if (typeof
|
|
31465
|
-
numberSchema = numberSchema.gt(
|
|
31466
|
-
} else if (
|
|
31467
|
-
numberSchema = numberSchema.gt(
|
|
31600
|
+
if (typeof schema4.exclusiveMinimum === "number") {
|
|
31601
|
+
numberSchema = numberSchema.gt(schema4.exclusiveMinimum);
|
|
31602
|
+
} else if (schema4.exclusiveMinimum === true && typeof schema4.minimum === "number") {
|
|
31603
|
+
numberSchema = numberSchema.gt(schema4.minimum);
|
|
31468
31604
|
}
|
|
31469
|
-
if (typeof
|
|
31470
|
-
numberSchema = numberSchema.lt(
|
|
31471
|
-
} else if (
|
|
31472
|
-
numberSchema = numberSchema.lt(
|
|
31605
|
+
if (typeof schema4.exclusiveMaximum === "number") {
|
|
31606
|
+
numberSchema = numberSchema.lt(schema4.exclusiveMaximum);
|
|
31607
|
+
} else if (schema4.exclusiveMaximum === true && typeof schema4.maximum === "number") {
|
|
31608
|
+
numberSchema = numberSchema.lt(schema4.maximum);
|
|
31473
31609
|
}
|
|
31474
|
-
if (typeof
|
|
31475
|
-
numberSchema = numberSchema.multipleOf(
|
|
31610
|
+
if (typeof schema4.multipleOf === "number") {
|
|
31611
|
+
numberSchema = numberSchema.multipleOf(schema4.multipleOf);
|
|
31476
31612
|
}
|
|
31477
31613
|
zodSchema = numberSchema;
|
|
31478
31614
|
break;
|
|
@@ -31487,15 +31623,15 @@ function convertBaseSchema(schema3, ctx) {
|
|
|
31487
31623
|
}
|
|
31488
31624
|
case "object": {
|
|
31489
31625
|
const shape = {};
|
|
31490
|
-
const properties =
|
|
31491
|
-
const requiredSet = new Set(
|
|
31626
|
+
const properties = schema4.properties || {};
|
|
31627
|
+
const requiredSet = new Set(schema4.required || []);
|
|
31492
31628
|
for (const [key, propSchema] of Object.entries(properties)) {
|
|
31493
31629
|
const propZodSchema = convertSchema(propSchema, ctx);
|
|
31494
31630
|
shape[key] = requiredSet.has(key) ? propZodSchema : propZodSchema.optional();
|
|
31495
31631
|
}
|
|
31496
|
-
if (
|
|
31497
|
-
const keySchema = convertSchema(
|
|
31498
|
-
const valueSchema =
|
|
31632
|
+
if (schema4.propertyNames) {
|
|
31633
|
+
const keySchema = convertSchema(schema4.propertyNames, ctx);
|
|
31634
|
+
const valueSchema = schema4.additionalProperties && typeof schema4.additionalProperties === "object" ? convertSchema(schema4.additionalProperties, ctx) : z.any();
|
|
31499
31635
|
if (Object.keys(shape).length === 0) {
|
|
31500
31636
|
zodSchema = z.record(keySchema, valueSchema);
|
|
31501
31637
|
break;
|
|
@@ -31505,8 +31641,8 @@ function convertBaseSchema(schema3, ctx) {
|
|
|
31505
31641
|
zodSchema = z.intersection(objectSchema2, recordSchema);
|
|
31506
31642
|
break;
|
|
31507
31643
|
}
|
|
31508
|
-
if (
|
|
31509
|
-
const patternProps =
|
|
31644
|
+
if (schema4.patternProperties) {
|
|
31645
|
+
const patternProps = schema4.patternProperties;
|
|
31510
31646
|
const patternKeys = Object.keys(patternProps);
|
|
31511
31647
|
const looseRecords = [];
|
|
31512
31648
|
for (const pattern of patternKeys) {
|
|
@@ -31533,18 +31669,18 @@ function convertBaseSchema(schema3, ctx) {
|
|
|
31533
31669
|
break;
|
|
31534
31670
|
}
|
|
31535
31671
|
const objectSchema = z.object(shape);
|
|
31536
|
-
if (
|
|
31672
|
+
if (schema4.additionalProperties === false) {
|
|
31537
31673
|
zodSchema = objectSchema.strict();
|
|
31538
|
-
} else if (typeof
|
|
31539
|
-
zodSchema = objectSchema.catchall(convertSchema(
|
|
31674
|
+
} else if (typeof schema4.additionalProperties === "object") {
|
|
31675
|
+
zodSchema = objectSchema.catchall(convertSchema(schema4.additionalProperties, ctx));
|
|
31540
31676
|
} else {
|
|
31541
31677
|
zodSchema = objectSchema.passthrough();
|
|
31542
31678
|
}
|
|
31543
31679
|
break;
|
|
31544
31680
|
}
|
|
31545
31681
|
case "array": {
|
|
31546
|
-
const prefixItems =
|
|
31547
|
-
const items =
|
|
31682
|
+
const prefixItems = schema4.prefixItems;
|
|
31683
|
+
const items = schema4.items;
|
|
31548
31684
|
if (prefixItems && Array.isArray(prefixItems)) {
|
|
31549
31685
|
const tupleItems = prefixItems.map((item) => convertSchema(item, ctx));
|
|
31550
31686
|
const rest = items && typeof items === "object" && !Array.isArray(items) ? convertSchema(items, ctx) : void 0;
|
|
@@ -31553,34 +31689,34 @@ function convertBaseSchema(schema3, ctx) {
|
|
|
31553
31689
|
} else {
|
|
31554
31690
|
zodSchema = z.tuple(tupleItems);
|
|
31555
31691
|
}
|
|
31556
|
-
if (typeof
|
|
31557
|
-
zodSchema = zodSchema.check(z.minLength(
|
|
31692
|
+
if (typeof schema4.minItems === "number") {
|
|
31693
|
+
zodSchema = zodSchema.check(z.minLength(schema4.minItems));
|
|
31558
31694
|
}
|
|
31559
|
-
if (typeof
|
|
31560
|
-
zodSchema = zodSchema.check(z.maxLength(
|
|
31695
|
+
if (typeof schema4.maxItems === "number") {
|
|
31696
|
+
zodSchema = zodSchema.check(z.maxLength(schema4.maxItems));
|
|
31561
31697
|
}
|
|
31562
31698
|
} else if (Array.isArray(items)) {
|
|
31563
31699
|
const tupleItems = items.map((item) => convertSchema(item, ctx));
|
|
31564
|
-
const rest =
|
|
31700
|
+
const rest = schema4.additionalItems && typeof schema4.additionalItems === "object" ? convertSchema(schema4.additionalItems, ctx) : void 0;
|
|
31565
31701
|
if (rest) {
|
|
31566
31702
|
zodSchema = z.tuple(tupleItems).rest(rest);
|
|
31567
31703
|
} else {
|
|
31568
31704
|
zodSchema = z.tuple(tupleItems);
|
|
31569
31705
|
}
|
|
31570
|
-
if (typeof
|
|
31571
|
-
zodSchema = zodSchema.check(z.minLength(
|
|
31706
|
+
if (typeof schema4.minItems === "number") {
|
|
31707
|
+
zodSchema = zodSchema.check(z.minLength(schema4.minItems));
|
|
31572
31708
|
}
|
|
31573
|
-
if (typeof
|
|
31574
|
-
zodSchema = zodSchema.check(z.maxLength(
|
|
31709
|
+
if (typeof schema4.maxItems === "number") {
|
|
31710
|
+
zodSchema = zodSchema.check(z.maxLength(schema4.maxItems));
|
|
31575
31711
|
}
|
|
31576
31712
|
} else if (items !== void 0) {
|
|
31577
31713
|
const element = convertSchema(items, ctx);
|
|
31578
31714
|
let arraySchema = z.array(element);
|
|
31579
|
-
if (typeof
|
|
31580
|
-
arraySchema = arraySchema.min(
|
|
31715
|
+
if (typeof schema4.minItems === "number") {
|
|
31716
|
+
arraySchema = arraySchema.min(schema4.minItems);
|
|
31581
31717
|
}
|
|
31582
|
-
if (typeof
|
|
31583
|
-
arraySchema = arraySchema.max(
|
|
31718
|
+
if (typeof schema4.maxItems === "number") {
|
|
31719
|
+
arraySchema = arraySchema.max(schema4.maxItems);
|
|
31584
31720
|
}
|
|
31585
31721
|
zodSchema = arraySchema;
|
|
31586
31722
|
} else {
|
|
@@ -31593,76 +31729,76 @@ function convertBaseSchema(schema3, ctx) {
|
|
|
31593
31729
|
}
|
|
31594
31730
|
return zodSchema;
|
|
31595
31731
|
}
|
|
31596
|
-
function convertSchema(
|
|
31597
|
-
if (typeof
|
|
31598
|
-
return
|
|
31732
|
+
function convertSchema(schema4, ctx) {
|
|
31733
|
+
if (typeof schema4 === "boolean") {
|
|
31734
|
+
return schema4 ? z.any() : z.never();
|
|
31599
31735
|
}
|
|
31600
|
-
let baseSchema = convertBaseSchema(
|
|
31601
|
-
const hasExplicitType =
|
|
31602
|
-
if (
|
|
31603
|
-
const options =
|
|
31736
|
+
let baseSchema = convertBaseSchema(schema4, ctx);
|
|
31737
|
+
const hasExplicitType = schema4.type || schema4.enum !== void 0 || schema4.const !== void 0;
|
|
31738
|
+
if (schema4.anyOf && Array.isArray(schema4.anyOf)) {
|
|
31739
|
+
const options = schema4.anyOf.map((s) => convertSchema(s, ctx));
|
|
31604
31740
|
const anyOfUnion = z.union(options);
|
|
31605
31741
|
baseSchema = hasExplicitType ? z.intersection(baseSchema, anyOfUnion) : anyOfUnion;
|
|
31606
31742
|
}
|
|
31607
|
-
if (
|
|
31608
|
-
const options =
|
|
31743
|
+
if (schema4.oneOf && Array.isArray(schema4.oneOf)) {
|
|
31744
|
+
const options = schema4.oneOf.map((s) => convertSchema(s, ctx));
|
|
31609
31745
|
const oneOfUnion = z.xor(options);
|
|
31610
31746
|
baseSchema = hasExplicitType ? z.intersection(baseSchema, oneOfUnion) : oneOfUnion;
|
|
31611
31747
|
}
|
|
31612
|
-
if (
|
|
31613
|
-
if (
|
|
31748
|
+
if (schema4.allOf && Array.isArray(schema4.allOf)) {
|
|
31749
|
+
if (schema4.allOf.length === 0) {
|
|
31614
31750
|
baseSchema = hasExplicitType ? baseSchema : z.any();
|
|
31615
31751
|
} else {
|
|
31616
|
-
let result2 = hasExplicitType ? baseSchema : convertSchema(
|
|
31752
|
+
let result2 = hasExplicitType ? baseSchema : convertSchema(schema4.allOf[0], ctx);
|
|
31617
31753
|
const startIdx = hasExplicitType ? 0 : 1;
|
|
31618
|
-
for (let i2 = startIdx; i2 <
|
|
31619
|
-
result2 = z.intersection(result2, convertSchema(
|
|
31754
|
+
for (let i2 = startIdx; i2 < schema4.allOf.length; i2++) {
|
|
31755
|
+
result2 = z.intersection(result2, convertSchema(schema4.allOf[i2], ctx));
|
|
31620
31756
|
}
|
|
31621
31757
|
baseSchema = result2;
|
|
31622
31758
|
}
|
|
31623
31759
|
}
|
|
31624
|
-
if (
|
|
31760
|
+
if (schema4.nullable === true && ctx.version === "openapi-3.0") {
|
|
31625
31761
|
baseSchema = z.nullable(baseSchema);
|
|
31626
31762
|
}
|
|
31627
|
-
if (
|
|
31763
|
+
if (schema4.readOnly === true) {
|
|
31628
31764
|
baseSchema = z.readonly(baseSchema);
|
|
31629
31765
|
}
|
|
31630
|
-
if (
|
|
31631
|
-
baseSchema = baseSchema.default(
|
|
31766
|
+
if (schema4.default !== void 0) {
|
|
31767
|
+
baseSchema = baseSchema.default(schema4.default);
|
|
31632
31768
|
}
|
|
31633
31769
|
const extraMeta = {};
|
|
31634
31770
|
const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
|
|
31635
31771
|
for (const key of coreMetadataKeys) {
|
|
31636
|
-
if (key in
|
|
31637
|
-
extraMeta[key] =
|
|
31772
|
+
if (key in schema4) {
|
|
31773
|
+
extraMeta[key] = schema4[key];
|
|
31638
31774
|
}
|
|
31639
31775
|
}
|
|
31640
31776
|
const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
|
|
31641
31777
|
for (const key of contentMetadataKeys) {
|
|
31642
|
-
if (key in
|
|
31643
|
-
extraMeta[key] =
|
|
31778
|
+
if (key in schema4) {
|
|
31779
|
+
extraMeta[key] = schema4[key];
|
|
31644
31780
|
}
|
|
31645
31781
|
}
|
|
31646
|
-
for (const key of Object.keys(
|
|
31782
|
+
for (const key of Object.keys(schema4)) {
|
|
31647
31783
|
if (!RECOGNIZED_KEYS.has(key)) {
|
|
31648
|
-
extraMeta[key] =
|
|
31784
|
+
extraMeta[key] = schema4[key];
|
|
31649
31785
|
}
|
|
31650
31786
|
}
|
|
31651
31787
|
if (Object.keys(extraMeta).length > 0) {
|
|
31652
31788
|
ctx.registry.add(baseSchema, extraMeta);
|
|
31653
31789
|
}
|
|
31654
|
-
if (
|
|
31655
|
-
baseSchema = baseSchema.describe(
|
|
31790
|
+
if (schema4.description) {
|
|
31791
|
+
baseSchema = baseSchema.describe(schema4.description);
|
|
31656
31792
|
}
|
|
31657
31793
|
return baseSchema;
|
|
31658
31794
|
}
|
|
31659
|
-
function fromJSONSchema(
|
|
31660
|
-
if (typeof
|
|
31661
|
-
return
|
|
31795
|
+
function fromJSONSchema(schema4, params) {
|
|
31796
|
+
if (typeof schema4 === "boolean") {
|
|
31797
|
+
return schema4 ? z.any() : z.never();
|
|
31662
31798
|
}
|
|
31663
31799
|
let normalized;
|
|
31664
31800
|
try {
|
|
31665
|
-
normalized = JSON.parse(JSON.stringify(
|
|
31801
|
+
normalized = JSON.parse(JSON.stringify(schema4));
|
|
31666
31802
|
} catch {
|
|
31667
31803
|
throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas");
|
|
31668
31804
|
}
|
|
@@ -32339,7 +32475,7 @@ var init_skill_protocol = __esm({
|
|
|
32339
32475
|
"https://bsc-dataseed.binance.org",
|
|
32340
32476
|
"https://bsc-dataseed1.defibit.io"
|
|
32341
32477
|
],
|
|
32342
|
-
maxLogBlockRange:
|
|
32478
|
+
maxLogBlockRange: 500
|
|
32343
32479
|
},
|
|
32344
32480
|
sourceRepository: "FinchipAI/finchip-protocol",
|
|
32345
32481
|
sourceCommit: "89e54d6ff46dbfba61122e90c5e77f409f02fe5e",
|
|
@@ -32367,7 +32503,8 @@ var init_skill_protocol = __esm({
|
|
|
32367
32503
|
defaultRpcUrls: [
|
|
32368
32504
|
"https://mainnet.base.org",
|
|
32369
32505
|
"https://base.drpc.org"
|
|
32370
|
-
]
|
|
32506
|
+
],
|
|
32507
|
+
maxLogBlockRange: 2e3
|
|
32371
32508
|
},
|
|
32372
32509
|
sourceRepository: "FinchipAI/finchip-protocol",
|
|
32373
32510
|
sourceCommit: "89e54d6ff46dbfba61122e90c5e77f409f02fe5e",
|
|
@@ -32523,8 +32660,8 @@ function resolveSkillProtocolEnvironment(raw) {
|
|
|
32523
32660
|
`FINCH_ENVIRONMENT must explicitly be local, test, or production; received ${received}.`
|
|
32524
32661
|
);
|
|
32525
32662
|
}
|
|
32526
|
-
function parseTypedRegistry(
|
|
32527
|
-
const parsed =
|
|
32663
|
+
function parseTypedRegistry(schema4, value) {
|
|
32664
|
+
const parsed = schema4.safeParse(value);
|
|
32528
32665
|
if (!parsed.success) {
|
|
32529
32666
|
throw new DeploymentManifestError(`Invalid chain deployment manifest: ${external_exports.prettifyError(parsed.error)}`);
|
|
32530
32667
|
}
|
|
@@ -32933,6 +33070,65 @@ var init_chains = __esm({
|
|
|
32933
33070
|
}
|
|
32934
33071
|
});
|
|
32935
33072
|
|
|
33073
|
+
// ../../packages/deployment-manifest/src/platform/passkey-safe.json
|
|
33074
|
+
var passkey_safe_default;
|
|
33075
|
+
var init_passkey_safe = __esm({
|
|
33076
|
+
"../../packages/deployment-manifest/src/platform/passkey-safe.json"() {
|
|
33077
|
+
passkey_safe_default = {
|
|
33078
|
+
schemaVersion: 1,
|
|
33079
|
+
kind: "passkey_safe",
|
|
33080
|
+
environments: {
|
|
33081
|
+
local: { enabled: false },
|
|
33082
|
+
test: {
|
|
33083
|
+
enabled: true,
|
|
33084
|
+
larkAlertsEnabled: true,
|
|
33085
|
+
chainId: 84532,
|
|
33086
|
+
platformOwner: "0xa6244488cf4660618d054b5f69d6e60c807df9cb",
|
|
33087
|
+
safeVersion: "1.4.1",
|
|
33088
|
+
verifierAddress: "0x0000000000000000000000000000000000000100",
|
|
33089
|
+
minimumGasWei: "1000000000000000",
|
|
33090
|
+
maxGasPerTransaction: "3000000"
|
|
33091
|
+
},
|
|
33092
|
+
production: { enabled: false }
|
|
33093
|
+
}
|
|
33094
|
+
};
|
|
33095
|
+
}
|
|
33096
|
+
});
|
|
33097
|
+
|
|
33098
|
+
// ../../packages/deployment-manifest/src/platform/passkey-safe.ts
|
|
33099
|
+
function parsePasskeySafeManifest(input) {
|
|
33100
|
+
return schema.parse(input);
|
|
33101
|
+
}
|
|
33102
|
+
var disabled, enabled, schema, manifest;
|
|
33103
|
+
var init_passkey_safe2 = __esm({
|
|
33104
|
+
"../../packages/deployment-manifest/src/platform/passkey-safe.ts"() {
|
|
33105
|
+
"use strict";
|
|
33106
|
+
init_zod();
|
|
33107
|
+
init_passkey_safe();
|
|
33108
|
+
disabled = external_exports.strictObject({ enabled: external_exports.literal(false) });
|
|
33109
|
+
enabled = external_exports.strictObject({
|
|
33110
|
+
enabled: external_exports.literal(true),
|
|
33111
|
+
chainId: external_exports.literal(84532),
|
|
33112
|
+
larkAlertsEnabled: external_exports.boolean(),
|
|
33113
|
+
platformOwner: external_exports.string().regex(/^0x[0-9a-f]{40}$/).refine((v) => BigInt(v) !== BigInt(0)),
|
|
33114
|
+
safeVersion: external_exports.literal("1.4.1"),
|
|
33115
|
+
verifierAddress: external_exports.string().regex(/^0x[0-9a-f]{40}$/).refine((v) => BigInt(v) > BigInt(0) && BigInt(v) <= BigInt(65535)),
|
|
33116
|
+
minimumGasWei: external_exports.string().regex(/^[1-9][0-9]*$/),
|
|
33117
|
+
maxGasPerTransaction: external_exports.string().regex(/^[1-9][0-9]*$/)
|
|
33118
|
+
});
|
|
33119
|
+
schema = external_exports.strictObject({
|
|
33120
|
+
schemaVersion: external_exports.literal(1),
|
|
33121
|
+
kind: external_exports.literal("passkey_safe"),
|
|
33122
|
+
environments: external_exports.strictObject({
|
|
33123
|
+
local: disabled,
|
|
33124
|
+
test: external_exports.discriminatedUnion("enabled", [disabled, enabled]),
|
|
33125
|
+
production: disabled
|
|
33126
|
+
})
|
|
33127
|
+
});
|
|
33128
|
+
manifest = parsePasskeySafeManifest(passkey_safe_default);
|
|
33129
|
+
}
|
|
33130
|
+
});
|
|
33131
|
+
|
|
32936
33132
|
// ../../packages/deployment-manifest/src/platform/web-analytics.json
|
|
32937
33133
|
var web_analytics_default;
|
|
32938
33134
|
var init_web_analytics = __esm({
|
|
@@ -32980,16 +33176,31 @@ var init_internal_apps = __esm({
|
|
|
32980
33176
|
kind: "internal_apps",
|
|
32981
33177
|
environments: {
|
|
32982
33178
|
local: {
|
|
32983
|
-
data: {
|
|
32984
|
-
|
|
33179
|
+
data: {
|
|
33180
|
+
sessionTtlSeconds: 28800
|
|
33181
|
+
},
|
|
33182
|
+
ops: {
|
|
33183
|
+
sessionTtlSeconds: 28800,
|
|
33184
|
+
webOrigin: "http://localhost:3000"
|
|
33185
|
+
}
|
|
32985
33186
|
},
|
|
32986
33187
|
test: {
|
|
32987
|
-
data: {
|
|
32988
|
-
|
|
33188
|
+
data: {
|
|
33189
|
+
sessionTtlSeconds: 28800
|
|
33190
|
+
},
|
|
33191
|
+
ops: {
|
|
33192
|
+
sessionTtlSeconds: 28800,
|
|
33193
|
+
webOrigin: "https://finch-site.vercel.app"
|
|
33194
|
+
}
|
|
32989
33195
|
},
|
|
32990
33196
|
production: {
|
|
32991
|
-
data: {
|
|
32992
|
-
|
|
33197
|
+
data: {
|
|
33198
|
+
sessionTtlSeconds: 28800
|
|
33199
|
+
},
|
|
33200
|
+
ops: {
|
|
33201
|
+
sessionTtlSeconds: 28800,
|
|
33202
|
+
webOrigin: "https://www.finchtech.ai"
|
|
33203
|
+
}
|
|
32993
33204
|
}
|
|
32994
33205
|
}
|
|
32995
33206
|
};
|
|
@@ -33139,9 +33350,9 @@ var init_agenton_payout = __esm({
|
|
|
33139
33350
|
|
|
33140
33351
|
// ../../packages/deployment-manifest/src/platform/agenton-payout.ts
|
|
33141
33352
|
function parseAgentonPayoutManifest(input) {
|
|
33142
|
-
return
|
|
33353
|
+
return schema2.parse(input);
|
|
33143
33354
|
}
|
|
33144
|
-
var origin, environment,
|
|
33355
|
+
var origin, environment, schema2, manifest2;
|
|
33145
33356
|
var init_agenton_payout2 = __esm({
|
|
33146
33357
|
"../../packages/deployment-manifest/src/platform/agenton-payout.ts"() {
|
|
33147
33358
|
"use strict";
|
|
@@ -33152,14 +33363,14 @@ var init_agenton_payout2 = __esm({
|
|
|
33152
33363
|
return url2.protocol === "https:" && url2.origin === value && !url2.username && !url2.password;
|
|
33153
33364
|
});
|
|
33154
33365
|
environment = external_exports.strictObject({ enabled: external_exports.boolean(), mandateId: external_exports.string().min(1).nullable() });
|
|
33155
|
-
|
|
33366
|
+
schema2 = external_exports.strictObject({
|
|
33156
33367
|
schemaVersion: external_exports.literal(1),
|
|
33157
33368
|
kind: external_exports.literal("agenton_payout"),
|
|
33158
33369
|
agentIdBaseUrl: origin,
|
|
33159
33370
|
walletApiBaseUrl: origin,
|
|
33160
33371
|
environments: external_exports.strictObject({ local: environment, test: environment, production: environment })
|
|
33161
33372
|
});
|
|
33162
|
-
|
|
33373
|
+
manifest2 = parseAgentonPayoutManifest(agenton_payout_default);
|
|
33163
33374
|
}
|
|
33164
33375
|
});
|
|
33165
33376
|
|
|
@@ -33171,9 +33382,19 @@ var init_merchant_avatar_video = __esm({
|
|
|
33171
33382
|
schemaVersion: 1,
|
|
33172
33383
|
kind: "merchant_avatar_video",
|
|
33173
33384
|
environments: {
|
|
33174
|
-
local: {
|
|
33175
|
-
|
|
33176
|
-
|
|
33385
|
+
local: {
|
|
33386
|
+
enabled: false
|
|
33387
|
+
},
|
|
33388
|
+
test: {
|
|
33389
|
+
enabled: true,
|
|
33390
|
+
offerId: "e72aeda7-da44-5685-b5a0-4d90cfa63c2d",
|
|
33391
|
+
dailyLimit: 10
|
|
33392
|
+
},
|
|
33393
|
+
production: {
|
|
33394
|
+
enabled: true,
|
|
33395
|
+
offerId: "1cf22f74-a451-54f0-894a-baff6221693d",
|
|
33396
|
+
dailyLimit: 10
|
|
33397
|
+
}
|
|
33177
33398
|
}
|
|
33178
33399
|
};
|
|
33179
33400
|
}
|
|
@@ -33181,9 +33402,9 @@ var init_merchant_avatar_video = __esm({
|
|
|
33181
33402
|
|
|
33182
33403
|
// ../../packages/deployment-manifest/src/platform/merchant-avatar-video.ts
|
|
33183
33404
|
function parseMerchantAvatarVideoManifest(input) {
|
|
33184
|
-
return
|
|
33405
|
+
return schema3.parse(input);
|
|
33185
33406
|
}
|
|
33186
|
-
var policy,
|
|
33407
|
+
var policy, schema3, manifest3;
|
|
33187
33408
|
var init_merchant_avatar_video2 = __esm({
|
|
33188
33409
|
"../../packages/deployment-manifest/src/platform/merchant-avatar-video.ts"() {
|
|
33189
33410
|
"use strict";
|
|
@@ -33193,18 +33414,18 @@ var init_merchant_avatar_video2 = __esm({
|
|
|
33193
33414
|
external_exports.strictObject({ enabled: external_exports.literal(false) }),
|
|
33194
33415
|
external_exports.strictObject({ enabled: external_exports.literal(true), offerId: external_exports.uuid(), dailyLimit: external_exports.number().int().min(1).max(1e4) })
|
|
33195
33416
|
]);
|
|
33196
|
-
|
|
33417
|
+
schema3 = external_exports.strictObject({
|
|
33197
33418
|
schemaVersion: external_exports.literal(1),
|
|
33198
33419
|
kind: external_exports.literal("merchant_avatar_video"),
|
|
33199
33420
|
environments: external_exports.strictObject({ local: policy, test: policy, production: policy })
|
|
33200
33421
|
});
|
|
33201
|
-
|
|
33422
|
+
manifest3 = parseMerchantAvatarVideoManifest(merchant_avatar_video_default);
|
|
33202
33423
|
}
|
|
33203
33424
|
});
|
|
33204
33425
|
|
|
33205
33426
|
// ../../packages/deployment-manifest/src/platform/index.ts
|
|
33206
|
-
function parseManifest2(label,
|
|
33207
|
-
const parsed =
|
|
33427
|
+
function parseManifest2(label, schema4, value) {
|
|
33428
|
+
const parsed = schema4.safeParse(value);
|
|
33208
33429
|
if (!parsed.success) {
|
|
33209
33430
|
throw new DeploymentManifestError(
|
|
33210
33431
|
`Invalid ${label} deployment manifest: ${external_exports.prettifyError(parsed.error)}`
|
|
@@ -33248,6 +33469,7 @@ var init_platform = __esm({
|
|
|
33248
33469
|
"../../packages/deployment-manifest/src/platform/index.ts"() {
|
|
33249
33470
|
"use strict";
|
|
33250
33471
|
init_zod();
|
|
33472
|
+
init_passkey_safe2();
|
|
33251
33473
|
init_web_analytics();
|
|
33252
33474
|
init_web_localization();
|
|
33253
33475
|
init_chains();
|
|
@@ -33262,7 +33484,10 @@ var init_platform = __esm({
|
|
|
33262
33484
|
});
|
|
33263
33485
|
internalAppsEnvironmentSchema = external_exports.strictObject({
|
|
33264
33486
|
data: internalAppSchema,
|
|
33265
|
-
ops: internalAppSchema
|
|
33487
|
+
ops: internalAppSchema.extend({ webOrigin: external_exports.url().refine((value) => {
|
|
33488
|
+
const url2 = new URL(value);
|
|
33489
|
+
return url2.origin === value && (url2.protocol === "https:" || value === "http://localhost:3000");
|
|
33490
|
+
}, "An exact reviewed Web origin is required.") })
|
|
33266
33491
|
});
|
|
33267
33492
|
internalAppsManifestSchema = external_exports.strictObject({
|
|
33268
33493
|
schemaVersion: external_exports.literal(1),
|
|
@@ -47908,8 +48133,8 @@ var init_verifyAuthorization = __esm({
|
|
|
47908
48133
|
});
|
|
47909
48134
|
|
|
47910
48135
|
// ../../node_modules/.pnpm/viem@2.55.15_bufferutil@4.1_ce20031be19c56210207d462110a7a29/node_modules/viem/_esm/utils/promise/withDedupe.js
|
|
47911
|
-
function withDedupe(fn, { enabled = true, id }) {
|
|
47912
|
-
if (!
|
|
48136
|
+
function withDedupe(fn, { enabled: enabled2 = true, id }) {
|
|
48137
|
+
if (!enabled2 || !id)
|
|
47913
48138
|
return fn();
|
|
47914
48139
|
if (promiseCache2.get(id))
|
|
47915
48140
|
return promiseCache2.get(id);
|
|
@@ -54100,27 +54325,27 @@ function normalizeCliEvmAddress(value, field = "EVM address") {
|
|
|
54100
54325
|
function record3(value) {
|
|
54101
54326
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
54102
54327
|
}
|
|
54103
|
-
function variantMatches(
|
|
54104
|
-
if (!record3(
|
|
54105
|
-
return Object.entries(
|
|
54328
|
+
function variantMatches(schema4, value) {
|
|
54329
|
+
if (!record3(schema4.properties) || !record3(value)) return true;
|
|
54330
|
+
return Object.entries(schema4.properties).every(([key, property]) => {
|
|
54106
54331
|
if (!record3(property) || !Object.hasOwn(property, "const")) return true;
|
|
54107
54332
|
return value[key] === property.const;
|
|
54108
54333
|
});
|
|
54109
54334
|
}
|
|
54110
|
-
function normalizeCliRequestAddresses(
|
|
54111
|
-
if ((
|
|
54335
|
+
function normalizeCliRequestAddresses(schema4, value) {
|
|
54336
|
+
if ((schema4.pattern === CANONICAL_ADDRESS_PATTERN || schema4.pattern === INPUT_ADDRESS_PATTERN) && typeof value === "string") {
|
|
54112
54337
|
return normalizeCliEvmAddress(value);
|
|
54113
54338
|
}
|
|
54114
|
-
const variants = Array.isArray(
|
|
54339
|
+
const variants = Array.isArray(schema4.oneOf) ? schema4.oneOf : Array.isArray(schema4.anyOf) ? schema4.anyOf : null;
|
|
54115
54340
|
if (variants !== null) {
|
|
54116
54341
|
const selected = variants.find((variant) => record3(variant) && variantMatches(variant, value));
|
|
54117
54342
|
return selected === void 0 || !record3(selected) ? value : normalizeCliRequestAddresses(selected, value);
|
|
54118
54343
|
}
|
|
54119
|
-
if (Array.isArray(value) && record3(
|
|
54120
|
-
return value.map((item) => normalizeCliRequestAddresses(
|
|
54344
|
+
if (Array.isArray(value) && record3(schema4.items)) {
|
|
54345
|
+
return value.map((item) => normalizeCliRequestAddresses(schema4.items, item));
|
|
54121
54346
|
}
|
|
54122
|
-
if (record3(value) && record3(
|
|
54123
|
-
const properties =
|
|
54347
|
+
if (record3(value) && record3(schema4.properties)) {
|
|
54348
|
+
const properties = schema4.properties;
|
|
54124
54349
|
return Object.fromEntries(Object.entries(value).map(([key, entry2]) => {
|
|
54125
54350
|
const property = properties[key];
|
|
54126
54351
|
return [key, record3(property) ? normalizeCliRequestAddresses(property, entry2) : entry2];
|
|
@@ -54141,21 +54366,38 @@ var init_address3 = __esm({
|
|
|
54141
54366
|
});
|
|
54142
54367
|
|
|
54143
54368
|
// src/api.ts
|
|
54144
|
-
function
|
|
54145
|
-
|
|
54369
|
+
function skillHttpDiagnostic(response, value) {
|
|
54370
|
+
const code = value?.error?.code;
|
|
54371
|
+
const platformCode = response.headers.get("x-vercel-error");
|
|
54372
|
+
const requestId = response.headers.get("x-vercel-id");
|
|
54373
|
+
const traceId = response.headers.get("x-finch-trace-id");
|
|
54374
|
+
return {
|
|
54375
|
+
...typeof code === "string" && PUBLIC_SKILL_HTTP_CODES.has(code) ? { remoteCode: code } : platformCode !== null && PUBLIC_SKILL_HTTP_CODES.has(platformCode) ? { remoteCode: platformCode } : {},
|
|
54376
|
+
...requestId !== null && /^[a-z0-9]{3,8}(?:::[a-z0-9]{3,8})?::[a-z0-9]{5}-[0-9]{13}-[a-f0-9]{12}$/u.test(requestId) ? { remoteRequestId: requestId } : {},
|
|
54377
|
+
...traceId !== null && /^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/u.test(traceId) ? { remoteTraceId: traceId } : {}
|
|
54378
|
+
};
|
|
54379
|
+
}
|
|
54380
|
+
function assertSchema(schema4, value, diagnosticPaths) {
|
|
54381
|
+
let validator = validatorCache.get(schema4);
|
|
54146
54382
|
if (validator === void 0) {
|
|
54147
|
-
const compiled = ajv.compile(
|
|
54148
|
-
validatorCache.set(
|
|
54383
|
+
const compiled = ajv.compile(schema4);
|
|
54384
|
+
validatorCache.set(schema4, compiled);
|
|
54149
54385
|
validator = compiled;
|
|
54150
54386
|
}
|
|
54151
|
-
if (!validator(value))
|
|
54387
|
+
if (!validator(value)) {
|
|
54388
|
+
const schemaIssues = diagnosticPaths === void 0 ? void 0 : (validator.errors ?? []).slice(0, 8).map((error51) => {
|
|
54389
|
+
const candidate = error51.keyword === "required" ? `${error51.instancePath}/${error51.params.missingProperty}` : error51.instancePath;
|
|
54390
|
+
return { path: diagnosticPaths.includes(candidate) ? candidate : "", keyword: error51.keyword };
|
|
54391
|
+
});
|
|
54392
|
+
throw new CliHttpError("CLI_RESPONSE_INVALID", null, schemaIssues === void 0 ? void 0 : { diagnostic: { responseIssue: "schema_mismatch", schemaIssues } });
|
|
54393
|
+
}
|
|
54152
54394
|
return value;
|
|
54153
54395
|
}
|
|
54154
|
-
function assertRequestSchema(
|
|
54155
|
-
let validator = validatorCache.get(
|
|
54396
|
+
function assertRequestSchema(schema4, value) {
|
|
54397
|
+
let validator = validatorCache.get(schema4);
|
|
54156
54398
|
if (validator === void 0) {
|
|
54157
|
-
validator = ajv.compile(
|
|
54158
|
-
validatorCache.set(
|
|
54399
|
+
validator = ajv.compile(schema4);
|
|
54400
|
+
validatorCache.set(schema4, validator);
|
|
54159
54401
|
}
|
|
54160
54402
|
if (!validator(value)) throw new TypeError("Creator request does not match the shared operation schema.");
|
|
54161
54403
|
}
|
|
@@ -54193,13 +54435,14 @@ function protectedResourceMetadataAuthority(authenticate, origin2, resourcePath)
|
|
|
54193
54435
|
resource: metadata.pathname === rootPath ? `${origin2}/` : `${origin2}${resourcePath}`
|
|
54194
54436
|
});
|
|
54195
54437
|
}
|
|
54196
|
-
async function readBoundedJson(response, maximumBytes = 65536) {
|
|
54438
|
+
async function readBoundedJson(response, maximumBytes = 65536, diagnose = false) {
|
|
54439
|
+
const failure2 = (code, responseIssue, cause) => new CliHttpError(code, response.status, { cause, ...diagnose ? { diagnostic: { responseIssue } } : {} });
|
|
54197
54440
|
const length2 = response.headers.get("content-length");
|
|
54198
54441
|
if (length2 !== null && (!/^(?:0|[1-9][0-9]*)$/u.test(length2) || Number(length2) > maximumBytes)) {
|
|
54199
54442
|
await response.body?.cancel().catch(() => void 0);
|
|
54200
|
-
throw
|
|
54443
|
+
throw failure2("CLI_RESPONSE_INVALID", /^(?:0|[1-9][0-9]*)$/u.test(length2) ? "response_too_large" : "invalid_content_length");
|
|
54201
54444
|
}
|
|
54202
|
-
if (response.body === null) throw
|
|
54445
|
+
if (response.body === null) throw failure2("CLI_RESPONSE_INVALID", "empty_body");
|
|
54203
54446
|
const reader = response.body.getReader();
|
|
54204
54447
|
const chunks = [];
|
|
54205
54448
|
let total = 0;
|
|
@@ -54209,16 +54452,17 @@ async function readBoundedJson(response, maximumBytes = 65536) {
|
|
|
54209
54452
|
try {
|
|
54210
54453
|
chunk = await reader.read();
|
|
54211
54454
|
} catch (cause) {
|
|
54212
|
-
throw
|
|
54455
|
+
throw failure2("CLI_REMOTE_UNAVAILABLE", "body_read_failed", cause);
|
|
54213
54456
|
}
|
|
54214
54457
|
if (chunk.done) break;
|
|
54215
54458
|
total += chunk.value.byteLength;
|
|
54216
54459
|
if (total > maximumBytes) {
|
|
54217
54460
|
await reader.cancel().catch(() => void 0);
|
|
54218
|
-
throw
|
|
54461
|
+
throw failure2("CLI_RESPONSE_INVALID", "response_too_large");
|
|
54219
54462
|
}
|
|
54220
54463
|
chunks.push(chunk.value);
|
|
54221
54464
|
}
|
|
54465
|
+
if (total === 0) throw failure2("CLI_RESPONSE_INVALID", "empty_body");
|
|
54222
54466
|
const body = new Uint8Array(total);
|
|
54223
54467
|
let offset = 0;
|
|
54224
54468
|
for (const chunk of chunks) {
|
|
@@ -54228,11 +54472,11 @@ async function readBoundedJson(response, maximumBytes = 65536) {
|
|
|
54228
54472
|
try {
|
|
54229
54473
|
return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(body));
|
|
54230
54474
|
} catch (cause) {
|
|
54231
|
-
throw
|
|
54475
|
+
throw failure2("CLI_RESPONSE_INVALID", "invalid_json", cause);
|
|
54232
54476
|
}
|
|
54233
54477
|
} catch (cause) {
|
|
54234
54478
|
if (cause instanceof CliHttpError) throw cause;
|
|
54235
|
-
throw
|
|
54479
|
+
throw failure2("CLI_REMOTE_UNAVAILABLE", "body_read_failed", cause);
|
|
54236
54480
|
} finally {
|
|
54237
54481
|
reader.releaseLock();
|
|
54238
54482
|
}
|
|
@@ -54281,13 +54525,16 @@ async function readBoundedBytes(response, minimumBytes, maximumBytes) {
|
|
|
54281
54525
|
reader.releaseLock();
|
|
54282
54526
|
}
|
|
54283
54527
|
}
|
|
54284
|
-
function parseRemoteError(contract, response, value) {
|
|
54285
|
-
const
|
|
54528
|
+
function parseRemoteError(contract, response, value, diagnose = false) {
|
|
54529
|
+
const schema4 = contract === "agent_market" ? agentCliErrorEnvelopeSchema : contract === "identity" ? identityErrorEnvelopeSchema : contract === "task_market" ? taskErrorEnvelopeSchema : contract === "skill_market" ? skillErrorEnvelopeSchema : oauthErrorResponseSchema;
|
|
54286
54530
|
let envelope;
|
|
54287
54531
|
try {
|
|
54288
|
-
envelope = assertSchema(
|
|
54532
|
+
envelope = assertSchema(schema4, value, diagnose ? skillErrorDiagnosticPaths : void 0);
|
|
54289
54533
|
} catch (cause) {
|
|
54290
|
-
throw new CliHttpError("CLI_RESPONSE_INVALID", response.status, {
|
|
54534
|
+
throw new CliHttpError("CLI_RESPONSE_INVALID", response.status, {
|
|
54535
|
+
cause,
|
|
54536
|
+
...cause instanceof CliHttpError && cause.diagnostic !== null ? { diagnostic: cause.diagnostic } : {}
|
|
54537
|
+
});
|
|
54291
54538
|
}
|
|
54292
54539
|
if (contract === "agent_market") {
|
|
54293
54540
|
const error51 = envelope.error;
|
|
@@ -54299,11 +54546,12 @@ function parseRemoteError(contract, response, value) {
|
|
|
54299
54546
|
}
|
|
54300
54547
|
return envelope;
|
|
54301
54548
|
}
|
|
54302
|
-
var import_ajv, CLI_MERCHANT_OPERATION_IDS, CliHttpError, ajv, validatorCache, oauthAuthorizationResponseSchema, oauthErrorResponseSchema, AgentCliHttpClient;
|
|
54549
|
+
var import_ajv, CLI_MERCHANT_OPERATION_IDS, PUBLIC_SKILL_HTTP_CODES, CliHttpError, ajv, validatorCache, skillUnsignedIntentResponseSchema, intentDiagnosticPaths, skillErrorDiagnosticPaths, oauthAuthorizationResponseSchema, oauthErrorResponseSchema, AgentCliHttpClient;
|
|
54303
54550
|
var init_api2 = __esm({
|
|
54304
54551
|
"src/api.ts"() {
|
|
54305
54552
|
"use strict";
|
|
54306
54553
|
import_ajv = __toESM(require_ajv(), 1);
|
|
54554
|
+
init_cli_error();
|
|
54307
54555
|
init_src2();
|
|
54308
54556
|
init_v1();
|
|
54309
54557
|
init_src3();
|
|
@@ -54331,22 +54579,52 @@ var init_api2 = __esm({
|
|
|
54331
54579
|
"merchant_connection_tests.create",
|
|
54332
54580
|
"merchant_publish_intents.create"
|
|
54333
54581
|
]);
|
|
54582
|
+
PUBLIC_SKILL_HTTP_CODES = /* @__PURE__ */ new Set([
|
|
54583
|
+
"UPLOAD_INVALID",
|
|
54584
|
+
"UPLOAD_TOO_LARGE",
|
|
54585
|
+
"UPLOAD_UNAUTHENTICATED",
|
|
54586
|
+
"WALLET_REQUIRED",
|
|
54587
|
+
"UPLOAD_PROVIDER_UNAVAILABLE",
|
|
54588
|
+
"UPLOAD_UNAVAILABLE",
|
|
54589
|
+
"FUNCTION_PAYLOAD_TOO_LARGE",
|
|
54590
|
+
"FUNCTION_INVOCATION_TIMEOUT",
|
|
54591
|
+
"FUNCTION_INVOCATION_FAILED",
|
|
54592
|
+
"INTENT_INVALID",
|
|
54593
|
+
"INTENT_UNAVAILABLE",
|
|
54594
|
+
"PUBLICATION_INVALID"
|
|
54595
|
+
]);
|
|
54334
54596
|
CliHttpError = class extends Error {
|
|
54335
54597
|
code;
|
|
54336
54598
|
status;
|
|
54337
54599
|
envelope;
|
|
54600
|
+
diagnostic;
|
|
54338
54601
|
constructor(code, status = null, options) {
|
|
54339
54602
|
super(code, options);
|
|
54340
54603
|
this.name = "CliHttpError";
|
|
54341
54604
|
this.code = code;
|
|
54342
54605
|
this.status = status;
|
|
54343
54606
|
this.envelope = options?.envelope ?? null;
|
|
54607
|
+
this.diagnostic = options?.diagnostic ?? null;
|
|
54344
54608
|
}
|
|
54345
54609
|
};
|
|
54346
54610
|
ajv = new import_ajv.default({ allErrors: true, strict: false });
|
|
54347
54611
|
ajv.addFormat("date-time", (value) => Number.isFinite(Date.parse(value)));
|
|
54348
54612
|
ajv.addFormat("uri", (value) => URL.canParse(value));
|
|
54349
54613
|
validatorCache = /* @__PURE__ */ new WeakMap();
|
|
54614
|
+
skillUnsignedIntentResponseSchema = {
|
|
54615
|
+
type: "object",
|
|
54616
|
+
additionalProperties: false,
|
|
54617
|
+
required: ["chainId", "to", "data", "value", "summary"],
|
|
54618
|
+
properties: {
|
|
54619
|
+
chainId: { type: "integer", enum: SKILL_V3_CHAIN_IDS },
|
|
54620
|
+
to: { type: "string", pattern: "^0x[0-9a-fA-F]{40}$" },
|
|
54621
|
+
data: { type: "string", pattern: "^0x(?:[0-9a-fA-F]{2})+$" },
|
|
54622
|
+
value: { type: "string", pattern: "^(?:0|[1-9][0-9]*)$" },
|
|
54623
|
+
summary: { type: "string", minLength: 1 }
|
|
54624
|
+
}
|
|
54625
|
+
};
|
|
54626
|
+
intentDiagnosticPaths = Object.keys(skillUnsignedIntentResponseSchema.properties).map((field) => `/${field}`);
|
|
54627
|
+
skillErrorDiagnosticPaths = ["/error", "/error/code", "/error/message", "/error/traceId"];
|
|
54350
54628
|
oauthAuthorizationResponseSchema = {
|
|
54351
54629
|
type: "object",
|
|
54352
54630
|
additionalProperties: false,
|
|
@@ -54371,12 +54649,16 @@ var init_api2 = __esm({
|
|
|
54371
54649
|
}
|
|
54372
54650
|
};
|
|
54373
54651
|
AgentCliHttpClient = class {
|
|
54374
|
-
|
|
54375
|
-
|
|
54376
|
-
|
|
54652
|
+
constructor(origin2, fetchImplementation = fetch, warn = (warning) => {
|
|
54653
|
+
process.stderr.write(JSON.stringify({ warning }) + "\n");
|
|
54654
|
+
}) {
|
|
54655
|
+
this.warn = warn;
|
|
54377
54656
|
this.origin = canonicalOrigin2(origin2);
|
|
54378
54657
|
this.fetchImplementation = fetchImplementation;
|
|
54379
54658
|
}
|
|
54659
|
+
warn;
|
|
54660
|
+
origin;
|
|
54661
|
+
fetchImplementation;
|
|
54380
54662
|
async request(options) {
|
|
54381
54663
|
const headers = new Headers(options.headers);
|
|
54382
54664
|
if (options.path.split("?")[0] === "/api/v1/skill-market/skills") headers.set("X-Finch-Search-Version", "2");
|
|
@@ -54418,12 +54700,17 @@ var init_api2 = __esm({
|
|
|
54418
54700
|
throw new CliHttpError("CLI_REMOTE_UNAVAILABLE", null, { cause });
|
|
54419
54701
|
}
|
|
54420
54702
|
if (response.status !== expectedStatus) {
|
|
54703
|
+
let value;
|
|
54421
54704
|
try {
|
|
54422
|
-
|
|
54705
|
+
value = await readBoundedJson(response, 65536, path2 === "/api/skills/intents");
|
|
54706
|
+
const envelope = parseRemoteError("skill_market", response, value, path2 === "/api/skills/intents");
|
|
54423
54707
|
throw new CliHttpError("CLI_REMOTE_UNAVAILABLE", response.status, { envelope });
|
|
54424
54708
|
} catch (cause) {
|
|
54425
|
-
|
|
54426
|
-
|
|
54709
|
+
throw new CliHttpError(cause instanceof CliHttpError ? cause.code : "CLI_RESPONSE_INVALID", response.status, {
|
|
54710
|
+
cause,
|
|
54711
|
+
...cause instanceof CliHttpError && cause.envelope !== null ? { envelope: cause.envelope } : {},
|
|
54712
|
+
diagnostic: { ...skillHttpDiagnostic(response, value), ...cause instanceof CliHttpError ? cause.diagnostic : {} }
|
|
54713
|
+
});
|
|
54427
54714
|
}
|
|
54428
54715
|
}
|
|
54429
54716
|
return response;
|
|
@@ -54479,17 +54766,17 @@ var init_api2 = __esm({
|
|
|
54479
54766
|
await manifestResponse.body?.cancel().catch(() => void 0);
|
|
54480
54767
|
throw new CliHttpError("CLI_REMOTE_UNAVAILABLE", manifestResponse.status);
|
|
54481
54768
|
}
|
|
54482
|
-
const
|
|
54483
|
-
const mcp = jsonObject(
|
|
54484
|
-
const source = jsonObject(
|
|
54485
|
-
if (!Array.isArray(
|
|
54769
|
+
const manifest4 = jsonObject(await readBoundedJson(manifestResponse));
|
|
54770
|
+
const mcp = jsonObject(manifest4.mcp);
|
|
54771
|
+
const source = jsonObject(manifest4.source);
|
|
54772
|
+
if (!Array.isArray(manifest4.clients) || manifest4.clients.length !== 1) {
|
|
54486
54773
|
throw new CliHttpError("CLI_RESPONSE_INVALID", manifestResponse.status);
|
|
54487
54774
|
}
|
|
54488
|
-
const client = jsonObject(
|
|
54775
|
+
const client = jsonObject(manifest4.clients[0]);
|
|
54489
54776
|
const install = jsonObject(client.install);
|
|
54490
54777
|
const authorize = jsonObject(client.authorize);
|
|
54491
54778
|
const verify = jsonObject(client.verify);
|
|
54492
|
-
if (
|
|
54779
|
+
if (manifest4.schemaVersion !== 3 || manifest4.manifestId !== "finch.remote-mcp-clients" || mcp.serverName !== "finch" || mcp.url !== mcpUrl || mcp.transport !== "streamable_http" || mcp.authorization !== "oauth" || source.repository !== "https://github.com/FinchipAI/Finch-Site" || source.path !== "apps/mcp/src/client-compatibility.ts" || client.id !== "codex" || client.supportLevel !== "verified" || install.kind !== "native_cli" || install.executable !== "codex" || JSON.stringify(install.arguments) !== JSON.stringify(["mcp", "add", "finch", "--url", mcpUrl]) || authorize.kind !== "native_cli" || authorize.executable !== "codex" || JSON.stringify(authorize.arguments) !== JSON.stringify(["mcp", "login", "finch"]) || verify.kind !== "harness_ui" || verify.surface !== "mcp_tools" || client.reload !== "new_session") {
|
|
54493
54780
|
throw new CliHttpError("CLI_RESPONSE_INVALID", manifestResponse.status);
|
|
54494
54781
|
}
|
|
54495
54782
|
return Object.freeze({
|
|
@@ -54501,6 +54788,13 @@ var init_api2 = __esm({
|
|
|
54501
54788
|
});
|
|
54502
54789
|
}
|
|
54503
54790
|
async uploadSkillObject(input) {
|
|
54791
|
+
if (input.objectKind === "manifest" && input.bytes.byteLength > MAX_SKILL_MANIFEST_BYTES) {
|
|
54792
|
+
throw new CliSkillSourceError(
|
|
54793
|
+
"SKILL_MANIFEST_SIZE_INVALID",
|
|
54794
|
+
{ actualBytes: input.bytes.byteLength, maxBytes: MAX_SKILL_MANIFEST_BYTES },
|
|
54795
|
+
"Skill manifest exceeds the 3 MiB limit."
|
|
54796
|
+
);
|
|
54797
|
+
}
|
|
54504
54798
|
const form = new FormData();
|
|
54505
54799
|
form.append("file", new Blob([input.bytes], {
|
|
54506
54800
|
type: input.mediaType ?? "application/octet-stream"
|
|
@@ -54509,21 +54803,70 @@ var init_api2 = __esm({
|
|
|
54509
54803
|
form.append("objectKind", input.objectKind);
|
|
54510
54804
|
if (input.sourceKind !== void 0) form.append("sourceKind", input.sourceKind);
|
|
54511
54805
|
if (input.contentMode !== void 0) form.append("contentMode", input.contentMode);
|
|
54512
|
-
const
|
|
54513
|
-
|
|
54514
|
-
|
|
54515
|
-
|
|
54516
|
-
|
|
54517
|
-
|
|
54518
|
-
|
|
54519
|
-
|
|
54806
|
+
const encoded = new Response(form);
|
|
54807
|
+
const bodyBytes = await encoded.arrayBuffer();
|
|
54808
|
+
const requestBytes = bodyBytes.byteLength;
|
|
54809
|
+
if (requestBytes > 45e5) {
|
|
54810
|
+
throw new CliSkillSourceError(
|
|
54811
|
+
"SKILL_UPLOAD_REQUEST_TOO_LARGE",
|
|
54812
|
+
{ actualBytes: requestBytes, maxBytes: 45e5 },
|
|
54813
|
+
"Skill upload request exceeds 4.5 MB. Reduce the package size before publishing."
|
|
54814
|
+
);
|
|
54815
|
+
}
|
|
54816
|
+
if (requestBytes > 4e6) this.warn({
|
|
54817
|
+
code: "SKILL_UPLOAD_NEAR_LIMIT",
|
|
54818
|
+
requestBytes,
|
|
54819
|
+
maxBytes: 45e5,
|
|
54820
|
+
message: "Skill upload request exceeds 4 MB and may fail near the platform limit. Continuing."
|
|
54821
|
+
});
|
|
54822
|
+
let response;
|
|
54823
|
+
let value;
|
|
54824
|
+
try {
|
|
54825
|
+
response = await this.skillFetch("/api/skills/ipfs", {
|
|
54826
|
+
method: "POST",
|
|
54827
|
+
headers: { authorization: `Bearer ${input.bearer}`, "content-type": encoded.headers.get("content-type") },
|
|
54828
|
+
body: bodyBytes
|
|
54829
|
+
});
|
|
54830
|
+
value = await readBoundedJson(response);
|
|
54831
|
+
const body = value;
|
|
54832
|
+
if (typeof body?.uri !== "string") throw new CliHttpError("CLI_RESPONSE_INVALID", 200);
|
|
54833
|
+
return Object.freeze({ uri: body.uri });
|
|
54834
|
+
} catch (cause) {
|
|
54835
|
+
if (!(cause instanceof CliHttpError)) throw cause;
|
|
54836
|
+
throw new CliHttpError(cause.code, cause.status, {
|
|
54837
|
+
cause,
|
|
54838
|
+
...cause.envelope !== null ? { envelope: cause.envelope } : {},
|
|
54839
|
+
diagnostic: {
|
|
54840
|
+
...response === void 0 ? {} : skillHttpDiagnostic(response, value),
|
|
54841
|
+
...cause.diagnostic,
|
|
54842
|
+
uploadBytes: input.bytes.byteLength,
|
|
54843
|
+
uploadObjectKind: input.objectKind
|
|
54844
|
+
}
|
|
54845
|
+
});
|
|
54846
|
+
}
|
|
54520
54847
|
}
|
|
54521
54848
|
async requestSkillIntent(body, bearer) {
|
|
54522
|
-
|
|
54523
|
-
|
|
54524
|
-
|
|
54525
|
-
|
|
54526
|
-
|
|
54849
|
+
let response;
|
|
54850
|
+
try {
|
|
54851
|
+
response = await this.skillFetch("/api/skills/intents", {
|
|
54852
|
+
method: "POST",
|
|
54853
|
+
headers: { authorization: `Bearer ${bearer}`, "content-type": "application/json" },
|
|
54854
|
+
body: JSON.stringify(body)
|
|
54855
|
+
});
|
|
54856
|
+
return assertSchema(skillUnsignedIntentResponseSchema, await readBoundedJson(response, 65536, true), intentDiagnosticPaths);
|
|
54857
|
+
} catch (cause) {
|
|
54858
|
+
if (!(cause instanceof CliHttpError)) throw cause;
|
|
54859
|
+
throw new CliHttpError(cause.code, cause.status ?? response?.status ?? null, {
|
|
54860
|
+
cause,
|
|
54861
|
+
...cause.envelope !== null ? { envelope: cause.envelope } : {},
|
|
54862
|
+
diagnostic: {
|
|
54863
|
+
...response === void 0 ? {} : skillHttpDiagnostic(response, void 0),
|
|
54864
|
+
...cause.diagnostic,
|
|
54865
|
+
...cause.status === null && response === void 0 ? { responseIssue: "transport_failed" } : {},
|
|
54866
|
+
remotePath: "/api/skills/intents"
|
|
54867
|
+
}
|
|
54868
|
+
});
|
|
54869
|
+
}
|
|
54527
54870
|
}
|
|
54528
54871
|
async resolveSkillId(chainId, slug, bearer) {
|
|
54529
54872
|
let response;
|
|
@@ -55748,26 +56091,43 @@ function legacyIntent(value, walletAddress2, authority) {
|
|
|
55748
56091
|
}
|
|
55749
56092
|
async function readPublishablePath(inputPath) {
|
|
55750
56093
|
const root = resolve2(inputPath);
|
|
55751
|
-
const
|
|
55752
|
-
|
|
56094
|
+
const unreadable = (path2) => new CliSkillSourceError("SKILL_SOURCE_UNREADABLE", { path: path2 }, "Skill source cannot be read. Check the selected path and filesystem permissions.");
|
|
56095
|
+
const rootStat = await lstat2(root).catch(() => {
|
|
56096
|
+
throw unreadable(".");
|
|
56097
|
+
});
|
|
56098
|
+
if (rootStat.isSymbolicLink()) throw new CliSkillSourceError("SKILL_SOURCE_SYMLINK_UNSUPPORTED", { path: "." }, "Skill source does not support symbolic links, including broken links.");
|
|
55753
56099
|
if (rootStat.isFile()) return {
|
|
55754
56100
|
sourceKind: "file",
|
|
55755
|
-
files: [{ path: basename(root), content: new Uint8Array(await readFile2(root))
|
|
56101
|
+
files: [{ path: basename(root), content: new Uint8Array(await readFile2(root).catch(() => {
|
|
56102
|
+
throw unreadable(".");
|
|
56103
|
+
})) }],
|
|
56104
|
+
excluded: []
|
|
55756
56105
|
};
|
|
55757
56106
|
if (!rootStat.isDirectory()) throw new TypeError("Skill publication path must be one regular file or directory.");
|
|
55758
56107
|
const files = [];
|
|
56108
|
+
const excluded = [];
|
|
55759
56109
|
const prefix = basename(root);
|
|
55760
56110
|
const walk3 = async (directory) => {
|
|
55761
|
-
const entries = (await readdir(directory, { withFileTypes: true })
|
|
56111
|
+
const entries = (await readdir(directory, { withFileTypes: true }).catch(() => {
|
|
56112
|
+
throw unreadable(relative2(root, directory).split(sep2).join("/") || ".");
|
|
56113
|
+
})).sort((left, right) => left.name.localeCompare(right.name, "en"));
|
|
55762
56114
|
for (const entry2 of entries) {
|
|
55763
56115
|
const path2 = join2(directory, entry2.name);
|
|
55764
|
-
|
|
56116
|
+
const relativePath = relative2(root, path2).split(sep2).join("/");
|
|
56117
|
+
const packagePath = `${prefix}/${relativePath}`;
|
|
56118
|
+
if (isExcludedSkillPath(packagePath)) {
|
|
56119
|
+
excluded.push(packagePath);
|
|
56120
|
+
continue;
|
|
56121
|
+
}
|
|
56122
|
+
if (entry2.isSymbolicLink()) throw new CliSkillSourceError("SKILL_SOURCE_SYMLINK_UNSUPPORTED", { path: relativePath }, "Skill source does not support symbolic links, including broken links.");
|
|
55765
56123
|
if (entry2.isDirectory()) await walk3(path2);
|
|
55766
|
-
else if (entry2.isFile()) files.push({ path:
|
|
56124
|
+
else if (entry2.isFile()) files.push({ path: packagePath, content: new Uint8Array(await readFile2(path2).catch(() => {
|
|
56125
|
+
throw unreadable(relativePath);
|
|
56126
|
+
})) });
|
|
55767
56127
|
}
|
|
55768
56128
|
};
|
|
55769
56129
|
await walk3(root);
|
|
55770
|
-
return { sourceKind: "directory", files };
|
|
56130
|
+
return { sourceKind: "directory", files, excluded };
|
|
55771
56131
|
}
|
|
55772
56132
|
function sourceKind(value) {
|
|
55773
56133
|
if (value !== "file" && value !== "directory") throw new TypeError("Skill sourceKind is invalid.");
|
|
@@ -55993,16 +56353,20 @@ function recoveryJournal(value, fingerprint2, kind, context) {
|
|
|
55993
56353
|
"targetVersion",
|
|
55994
56354
|
"requests",
|
|
55995
56355
|
"receipts",
|
|
55996
|
-
...journal.version === 5 ? ["sourceHash"] : []
|
|
56356
|
+
...journal.version === 5 || journal.version === 6 ? ["sourceHash"] : [],
|
|
56357
|
+
...journal.version === 6 ? ["pendingStage"] : []
|
|
55997
56358
|
], "Skill publication recovery");
|
|
55998
56359
|
const chainId = skillChain(journal.chainId, "Skill recovery chain");
|
|
55999
|
-
if (journal.version !== 4 && journal.version !== 5 || journal.kind !== kind || journal.fingerprint !== fingerprint2 || !/^[0-9a-f]{64}$/u.test(fingerprint2) || typeof journal.walletAddress !== "string" || journal.walletAddress.toLowerCase() !== context.walletAddress.toLowerCase()) throw new TypeError("Skill publication recovery authority does not match this command.");
|
|
56360
|
+
if (journal.version !== 4 && journal.version !== 5 && journal.version !== 6 || journal.kind !== kind || journal.fingerprint !== fingerprint2 || !/^[0-9a-f]{64}$/u.test(fingerprint2) || typeof journal.walletAddress !== "string" || journal.walletAddress.toLowerCase() !== context.walletAddress.toLowerCase()) throw new TypeError("Skill publication recovery authority does not match this command.");
|
|
56000
56361
|
const recoveredAuthority = assertPublicationAuthority(
|
|
56001
56362
|
signingAuthority(journal.signingAuthority, context.walletAddress),
|
|
56002
56363
|
context
|
|
56003
56364
|
);
|
|
56004
56365
|
string4(journal.packageHash, "Skill recovery package hash", HASH2);
|
|
56005
|
-
if (journal.version === 5) string4(journal.sourceHash, "Skill recovery source hash", HASH2);
|
|
56366
|
+
if (journal.version === 5 || journal.version === 6) string4(journal.sourceHash, "Skill recovery source hash", HASH2);
|
|
56367
|
+
if (journal.version === 6 && journal.pendingStage !== null && !["primary", "uri", "lit"].includes(String(journal.pendingStage))) {
|
|
56368
|
+
throw new TypeError("Skill recovery pending stage is invalid.");
|
|
56369
|
+
}
|
|
56006
56370
|
const encodedPackage = string4(journal.packageBytesBase64, "Skill recovery package bytes");
|
|
56007
56371
|
const packageBytes = Buffer.from(encodedPackage, "base64");
|
|
56008
56372
|
if (packageBytes.byteLength < 1 || packageBytes.byteLength > MAX_ENCRYPTED_BYTES || packageBytes.toString("base64") !== encodedPackage) throw new TypeError("Skill recovery package bytes are invalid.");
|
|
@@ -56052,6 +56416,7 @@ var init_skill_local_flow = __esm({
|
|
|
56052
56416
|
"use strict";
|
|
56053
56417
|
init_src2();
|
|
56054
56418
|
init_client();
|
|
56419
|
+
init_cli_error();
|
|
56055
56420
|
MAX_ENCRYPTED_BYTES = 10 * 1024 * 1024;
|
|
56056
56421
|
HASH2 = /^0x[0-9a-fA-F]{64}$/u;
|
|
56057
56422
|
IPFS = /^ipfs:\/\/(?:Qm[1-9A-HJ-NP-Za-km-z]{44}|b[a-z2-7]{20,})$/u;
|
|
@@ -56072,6 +56437,33 @@ var init_skill_local_flow = __esm({
|
|
|
56072
56437
|
pause;
|
|
56073
56438
|
nonce;
|
|
56074
56439
|
recovery;
|
|
56440
|
+
async publication(work) {
|
|
56441
|
+
const progress = { phase: "validation", journalSaved: false, uncertain: false };
|
|
56442
|
+
try {
|
|
56443
|
+
return await work(progress);
|
|
56444
|
+
} catch (cause) {
|
|
56445
|
+
const journal = progress.journal;
|
|
56446
|
+
if (journal && (journal.pendingStage != null || journal.version !== 6 && (journal.receipts.primary === null || journal.kind === "version" && journal.receipts.uri === null || journal.contentMode !== "plaintext" && journal.receipts.lit === null))) progress.uncertain = true;
|
|
56447
|
+
const transactionHashes = Object.fromEntries(Object.entries(progress.journal?.receipts ?? {}).flatMap(([stage, receipt]) => receipt && HASH2.test(receipt.transactionHash) ? [[stage, receipt.transactionHash]] : []));
|
|
56448
|
+
const fingerprint2 = progress.journal && progress.fingerprint ? progress.fingerprint : null;
|
|
56449
|
+
throw new CliSkillPublicationError({
|
|
56450
|
+
phase: progress.phase,
|
|
56451
|
+
fingerprint: fingerprint2,
|
|
56452
|
+
transactionHashes,
|
|
56453
|
+
submissionStatus: progress.uncertain ? "uncertain" : Object.keys(transactionHashes).length ? "hash_known" : "not_attempted",
|
|
56454
|
+
recoveryCommand: progress.journalSaved && !progress.uncertain && progress.phase !== "cleanup" && fingerprint2 ? `finch skill recover publication ${fingerprint2}` : null
|
|
56455
|
+
}, cause);
|
|
56456
|
+
}
|
|
56457
|
+
}
|
|
56458
|
+
async publish(path2, plan, context) {
|
|
56459
|
+
return this.publication((progress) => this.publishWithProgress(path2, plan, context, progress));
|
|
56460
|
+
}
|
|
56461
|
+
async publishVersion(path2, plan, context) {
|
|
56462
|
+
return this.publication((progress) => this.publishVersionWithProgress(path2, plan, context, progress));
|
|
56463
|
+
}
|
|
56464
|
+
async recoverPublication(fingerprint2, context) {
|
|
56465
|
+
return this.publication((progress) => this.recoverWithProgress(fingerprint2, context, progress));
|
|
56466
|
+
}
|
|
56075
56467
|
async send(context, action, request, prepared, authority, onBroadcast) {
|
|
56076
56468
|
return required2(this.sender.submitPrepared, "Skill prepared-intent sender").call(this.sender, {
|
|
56077
56469
|
privateKey: context.privateKey,
|
|
@@ -56084,7 +56476,7 @@ var init_skill_local_flow = __esm({
|
|
|
56084
56476
|
}
|
|
56085
56477
|
async upload(input) {
|
|
56086
56478
|
const { bytes } = input;
|
|
56087
|
-
if (bytes.byteLength === 0 || bytes.byteLength > MAX_ENCRYPTED_BYTES) throw new
|
|
56479
|
+
if (bytes.byteLength === 0 || bytes.byteLength > MAX_ENCRYPTED_BYTES) throw new CliSkillSourceError("SKILL_UPLOAD_SIZE_INVALID", { actualBytes: bytes.byteLength, maxBytes: MAX_ENCRYPTED_BYTES }, "Skill upload must be between 1 byte and 10 MiB, including package metadata and encryption overhead.");
|
|
56088
56480
|
const result2 = await required2(this.api.uploadSkillObject, "Skill upload").call(this.api, input);
|
|
56089
56481
|
return string4(result2.uri, "Pinned Skill URI", IPFS);
|
|
56090
56482
|
}
|
|
@@ -56129,25 +56521,49 @@ var init_skill_local_flow = __esm({
|
|
|
56129
56521
|
if ("delivery" in grant && grant.delivery === "oracle-v2") return openOracleKey(grant, device.privateKey);
|
|
56130
56522
|
throw new TypeError("Encrypted Skill downloads require an Oracle V2 sealed grant. Update the gateway.");
|
|
56131
56523
|
}
|
|
56132
|
-
async package(files, mode) {
|
|
56133
|
-
|
|
56134
|
-
|
|
56524
|
+
async package(files, mode, excluded = []) {
|
|
56525
|
+
try {
|
|
56526
|
+
if (mode === "plaintext") {
|
|
56527
|
+
const archived = await archivePackage(files, buildZip);
|
|
56528
|
+
return Object.freeze({
|
|
56529
|
+
archive: archived,
|
|
56530
|
+
contentKey: null,
|
|
56531
|
+
packageHash: archived.packageHash,
|
|
56532
|
+
mdHash: archived.primary.mdHash,
|
|
56533
|
+
excluded: [...excluded, ...archived.excluded]
|
|
56534
|
+
});
|
|
56535
|
+
}
|
|
56536
|
+
const sealed = await prepareRootPackage(files, buildZip);
|
|
56135
56537
|
return Object.freeze({
|
|
56136
|
-
archive:
|
|
56137
|
-
contentKey:
|
|
56138
|
-
packageHash:
|
|
56139
|
-
mdHash:
|
|
56140
|
-
excluded:
|
|
56538
|
+
archive: sealed,
|
|
56539
|
+
contentKey: sealed.contentKeyBase64,
|
|
56540
|
+
packageHash: sealed.packageHash,
|
|
56541
|
+
mdHash: sealed.primary.mdHash,
|
|
56542
|
+
excluded: [...excluded, ...sealed.excluded]
|
|
56141
56543
|
});
|
|
56544
|
+
} catch (error51) {
|
|
56545
|
+
if (error51 instanceof SkillZipSymlinkError) throw new CliSkillSourceError(
|
|
56546
|
+
"SKILL_SOURCE_SYMLINK_UNSUPPORTED",
|
|
56547
|
+
{ path: error51.path },
|
|
56548
|
+
"Skill source does not support symbolic links, including ZIP entries."
|
|
56549
|
+
);
|
|
56550
|
+
if (error51 instanceof SkillZipInvalidError) {
|
|
56551
|
+
const messages = {
|
|
56552
|
+
invalid_archive: "Skill ZIP is damaged or unsupported. Rebuild a regular ZIP and try again.",
|
|
56553
|
+
archive_too_large: "Skill ZIP exceeds the 10 MiB compressed import limit. Reduce the archive size and try again.",
|
|
56554
|
+
expanded_content_too_large: "Skill ZIP declares expanded content above the 10 MiB import limit. Reduce the uncompressed content and rebuild the ZIP.",
|
|
56555
|
+
utf8_flag_missing: "Skill ZIP filenames with non-ASCII characters must declare UTF-8 (bit 11). Rebuild the ZIP with UTF-8 filenames and flags.",
|
|
56556
|
+
filename_encoding_invalid: "Skill ZIP filename bytes are not valid UTF-8. Rebuild the ZIP with UTF-8 filenames and flags."
|
|
56557
|
+
};
|
|
56558
|
+
throw new CliSkillSourceError("SKILL_SOURCE_ZIP_INVALID", { zipReason: error51.reason, ...error51.details }, messages[error51.reason]);
|
|
56559
|
+
}
|
|
56560
|
+
if (error51 instanceof SkillPrimaryDocumentError) throw new CliSkillSourceError(
|
|
56561
|
+
"SKILL_SOURCE_PRIMARY_DOCUMENT_INVALID",
|
|
56562
|
+
{},
|
|
56563
|
+
"Skill package needs a valid UTF-8 SKILL.md or README.md at its root, or exactly one root Markdown file."
|
|
56564
|
+
);
|
|
56565
|
+
throw error51;
|
|
56142
56566
|
}
|
|
56143
|
-
const sealed = await prepareRootPackage(files, buildZip);
|
|
56144
|
-
return Object.freeze({
|
|
56145
|
-
archive: sealed,
|
|
56146
|
-
contentKey: sealed.contentKeyBase64,
|
|
56147
|
-
packageHash: sealed.packageHash,
|
|
56148
|
-
mdHash: sealed.primary.mdHash,
|
|
56149
|
-
excluded: sealed.excluded
|
|
56150
|
-
});
|
|
56151
56567
|
}
|
|
56152
56568
|
async protectedEnvelope(context, chainId, skillId, version6, mode, packageContentKey) {
|
|
56153
56569
|
if (mode === "finchip_v2") {
|
|
@@ -56201,15 +56617,31 @@ var init_skill_local_flow = __esm({
|
|
|
56201
56617
|
async project(chainId, transactionHash3, bearer) {
|
|
56202
56618
|
await this.api.confirmSkillProjection?.(chainId, transactionHash3, bearer);
|
|
56203
56619
|
}
|
|
56204
|
-
async stage(context, fingerprint2, journal, stage, action, request, prepare) {
|
|
56620
|
+
async stage(progress, context, fingerprint2, journal, stage, action, request, prepare) {
|
|
56621
|
+
progress.journal = journal;
|
|
56622
|
+
progress.fingerprint = fingerprint2;
|
|
56623
|
+
progress.journalSaved = true;
|
|
56624
|
+
progress.phase = "transaction";
|
|
56205
56625
|
const existing = journal.receipts[stage];
|
|
56206
56626
|
if (existing !== null) {
|
|
56207
56627
|
journal.receipts[stage] = await this.verify(context, action, request, existing);
|
|
56628
|
+
if (journal.pendingStage === stage) journal.pendingStage = null;
|
|
56208
56629
|
await this.save(fingerprint2, journal);
|
|
56630
|
+
progress.uncertain = false;
|
|
56631
|
+
progress.phase = "projection";
|
|
56209
56632
|
await this.project(journal.chainId, journal.receipts[stage].transactionHash, context.bearer);
|
|
56210
56633
|
return;
|
|
56211
56634
|
}
|
|
56635
|
+
if (journal.version !== 6 || journal.pendingStage != null) {
|
|
56636
|
+
progress.uncertain = true;
|
|
56637
|
+
throw new Error("Skill transaction submission state is uncertain. Contact support before retrying.");
|
|
56638
|
+
}
|
|
56639
|
+
progress.phase = "intent";
|
|
56212
56640
|
const prepared = await prepare();
|
|
56641
|
+
progress.phase = "transaction";
|
|
56642
|
+
journal.pendingStage = stage;
|
|
56643
|
+
await this.save(fingerprint2, journal);
|
|
56644
|
+
progress.uncertain = true;
|
|
56213
56645
|
journal.receipts[stage] = await this.send(
|
|
56214
56646
|
context,
|
|
56215
56647
|
action,
|
|
@@ -56219,12 +56651,19 @@ var init_skill_local_flow = __esm({
|
|
|
56219
56651
|
async ({ transactionHash: transactionHash3 }) => {
|
|
56220
56652
|
journal.receipts[stage] = { transactionHash: transactionHash3, blockNumber: null };
|
|
56221
56653
|
await this.save(fingerprint2, journal);
|
|
56654
|
+
journal.pendingStage = null;
|
|
56655
|
+
await this.save(fingerprint2, journal);
|
|
56656
|
+
progress.uncertain = false;
|
|
56222
56657
|
}
|
|
56223
56658
|
);
|
|
56659
|
+
journal.pendingStage = null;
|
|
56224
56660
|
await this.save(fingerprint2, journal);
|
|
56661
|
+
progress.uncertain = false;
|
|
56662
|
+
progress.phase = "projection";
|
|
56225
56663
|
await this.project(journal.chainId, journal.receipts[stage].transactionHash, context.bearer);
|
|
56226
56664
|
}
|
|
56227
|
-
async
|
|
56665
|
+
async recoverWithProgress(fingerprint2, context, progress) {
|
|
56666
|
+
progress.phase = "recovery";
|
|
56228
56667
|
if (!/^[0-9a-f]{64}$/u.test(fingerprint2)) throw new TypeError("Skill publication recovery fingerprint is invalid.");
|
|
56229
56668
|
const store = required2(this.recovery, "Skill publication recovery");
|
|
56230
56669
|
const stored = await store.readSkillPublicationRecovery(fingerprint2);
|
|
@@ -56232,8 +56671,12 @@ var init_skill_local_flow = __esm({
|
|
|
56232
56671
|
const candidate = object2(stored, "Skill publication recovery");
|
|
56233
56672
|
if (candidate.kind !== "publish" && candidate.kind !== "version") throw new TypeError("Skill publication recovery kind is invalid.");
|
|
56234
56673
|
const journal = recoveryJournal(stored, fingerprint2, candidate.kind, context);
|
|
56674
|
+
progress.journal = journal;
|
|
56675
|
+
progress.fingerprint = fingerprint2;
|
|
56676
|
+
progress.journalSaved = true;
|
|
56235
56677
|
if (journal.kind === "publish") {
|
|
56236
56678
|
await this.stage(
|
|
56679
|
+
progress,
|
|
56237
56680
|
context,
|
|
56238
56681
|
fingerprint2,
|
|
56239
56682
|
journal,
|
|
@@ -56258,6 +56701,7 @@ var init_skill_local_flow = __esm({
|
|
|
56258
56701
|
journal.skillId = skillId2;
|
|
56259
56702
|
if (journal.contentMode !== "plaintext") {
|
|
56260
56703
|
if (journal.requests.lit === null) {
|
|
56704
|
+
progress.phase = "key_custody";
|
|
56261
56705
|
journal.requests.lit = await this.protectedEnvelope(
|
|
56262
56706
|
context,
|
|
56263
56707
|
journal.chainId,
|
|
@@ -56270,6 +56714,7 @@ var init_skill_local_flow = __esm({
|
|
|
56270
56714
|
}
|
|
56271
56715
|
const litRequest = required2(journal.requests.lit, "Skill Lit recovery request");
|
|
56272
56716
|
await this.stage(
|
|
56717
|
+
progress,
|
|
56273
56718
|
context,
|
|
56274
56719
|
fingerprint2,
|
|
56275
56720
|
journal,
|
|
@@ -56279,6 +56724,7 @@ var init_skill_local_flow = __esm({
|
|
|
56279
56724
|
() => required2(this.api.requestSkillIntent, "Skill intent API").call(this.api, litRequest, context.bearer)
|
|
56280
56725
|
);
|
|
56281
56726
|
}
|
|
56727
|
+
progress.phase = "cleanup";
|
|
56282
56728
|
await store.clearSkillPublicationRecovery(fingerprint2);
|
|
56283
56729
|
return {
|
|
56284
56730
|
chainId: journal.chainId,
|
|
@@ -56297,6 +56743,7 @@ var init_skill_local_flow = __esm({
|
|
|
56297
56743
|
}
|
|
56298
56744
|
const skillId = required2(journal.skillId, "Skill recovery id");
|
|
56299
56745
|
await this.stage(
|
|
56746
|
+
progress,
|
|
56300
56747
|
context,
|
|
56301
56748
|
fingerprint2,
|
|
56302
56749
|
journal,
|
|
@@ -56316,6 +56763,7 @@ var init_skill_local_flow = __esm({
|
|
|
56316
56763
|
);
|
|
56317
56764
|
const uriRequest = required2(journal.requests.uri, "Skill URI recovery request");
|
|
56318
56765
|
await this.stage(
|
|
56766
|
+
progress,
|
|
56319
56767
|
context,
|
|
56320
56768
|
fingerprint2,
|
|
56321
56769
|
journal,
|
|
@@ -56326,6 +56774,7 @@ var init_skill_local_flow = __esm({
|
|
|
56326
56774
|
);
|
|
56327
56775
|
if (journal.contentMode !== "plaintext") {
|
|
56328
56776
|
if (journal.requests.lit === null) {
|
|
56777
|
+
progress.phase = "key_custody";
|
|
56329
56778
|
journal.requests.lit = await this.protectedEnvelope(
|
|
56330
56779
|
context,
|
|
56331
56780
|
journal.chainId,
|
|
@@ -56338,6 +56787,7 @@ var init_skill_local_flow = __esm({
|
|
|
56338
56787
|
}
|
|
56339
56788
|
const litRequest = required2(journal.requests.lit, "Skill Lit recovery request");
|
|
56340
56789
|
await this.stage(
|
|
56790
|
+
progress,
|
|
56341
56791
|
context,
|
|
56342
56792
|
fingerprint2,
|
|
56343
56793
|
journal,
|
|
@@ -56347,6 +56797,7 @@ var init_skill_local_flow = __esm({
|
|
|
56347
56797
|
() => required2(this.api.requestSkillIntent, "Skill intent API").call(this.api, litRequest, context.bearer)
|
|
56348
56798
|
);
|
|
56349
56799
|
}
|
|
56800
|
+
progress.phase = "cleanup";
|
|
56350
56801
|
await store.clearSkillPublicationRecovery(fingerprint2);
|
|
56351
56802
|
return {
|
|
56352
56803
|
chainId: journal.chainId,
|
|
@@ -56364,23 +56815,32 @@ var init_skill_local_flow = __esm({
|
|
|
56364
56815
|
}
|
|
56365
56816
|
};
|
|
56366
56817
|
}
|
|
56367
|
-
async
|
|
56818
|
+
async publishWithProgress(path2, planValue, context, progress) {
|
|
56368
56819
|
const plan = publishPlan(planValue, context);
|
|
56369
56820
|
const request = plan.request;
|
|
56370
56821
|
const fingerprint2 = recoveryFingerprint("publish", planValue, context.walletAddress);
|
|
56371
56822
|
const store = required2(this.recovery, "Skill publication recovery");
|
|
56823
|
+
progress.phase = "recovery";
|
|
56824
|
+
const prior = await store.readSkillPublicationRecovery(fingerprint2);
|
|
56825
|
+
if (prior !== null) {
|
|
56826
|
+
progress.journal = recoveryJournal(prior, fingerprint2, "publish", context);
|
|
56827
|
+
progress.fingerprint = fingerprint2;
|
|
56828
|
+
progress.journalSaved = true;
|
|
56829
|
+
}
|
|
56830
|
+
progress.phase = "source";
|
|
56372
56831
|
const selected = await readPublishablePath(path2);
|
|
56373
56832
|
const expectedSourceKind = sourceKind(request.sourceKind);
|
|
56374
56833
|
const mode = contentMode(request.contentMode);
|
|
56375
56834
|
if (selected.sourceKind !== expectedSourceKind) throw new TypeError(`Skill plan requires a ${expectedSourceKind} source.`);
|
|
56376
|
-
|
|
56377
|
-
const packaged = await this.package(selected.files, prior === null ? mode : "plaintext");
|
|
56835
|
+
progress.phase = "packaging";
|
|
56836
|
+
const packaged = await this.package(selected.files, prior === null ? mode : "plaintext", selected.excluded);
|
|
56378
56837
|
let journal;
|
|
56379
56838
|
if (prior !== null) {
|
|
56380
56839
|
journal = recoveryJournal(prior, fingerprint2, "publish", context);
|
|
56381
56840
|
if (journal.sourceKind !== expectedSourceKind || journal.contentMode !== mode || (journal.sourceHash ?? journal.packageHash).toLowerCase() !== packaged.packageHash.toLowerCase() || canonical(journal.excluded) !== canonical(packaged.excluded)) throw new TypeError("Skill publication content no longer matches its protected recovery.");
|
|
56382
56841
|
} else {
|
|
56383
56842
|
let publishedBytes;
|
|
56843
|
+
progress.phase = "packaging";
|
|
56384
56844
|
const entry2 = await buildPublicationEntry({
|
|
56385
56845
|
files: selected.files,
|
|
56386
56846
|
archive: packaged.archive,
|
|
@@ -56389,6 +56849,7 @@ var init_skill_local_flow = __esm({
|
|
|
56389
56849
|
summary: request.summary === void 0 ? "" : String(request.summary),
|
|
56390
56850
|
pinBundle: async (bytes) => {
|
|
56391
56851
|
publishedBytes = bytes;
|
|
56852
|
+
progress.phase = "upload";
|
|
56392
56853
|
return this.upload({
|
|
56393
56854
|
bytes,
|
|
56394
56855
|
filename: `${request.slug}.skillroot.zip`,
|
|
@@ -56418,7 +56879,8 @@ var init_skill_local_flow = __esm({
|
|
|
56418
56879
|
packageURI: manifestURI
|
|
56419
56880
|
};
|
|
56420
56881
|
journal = {
|
|
56421
|
-
version:
|
|
56882
|
+
version: 6,
|
|
56883
|
+
pendingStage: null,
|
|
56422
56884
|
sourceHash: packaged.packageHash,
|
|
56423
56885
|
kind: "publish",
|
|
56424
56886
|
fingerprint: fingerprint2,
|
|
@@ -56438,9 +56900,14 @@ var init_skill_local_flow = __esm({
|
|
|
56438
56900
|
requests: { primary: createRequest, uri: null, lit: null },
|
|
56439
56901
|
receipts: { primary: null, uri: null, lit: null }
|
|
56440
56902
|
};
|
|
56903
|
+
progress.journal = journal;
|
|
56904
|
+
progress.fingerprint = fingerprint2;
|
|
56905
|
+
progress.phase = "recovery";
|
|
56441
56906
|
await this.save(fingerprint2, journal);
|
|
56907
|
+
progress.journalSaved = true;
|
|
56442
56908
|
}
|
|
56443
56909
|
await this.stage(
|
|
56910
|
+
progress,
|
|
56444
56911
|
context,
|
|
56445
56912
|
fingerprint2,
|
|
56446
56913
|
journal,
|
|
@@ -56464,6 +56931,7 @@ var init_skill_local_flow = __esm({
|
|
|
56464
56931
|
journal.skillId = skillId;
|
|
56465
56932
|
if (journal.contentMode !== "plaintext") {
|
|
56466
56933
|
if (journal.requests.lit === null) {
|
|
56934
|
+
progress.phase = "key_custody";
|
|
56467
56935
|
journal.requests.lit = await this.protectedEnvelope(
|
|
56468
56936
|
context,
|
|
56469
56937
|
journal.chainId,
|
|
@@ -56476,6 +56944,7 @@ var init_skill_local_flow = __esm({
|
|
|
56476
56944
|
}
|
|
56477
56945
|
const litRequest = required2(journal.requests.lit, "Skill Lit recovery request");
|
|
56478
56946
|
await this.stage(
|
|
56947
|
+
progress,
|
|
56479
56948
|
context,
|
|
56480
56949
|
fingerprint2,
|
|
56481
56950
|
journal,
|
|
@@ -56485,14 +56954,21 @@ var init_skill_local_flow = __esm({
|
|
|
56485
56954
|
() => required2(this.api.requestSkillIntent, "Skill intent API").call(this.api, litRequest, context.bearer)
|
|
56486
56955
|
);
|
|
56487
56956
|
}
|
|
56957
|
+
progress.phase = "cleanup";
|
|
56488
56958
|
await store.clearSkillPublicationRecovery(fingerprint2);
|
|
56489
56959
|
return { chainId: journal.chainId, skillId, version: 1, contentMode: journal.contentMode, packageHash: journal.packageHash, excluded: journal.excluded, transactions: { create: required2(journal.receipts.primary, "Skill create receipt").transactionHash, ...journal.contentMode === "plaintext" ? {} : { setLitData: required2(journal.receipts.lit, "Skill Lit receipt").transactionHash } } };
|
|
56490
56960
|
}
|
|
56491
|
-
async
|
|
56961
|
+
async publishVersionWithProgress(path2, planValue, context, progress) {
|
|
56492
56962
|
const plan = versionPlan(planValue, context);
|
|
56493
56963
|
const fingerprint2 = recoveryFingerprint("version", planValue, context.walletAddress);
|
|
56964
|
+
progress.phase = "recovery";
|
|
56494
56965
|
const store = required2(this.recovery, "Skill publication recovery");
|
|
56495
56966
|
const prior = await store.readSkillPublicationRecovery(fingerprint2);
|
|
56967
|
+
if (prior !== null) {
|
|
56968
|
+
progress.journal = recoveryJournal(prior, fingerprint2, "version", context);
|
|
56969
|
+
progress.fingerprint = fingerprint2;
|
|
56970
|
+
progress.journalSaved = true;
|
|
56971
|
+
}
|
|
56496
56972
|
const observedVersion = await required2(this.api.readSkillCurrentVersion, "Skill version API").call(
|
|
56497
56973
|
this.api,
|
|
56498
56974
|
plan.chainId,
|
|
@@ -56502,9 +56978,11 @@ var init_skill_local_flow = __esm({
|
|
|
56502
56978
|
if (prior === null && observedVersion !== plan.currentVersion) {
|
|
56503
56979
|
throw new TypeError(`Skill current version ${observedVersion} no longer matches plan version ${plan.currentVersion}.`);
|
|
56504
56980
|
}
|
|
56981
|
+
progress.phase = "source";
|
|
56505
56982
|
const selected = await readPublishablePath(path2);
|
|
56506
56983
|
if (selected.sourceKind !== plan.sourceKind) throw new TypeError(`Skill plan requires a ${plan.sourceKind} source.`);
|
|
56507
|
-
|
|
56984
|
+
progress.phase = "packaging";
|
|
56985
|
+
const packaged = await this.package(selected.files, prior === null ? plan.contentMode : "plaintext", selected.excluded);
|
|
56508
56986
|
let journal;
|
|
56509
56987
|
if (prior !== null) {
|
|
56510
56988
|
journal = recoveryJournal(prior, fingerprint2, "version", context);
|
|
@@ -56516,6 +56994,7 @@ var init_skill_local_flow = __esm({
|
|
|
56516
56994
|
const previous = packageForVersion(currentManifest, plan.currentVersion);
|
|
56517
56995
|
if (previous === null) throw new TypeError("Current Skill version is missing from its manifest.");
|
|
56518
56996
|
let publishedBytes;
|
|
56997
|
+
progress.phase = "packaging";
|
|
56519
56998
|
const entry2 = await buildPublicationEntry({
|
|
56520
56999
|
files: selected.files,
|
|
56521
57000
|
archive: packaged.archive,
|
|
@@ -56523,9 +57002,10 @@ var init_skill_local_flow = __esm({
|
|
|
56523
57002
|
previous,
|
|
56524
57003
|
pinBundle: async (bytes, legacy) => {
|
|
56525
57004
|
publishedBytes = bytes;
|
|
57005
|
+
progress.phase = "upload";
|
|
56526
57006
|
return this.upload({
|
|
56527
57007
|
bytes,
|
|
56528
|
-
filename: `skill-${plan.request.skillId}-v${plan.nextVersion}.skillroot.zip`,
|
|
57008
|
+
filename: `skill-${plan.request.skillId}-v${plan.nextVersion}${legacy ? plan.contentMode === "plaintext" ? ".zip" : ".enc" : ".skillroot.zip"}`,
|
|
56529
57009
|
bearer: context.bearer,
|
|
56530
57010
|
objectKind: "package",
|
|
56531
57011
|
sourceKind: legacy ? plan.sourceKind : "file",
|
|
@@ -56543,7 +57023,8 @@ var init_skill_local_flow = __esm({
|
|
|
56543
57023
|
const updateRequest = { action: "updateSkill", chainId: plan.chainId, skillId: plan.request.skillId, mdHash: packaged.mdHash, packageHash: entry2.packageHash, packageURI: manifestURI };
|
|
56544
57024
|
const uriRequest2 = { action: "setSkillURI", chainId: plan.chainId, skillId: plan.request.skillId, packageURI: manifestURI };
|
|
56545
57025
|
journal = {
|
|
56546
|
-
version:
|
|
57026
|
+
version: 6,
|
|
57027
|
+
pendingStage: null,
|
|
56547
57028
|
sourceHash: packaged.packageHash,
|
|
56548
57029
|
kind: "version",
|
|
56549
57030
|
fingerprint: fingerprint2,
|
|
@@ -56563,9 +57044,14 @@ var init_skill_local_flow = __esm({
|
|
|
56563
57044
|
requests: { primary: updateRequest, uri: uriRequest2, lit: null },
|
|
56564
57045
|
receipts: { primary: null, uri: null, lit: null }
|
|
56565
57046
|
};
|
|
57047
|
+
progress.journal = journal;
|
|
57048
|
+
progress.fingerprint = fingerprint2;
|
|
57049
|
+
progress.phase = "recovery";
|
|
56566
57050
|
await this.save(fingerprint2, journal);
|
|
57051
|
+
progress.journalSaved = true;
|
|
56567
57052
|
}
|
|
56568
57053
|
await this.stage(
|
|
57054
|
+
progress,
|
|
56569
57055
|
context,
|
|
56570
57056
|
fingerprint2,
|
|
56571
57057
|
journal,
|
|
@@ -56582,6 +57068,7 @@ var init_skill_local_flow = __esm({
|
|
|
56582
57068
|
) === plan.nextVersion, `Skill ${plan.request.skillId} version ${plan.nextVersion}`);
|
|
56583
57069
|
const uriRequest = required2(journal.requests.uri, "Skill URI recovery request");
|
|
56584
57070
|
await this.stage(
|
|
57071
|
+
progress,
|
|
56585
57072
|
context,
|
|
56586
57073
|
fingerprint2,
|
|
56587
57074
|
journal,
|
|
@@ -56592,6 +57079,7 @@ var init_skill_local_flow = __esm({
|
|
|
56592
57079
|
);
|
|
56593
57080
|
if (journal.contentMode !== "plaintext") {
|
|
56594
57081
|
if (journal.requests.lit === null) {
|
|
57082
|
+
progress.phase = "key_custody";
|
|
56595
57083
|
journal.requests.lit = await this.protectedEnvelope(
|
|
56596
57084
|
context,
|
|
56597
57085
|
journal.chainId,
|
|
@@ -56604,6 +57092,7 @@ var init_skill_local_flow = __esm({
|
|
|
56604
57092
|
}
|
|
56605
57093
|
const litRequest = required2(journal.requests.lit, "Skill Lit recovery request");
|
|
56606
57094
|
await this.stage(
|
|
57095
|
+
progress,
|
|
56607
57096
|
context,
|
|
56608
57097
|
fingerprint2,
|
|
56609
57098
|
journal,
|
|
@@ -56613,6 +57102,7 @@ var init_skill_local_flow = __esm({
|
|
|
56613
57102
|
() => required2(this.api.requestSkillIntent, "Skill intent API").call(this.api, litRequest, context.bearer)
|
|
56614
57103
|
);
|
|
56615
57104
|
}
|
|
57105
|
+
progress.phase = "cleanup";
|
|
56616
57106
|
await store.clearSkillPublicationRecovery(fingerprint2);
|
|
56617
57107
|
return { chainId: journal.chainId, skillId: plan.request.skillId, version: plan.nextVersion, contentMode: journal.contentMode, packageHash: journal.packageHash, excluded: journal.excluded, transactions: { update: required2(journal.receipts.primary, "Skill update receipt").transactionHash, setSkillURI: required2(journal.receipts.uri, "Skill URI receipt").transactionHash, ...journal.contentMode === "plaintext" ? {} : { setLitData: required2(journal.receipts.lit, "Skill Lit receipt").transactionHash } } };
|
|
56618
57108
|
}
|
|
@@ -56673,12 +57163,12 @@ var init_skill_local_flow = __esm({
|
|
|
56673
57163
|
async download(planValue, context) {
|
|
56674
57164
|
const plan = deliveryPlan(planValue, context);
|
|
56675
57165
|
const located = await this.fetchDeliveryContent(plan.packageURI, context?.bearer);
|
|
56676
|
-
const
|
|
57166
|
+
const manifest4 = parseManifest(located);
|
|
56677
57167
|
let stored = located;
|
|
56678
57168
|
const expectedHash = plan.packageHash;
|
|
56679
|
-
const root =
|
|
56680
|
-
if (
|
|
56681
|
-
const entry2 = packageForVersion(
|
|
57169
|
+
const root = manifest4 === null ? void 0 : packageForVersion(manifest4, plan.version)?.skillRoot;
|
|
57170
|
+
if (manifest4 !== null) {
|
|
57171
|
+
const entry2 = packageForVersion(manifest4, plan.version);
|
|
56682
57172
|
if (entry2 === null) throw new TypeError(`Skill manifest does not list version ${plan.version}.`);
|
|
56683
57173
|
if (entry2.packageHash.toLowerCase() !== plan.packageHash.toLowerCase()) throw new TypeError("Skill manifest package hash does not match chain authority.");
|
|
56684
57174
|
stored = await this.fetchDeliveryContent(entry2.packageURI, context?.bearer);
|
|
@@ -56857,48 +57347,6 @@ var init_skill_buyer_intent_journal = __esm({
|
|
|
56857
57347
|
}
|
|
56858
57348
|
});
|
|
56859
57349
|
|
|
56860
|
-
// src/cli-error.ts
|
|
56861
|
-
var CliAuthorityError, CliProductionUnavailableError, BrowserOpenError, PUBLIC_RECOVERY_COMMAND, CliRecoveryBlockedError;
|
|
56862
|
-
var init_cli_error = __esm({
|
|
56863
|
-
"src/cli-error.ts"() {
|
|
56864
|
-
"use strict";
|
|
56865
|
-
CliAuthorityError = class extends Error {
|
|
56866
|
-
code = "MCP_CLI_WALLET_MISMATCH";
|
|
56867
|
-
constructor(code = "MCP_CLI_WALLET_MISMATCH") {
|
|
56868
|
-
super(code);
|
|
56869
|
-
this.name = "CliAuthorityError";
|
|
56870
|
-
}
|
|
56871
|
-
};
|
|
56872
|
-
CliProductionUnavailableError = class extends Error {
|
|
56873
|
-
code = "PRODUCTION_NOT_AVAILABLE";
|
|
56874
|
-
constructor() {
|
|
56875
|
-
super("PRODUCTION_NOT_AVAILABLE");
|
|
56876
|
-
this.name = "CliProductionUnavailableError";
|
|
56877
|
-
}
|
|
56878
|
-
};
|
|
56879
|
-
BrowserOpenError = class extends Error {
|
|
56880
|
-
code = "BROWSER_OPEN_FAILED";
|
|
56881
|
-
constructor() {
|
|
56882
|
-
super("BROWSER_OPEN_FAILED");
|
|
56883
|
-
this.name = "BrowserOpenError";
|
|
56884
|
-
}
|
|
56885
|
-
};
|
|
56886
|
-
PUBLIC_RECOVERY_COMMAND = /^(?:finch purchase (?:submit|recover-approval) [0-9a-f-]+(?: --transaction-hash 0x[0-9a-f]{64})?|finch task recover [0-9a-f-]+ (?:publish|award|reclaim)|finch skill recover (?:publication|intent) [0-9a-f]{64})$/u;
|
|
56887
|
-
CliRecoveryBlockedError = class extends Error {
|
|
56888
|
-
code = "CLI_RECOVERY_BLOCKED";
|
|
56889
|
-
recoveryCommands;
|
|
56890
|
-
constructor(recoveryCommands) {
|
|
56891
|
-
if (recoveryCommands.length === 0 || recoveryCommands.some((command) => !PUBLIC_RECOVERY_COMMAND.test(command))) {
|
|
56892
|
-
throw new TypeError("Recovery commands must contain only supported public recovery syntax.");
|
|
56893
|
-
}
|
|
56894
|
-
super("CLI_RECOVERY_BLOCKED");
|
|
56895
|
-
this.name = "CliRecoveryBlockedError";
|
|
56896
|
-
this.recoveryCommands = Object.freeze([...new Set(recoveryCommands)].sort());
|
|
56897
|
-
}
|
|
56898
|
-
};
|
|
56899
|
-
}
|
|
56900
|
-
});
|
|
56901
|
-
|
|
56902
57350
|
// src/application.ts
|
|
56903
57351
|
import { createHash as createHash3, randomUUID } from "node:crypto";
|
|
56904
57352
|
import { open as open2 } from "node:fs/promises";
|
|
@@ -57665,6 +58113,11 @@ var init_application = __esm({
|
|
|
57665
58113
|
}
|
|
57666
58114
|
return Object.freeze({
|
|
57667
58115
|
ready: true,
|
|
58116
|
+
readinessScope: "cli_session_and_mcp_discovery",
|
|
58117
|
+
harnessOAuth: Object.freeze({
|
|
58118
|
+
status: "not_checked",
|
|
58119
|
+
guidance: "Verify the connected MCP identity with identity_actor_get and compare it with finch status. If the Harness reports missing or expired OAuth credentials, reauthorize through its native MCP login flow."
|
|
58120
|
+
}),
|
|
57668
58121
|
environment: session.environment,
|
|
57669
58122
|
origin: profile.origin,
|
|
57670
58123
|
loginChainId: session.loginChainId,
|
|
@@ -58484,7 +58937,7 @@ var init_package = __esm({
|
|
|
58484
58937
|
"package.json"() {
|
|
58485
58938
|
package_default = {
|
|
58486
58939
|
name: "@finchtech/cli",
|
|
58487
|
-
version: "0.3.
|
|
58940
|
+
version: "0.3.3",
|
|
58488
58941
|
description: "Finch Agent CLI for wallet-owned marketplace and MCP workflows.",
|
|
58489
58942
|
type: "module",
|
|
58490
58943
|
bin: {
|
|
@@ -59543,6 +59996,8 @@ function hasAgentPurchaseCheckpoint(value) {
|
|
|
59543
59996
|
}
|
|
59544
59997
|
function hasSkillPublicationCheckpoint(value) {
|
|
59545
59998
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
59999
|
+
const journal = value;
|
|
60000
|
+
if (journal.version === 6 && ["primary", "uri", "lit"].includes(String(journal.pendingStage))) return true;
|
|
59546
60001
|
const receipts = value.receipts;
|
|
59547
60002
|
if (typeof receipts !== "object" || receipts === null || Array.isArray(receipts)) return false;
|
|
59548
60003
|
const stages = receipts;
|
|
@@ -61620,6 +62075,14 @@ function localFailureMessage(error51) {
|
|
|
61620
62075
|
return "Command input does not match the expected schema. Check finch help for this command.";
|
|
61621
62076
|
}
|
|
61622
62077
|
function failure(error51) {
|
|
62078
|
+
if (error51 instanceof CliSkillSourceError) {
|
|
62079
|
+
return {
|
|
62080
|
+
code: "AGENT_MARKET_REQUEST_INVALID",
|
|
62081
|
+
exitCode: 2,
|
|
62082
|
+
message: error51.message,
|
|
62083
|
+
state: JSON.stringify({ diagnosticCode: error51.diagnosticCode, ...error51.details })
|
|
62084
|
+
};
|
|
62085
|
+
}
|
|
61623
62086
|
if (error51 instanceof CliAuthorityError) {
|
|
61624
62087
|
return {
|
|
61625
62088
|
code: error51.code,
|
|
@@ -61662,6 +62125,30 @@ function emitCliOutcome(outcome, sinks) {
|
|
|
61662
62125
|
`);
|
|
61663
62126
|
return AGENT_CLI_OUTPUT_CONTRACT.exitCodes.success;
|
|
61664
62127
|
}
|
|
62128
|
+
if (outcome instanceof CliSkillPublicationError) {
|
|
62129
|
+
let serialized = "";
|
|
62130
|
+
const cause = outcome.cause instanceof Error ? outcome.cause : new Error("Skill publication failed.");
|
|
62131
|
+
const exitCode = emitCliOutcome(cause, { stdout: (value) => {
|
|
62132
|
+
serialized = value;
|
|
62133
|
+
}, stderr: sinks.stderr });
|
|
62134
|
+
const envelope2 = JSON.parse(serialized);
|
|
62135
|
+
const source = cause instanceof CliSkillSourceError ? cause : null;
|
|
62136
|
+
const remote = cause instanceof CliHttpError && cause.envelope !== null;
|
|
62137
|
+
const diagnostic = outcome.diagnostic;
|
|
62138
|
+
envelope2.error.state = JSON.stringify({
|
|
62139
|
+
diagnosticCode: source?.diagnosticCode ?? "SKILL_PUBLICATION_FAILED",
|
|
62140
|
+
...source?.details,
|
|
62141
|
+
...diagnostic,
|
|
62142
|
+
...cause instanceof CliHttpError ? { remoteStatus: cause.status, ...cause.diagnostic } : {},
|
|
62143
|
+
...remote ? { remoteStatus: cause.status, remoteState: envelope2.error.state } : {}
|
|
62144
|
+
});
|
|
62145
|
+
envelope2.error.retryable = false;
|
|
62146
|
+
if (!source && !remote && diagnostic.phase !== "validation") envelope2.error.message = `Skill publication failed during ${diagnostic.phase}. ${diagnostic.recoveryCommand ? "Use the recovery command in state; do not resubmit." : diagnostic.submissionStatus === "uncertain" ? "Broadcast outcome or checkpoint is uncertain. Contact support before retrying or recovering." : "Contact support with the public diagnostic state before retrying."}`;
|
|
62147
|
+
envelope2.error.nextAction = diagnostic.submissionStatus === "uncertain" ? "contact_support" : diagnostic.recoveryCommand ? "refresh_resource" : source ? "fix_request" : (remote || diagnostic.phase === "validation") && ["authenticate", "request_scope", "fix_request"].includes(String(envelope2.error.nextAction)) ? envelope2.error.nextAction : "contact_support";
|
|
62148
|
+
sinks.stdout(`${JSON.stringify(envelope2)}
|
|
62149
|
+
`);
|
|
62150
|
+
return exitCode;
|
|
62151
|
+
}
|
|
61665
62152
|
if (outcome instanceof BrowserOpenError) {
|
|
61666
62153
|
sinks.stdout(`${JSON.stringify({ error: {
|
|
61667
62154
|
code: outcome.code,
|
|
@@ -61692,7 +62179,7 @@ function emitCliOutcome(outcome, sinks) {
|
|
|
61692
62179
|
reasonCode: null,
|
|
61693
62180
|
retryable: definition.retryable,
|
|
61694
62181
|
nextAction: definition.nextAction,
|
|
61695
|
-
state: mapped.state ?? null,
|
|
62182
|
+
state: mapped.state ?? (outcome instanceof CliHttpError && outcome.diagnostic !== null ? JSON.stringify({ remoteStatus: outcome.status, ...outcome.diagnostic }) : null),
|
|
61696
62183
|
operationId: null,
|
|
61697
62184
|
currentRevision: null,
|
|
61698
62185
|
currentEtag: null,
|