linkque-cli-v2 1.6.14 → 1.6.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/linkquejs.js +805 -484
- package/package.json +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-OLLACFP7.js → chunk-2O5AZ546.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-PSKPY5FI.js → chunk-ZK7HXMMY.js} +97 -21
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-M5DHKJDG.js → chunk-ZQGBHENQ.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js +28 -77
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/clientCapability.js +2 -2
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/protocol.js +2 -2
- package/vendor/linkque-agent-appwrite-integrate/package.json +1 -1
- package/worker.js +124 -98
package/linkquejs.js
CHANGED
|
@@ -1196,7 +1196,7 @@ var require_command = __commonJS({
|
|
|
1196
1196
|
"../../node_modules/commander/lib/command.js"(exports2) {
|
|
1197
1197
|
var EventEmitter = require("node:events").EventEmitter;
|
|
1198
1198
|
var childProcess = require("node:child_process");
|
|
1199
|
-
var
|
|
1199
|
+
var path25 = require("node:path");
|
|
1200
1200
|
var fs2 = require("node:fs");
|
|
1201
1201
|
var process2 = require("node:process");
|
|
1202
1202
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
@@ -2209,9 +2209,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2209
2209
|
let launchWithNode = false;
|
|
2210
2210
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
2211
2211
|
function findFile(baseDir, baseName) {
|
|
2212
|
-
const localBin =
|
|
2212
|
+
const localBin = path25.resolve(baseDir, baseName);
|
|
2213
2213
|
if (fs2.existsSync(localBin)) return localBin;
|
|
2214
|
-
if (sourceExt.includes(
|
|
2214
|
+
if (sourceExt.includes(path25.extname(baseName))) return void 0;
|
|
2215
2215
|
const foundExt = sourceExt.find(
|
|
2216
2216
|
(ext) => fs2.existsSync(`${localBin}${ext}`)
|
|
2217
2217
|
);
|
|
@@ -2229,17 +2229,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2229
2229
|
} catch {
|
|
2230
2230
|
resolvedScriptPath = this._scriptPath;
|
|
2231
2231
|
}
|
|
2232
|
-
executableDir =
|
|
2233
|
-
|
|
2232
|
+
executableDir = path25.resolve(
|
|
2233
|
+
path25.dirname(resolvedScriptPath),
|
|
2234
2234
|
executableDir
|
|
2235
2235
|
);
|
|
2236
2236
|
}
|
|
2237
2237
|
if (executableDir) {
|
|
2238
2238
|
let localFile = findFile(executableDir, executableFile);
|
|
2239
2239
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
2240
|
-
const legacyName =
|
|
2240
|
+
const legacyName = path25.basename(
|
|
2241
2241
|
this._scriptPath,
|
|
2242
|
-
|
|
2242
|
+
path25.extname(this._scriptPath)
|
|
2243
2243
|
);
|
|
2244
2244
|
if (legacyName !== this._name) {
|
|
2245
2245
|
localFile = findFile(
|
|
@@ -2250,7 +2250,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2250
2250
|
}
|
|
2251
2251
|
executableFile = localFile || executableFile;
|
|
2252
2252
|
}
|
|
2253
|
-
launchWithNode = sourceExt.includes(
|
|
2253
|
+
launchWithNode = sourceExt.includes(path25.extname(executableFile));
|
|
2254
2254
|
let proc;
|
|
2255
2255
|
if (process2.platform !== "win32") {
|
|
2256
2256
|
if (launchWithNode) {
|
|
@@ -3165,7 +3165,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3165
3165
|
* @return {Command}
|
|
3166
3166
|
*/
|
|
3167
3167
|
nameFromFilename(filename) {
|
|
3168
|
-
this._name =
|
|
3168
|
+
this._name = path25.basename(filename, path25.extname(filename));
|
|
3169
3169
|
return this;
|
|
3170
3170
|
}
|
|
3171
3171
|
/**
|
|
@@ -3179,9 +3179,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3179
3179
|
* @param {string} [path]
|
|
3180
3180
|
* @return {(string|null|Command)}
|
|
3181
3181
|
*/
|
|
3182
|
-
executableDir(
|
|
3183
|
-
if (
|
|
3184
|
-
this._executableDir =
|
|
3182
|
+
executableDir(path26) {
|
|
3183
|
+
if (path26 === void 0) return this._executableDir;
|
|
3184
|
+
this._executableDir = path26;
|
|
3185
3185
|
return this;
|
|
3186
3186
|
}
|
|
3187
3187
|
/**
|
|
@@ -6688,8 +6688,8 @@ var require_utils = __commonJS({
|
|
|
6688
6688
|
}
|
|
6689
6689
|
return ind;
|
|
6690
6690
|
}
|
|
6691
|
-
function removeDotSegments(
|
|
6692
|
-
let input =
|
|
6691
|
+
function removeDotSegments(path25) {
|
|
6692
|
+
let input = path25;
|
|
6693
6693
|
const output = [];
|
|
6694
6694
|
let nextSlash = -1;
|
|
6695
6695
|
let len = 0;
|
|
@@ -6763,6 +6763,37 @@ var require_utils = __commonJS({
|
|
|
6763
6763
|
}
|
|
6764
6764
|
return output.join("");
|
|
6765
6765
|
}
|
|
6766
|
+
function removeDotSegmentsRelative(path25) {
|
|
6767
|
+
if (path25 === "" || path25[0] === "/") {
|
|
6768
|
+
return removeDotSegments(path25);
|
|
6769
|
+
}
|
|
6770
|
+
const segments = path25.split("/");
|
|
6771
|
+
const last = segments.length - 1;
|
|
6772
|
+
const output = [];
|
|
6773
|
+
let trailingDirectory = false;
|
|
6774
|
+
for (let i = 0; i <= last; i++) {
|
|
6775
|
+
const segment = segments[i];
|
|
6776
|
+
if (segment === "." || segment === "..") {
|
|
6777
|
+
if (segment === "..") {
|
|
6778
|
+
if (output.length !== 0 && output[output.length - 1] !== "..") {
|
|
6779
|
+
output.pop();
|
|
6780
|
+
} else {
|
|
6781
|
+
output.push("..");
|
|
6782
|
+
}
|
|
6783
|
+
}
|
|
6784
|
+
trailingDirectory = i === last;
|
|
6785
|
+
} else {
|
|
6786
|
+
output.push(segment);
|
|
6787
|
+
}
|
|
6788
|
+
}
|
|
6789
|
+
if (trailingDirectory && output[output.length - 1] !== "..") {
|
|
6790
|
+
output.push("");
|
|
6791
|
+
}
|
|
6792
|
+
if (output.length === 0 || output[0] === "" || output[0].includes(":")) {
|
|
6793
|
+
output.unshift(".");
|
|
6794
|
+
}
|
|
6795
|
+
return output.join("/");
|
|
6796
|
+
}
|
|
6766
6797
|
var HOST_DELIMS = { "@": "%40", "/": "%2F", "?": "%3F", "#": "%23", ":": "%3A" };
|
|
6767
6798
|
var HOST_DELIM_RE = /[@/?#:]/g;
|
|
6768
6799
|
var HOST_DELIM_NO_COLON_RE = /[@/?#]/g;
|
|
@@ -7023,6 +7054,7 @@ var require_utils = __commonJS({
|
|
|
7023
7054
|
encodeFragment,
|
|
7024
7055
|
escapePreservingEscapes,
|
|
7025
7056
|
removeDotSegments,
|
|
7057
|
+
removeDotSegmentsRelative,
|
|
7026
7058
|
isIPv4,
|
|
7027
7059
|
isUUID,
|
|
7028
7060
|
normalizeIPv6,
|
|
@@ -7098,8 +7130,8 @@ var require_schemes = __commonJS({
|
|
|
7098
7130
|
}
|
|
7099
7131
|
if (wsComponent.resourceName) {
|
|
7100
7132
|
const queryIndex = wsComponent.resourceName.indexOf("?");
|
|
7101
|
-
const
|
|
7102
|
-
wsComponent.path =
|
|
7133
|
+
const path25 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
|
|
7134
|
+
wsComponent.path = path25 && path25 !== "/" ? path25 : void 0;
|
|
7103
7135
|
wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
|
|
7104
7136
|
wsComponent.resourceName = void 0;
|
|
7105
7137
|
}
|
|
@@ -7246,16 +7278,18 @@ var require_schemes = __commonJS({
|
|
|
7246
7278
|
var require_fast_uri = __commonJS({
|
|
7247
7279
|
"../../node_modules/fast-uri/index.js"(exports2, module2) {
|
|
7248
7280
|
"use strict";
|
|
7249
|
-
var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
|
|
7281
|
+
var { normalizeIPv6, removeDotSegments, removeDotSegmentsRelative, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
|
|
7250
7282
|
var { SCHEMES, getSchemeHandler } = require_schemes();
|
|
7251
7283
|
var VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
|
|
7252
7284
|
var MALFORMED_SCHEME_ERROR = "URI scheme is malformed.";
|
|
7253
|
-
|
|
7254
|
-
|
|
7255
|
-
|
|
7285
|
+
var MALFORMED_HOST_ERROR = "URI host is malformed.";
|
|
7286
|
+
var FORBIDDEN_DOMAIN_HOST_CHARACTER = /[\0-\x20"#/:<>?@[\\\]^`{|}\x7F]/u;
|
|
7287
|
+
function validateScheme(scheme) {
|
|
7288
|
+
const stringScheme = String(scheme);
|
|
7289
|
+
if (!VALID_SCHEME.test(stringScheme)) {
|
|
7256
7290
|
throw new TypeError(MALFORMED_SCHEME_ERROR);
|
|
7257
7291
|
}
|
|
7258
|
-
return
|
|
7292
|
+
return stringScheme;
|
|
7259
7293
|
}
|
|
7260
7294
|
function normalize(uri, options) {
|
|
7261
7295
|
if (typeof uri === "string") {
|
|
@@ -7292,6 +7326,9 @@ var require_fast_uri = __commonJS({
|
|
|
7292
7326
|
const resolvedSchemeHandler = getSchemeHandler(options && options.scheme || resolved.scheme);
|
|
7293
7327
|
const resolvedHost = resolved.host;
|
|
7294
7328
|
const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (isIPv4(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6);
|
|
7329
|
+
if (hasForbiddenDomainHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP)) {
|
|
7330
|
+
throw new Error(MALFORMED_HOST_ERROR);
|
|
7331
|
+
}
|
|
7295
7332
|
canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP);
|
|
7296
7333
|
const encodedASCIIHost = resolvedHost && resolvedHost.indexOf("%") !== -1 && !/\P{ASCII}/u.test(resolvedHost);
|
|
7297
7334
|
if (resolved.error && !encodedASCIIHost) {
|
|
@@ -7333,14 +7370,15 @@ var require_fast_uri = __commonJS({
|
|
|
7333
7370
|
if (relative.path[0] === "/") {
|
|
7334
7371
|
target.path = removeDotSegments(relative.path);
|
|
7335
7372
|
} else {
|
|
7336
|
-
|
|
7373
|
+
const baseHasAuthority = base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0;
|
|
7374
|
+
if (baseHasAuthority && !base.path) {
|
|
7337
7375
|
target.path = "/" + relative.path;
|
|
7338
7376
|
} else if (!base.path) {
|
|
7339
7377
|
target.path = relative.path;
|
|
7340
7378
|
} else {
|
|
7341
7379
|
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
|
|
7342
7380
|
}
|
|
7343
|
-
target.path = removeDotSegments(target.path);
|
|
7381
|
+
target.path = base.scheme === void 0 && !baseHasAuthority && target.path[0] !== "/" ? removeDotSegmentsRelative(target.path) : removeDotSegments(target.path);
|
|
7344
7382
|
}
|
|
7345
7383
|
target.query = relative.query;
|
|
7346
7384
|
}
|
|
@@ -7378,12 +7416,13 @@ var require_fast_uri = __commonJS({
|
|
|
7378
7416
|
const options = Object.assign({}, opts);
|
|
7379
7417
|
const uriTokens = [];
|
|
7380
7418
|
if (component.scheme) {
|
|
7381
|
-
component.scheme =
|
|
7419
|
+
component.scheme = validateScheme(component.scheme);
|
|
7382
7420
|
}
|
|
7383
7421
|
const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
|
|
7384
7422
|
if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
|
|
7385
7423
|
const hasAuthority = component.userinfo !== void 0 || component.host !== void 0 || component.port !== void 0;
|
|
7386
|
-
const
|
|
7424
|
+
const schemelessReference = (component.scheme === void 0 || options.reference === "suffix") && !hasAuthority;
|
|
7425
|
+
const pathNoScheme = !options.skipEscape && schemelessReference;
|
|
7387
7426
|
if (component.path !== void 0) {
|
|
7388
7427
|
if (!options.skipEscape) {
|
|
7389
7428
|
component.path = serializePathEncoding(component.path, pathNoScheme);
|
|
@@ -7392,7 +7431,7 @@ var require_fast_uri = __commonJS({
|
|
|
7392
7431
|
}
|
|
7393
7432
|
}
|
|
7394
7433
|
if (options.reference !== "suffix" && component.scheme) {
|
|
7395
|
-
component.scheme =
|
|
7434
|
+
component.scheme = validateScheme(component.scheme);
|
|
7396
7435
|
uriTokens.push(component.scheme, ":");
|
|
7397
7436
|
}
|
|
7398
7437
|
const authority = recomposeAuthority(component);
|
|
@@ -7408,9 +7447,9 @@ var require_fast_uri = __commonJS({
|
|
|
7408
7447
|
if (component.path !== void 0) {
|
|
7409
7448
|
let s4 = component.path;
|
|
7410
7449
|
if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
|
|
7411
|
-
s4 = removeDotSegments(s4);
|
|
7450
|
+
s4 = schemelessReference && s4[0] !== "/" ? removeDotSegmentsRelative(s4) : removeDotSegments(s4);
|
|
7412
7451
|
}
|
|
7413
|
-
if (
|
|
7452
|
+
if (schemelessReference) {
|
|
7414
7453
|
s4 = serializePathEncoding(s4, true);
|
|
7415
7454
|
}
|
|
7416
7455
|
if (authority === void 0 && s4[0] === "/" && s4[1] === "/") {
|
|
@@ -7457,16 +7496,34 @@ var require_fast_uri = __commonJS({
|
|
|
7457
7496
|
return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !isIPLiteral(host) && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
|
|
7458
7497
|
}
|
|
7459
7498
|
function canonicalizeHost(parsed, options, schemeHandler, isIP) {
|
|
7499
|
+
if (hasForbiddenDomainHost(parsed, options, schemeHandler, isIP)) {
|
|
7500
|
+
parsed.error = parsed.error || MALFORMED_HOST_ERROR;
|
|
7501
|
+
return true;
|
|
7502
|
+
}
|
|
7460
7503
|
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
|
|
7504
|
+
let url2;
|
|
7461
7505
|
try {
|
|
7462
|
-
|
|
7506
|
+
url2 = new URL("http://" + parsed.host);
|
|
7463
7507
|
} catch (e3) {
|
|
7464
7508
|
parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e3;
|
|
7465
7509
|
return true;
|
|
7466
7510
|
}
|
|
7511
|
+
if (!isHostOnlyURL(url2)) {
|
|
7512
|
+
parsed.error = parsed.error || MALFORMED_HOST_ERROR;
|
|
7513
|
+
return true;
|
|
7514
|
+
}
|
|
7515
|
+
parsed.host = url2.hostname;
|
|
7467
7516
|
}
|
|
7468
7517
|
return false;
|
|
7469
7518
|
}
|
|
7519
|
+
function hasForbiddenDomainHost(parsed, options, schemeHandler, isIP) {
|
|
7520
|
+
return Boolean(
|
|
7521
|
+
parsed.host && isIP === false && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && FORBIDDEN_DOMAIN_HOST_CHARACTER.test(parsed.host)
|
|
7522
|
+
);
|
|
7523
|
+
}
|
|
7524
|
+
function isHostOnlyURL(url2) {
|
|
7525
|
+
return url2.username === "" && url2.password === "" && url2.port === "" && url2.pathname === "/" && url2.search === "" && url2.hash === "" && url2.hostname !== "";
|
|
7526
|
+
}
|
|
7470
7527
|
function parseWithStatus(uri, opts) {
|
|
7471
7528
|
const options = Object.assign({}, opts);
|
|
7472
7529
|
const parsed = {
|
|
@@ -7521,9 +7578,8 @@ var require_fast_uri = __commonJS({
|
|
|
7521
7578
|
parsed.query = matches[7];
|
|
7522
7579
|
parsed.fragment = matches[8];
|
|
7523
7580
|
if (parsed.scheme !== void 0) {
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
parsed.scheme = decodedScheme.toLowerCase();
|
|
7581
|
+
if (VALID_SCHEME.test(parsed.scheme)) {
|
|
7582
|
+
parsed.scheme = parsed.scheme.toLowerCase();
|
|
7527
7583
|
} else {
|
|
7528
7584
|
parsed.error = parsed.error || MALFORMED_SCHEME_ERROR;
|
|
7529
7585
|
malformedScheme = true;
|
|
@@ -7551,7 +7607,7 @@ var require_fast_uri = __commonJS({
|
|
|
7551
7607
|
malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true);
|
|
7552
7608
|
parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
|
|
7553
7609
|
if (malformedIPLiteral) {
|
|
7554
|
-
parsed.error = parsed.error ||
|
|
7610
|
+
parsed.error = parsed.error || MALFORMED_HOST_ERROR;
|
|
7555
7611
|
malformedAuthorityOrPort = true;
|
|
7556
7612
|
}
|
|
7557
7613
|
} else {
|
|
@@ -7579,7 +7635,7 @@ var require_fast_uri = __commonJS({
|
|
|
7579
7635
|
if (!isIP) {
|
|
7580
7636
|
host = normalizePercentEncoding(host.toLowerCase());
|
|
7581
7637
|
}
|
|
7582
|
-
parsed.host = reescapeHostDelimiters(host, isIP);
|
|
7638
|
+
parsed.host = isIP || options.scheme !== "null" ? reescapeHostDelimiters(host, isIP) : host;
|
|
7583
7639
|
}
|
|
7584
7640
|
if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
|
|
7585
7641
|
if (parsed.path) {
|
|
@@ -16749,6 +16805,10 @@ var init_zip_reader = __esm({
|
|
|
16749
16805
|
|
|
16750
16806
|
// src/errors/catalog.ts
|
|
16751
16807
|
var ERROR_CATALOG = {
|
|
16808
|
+
// 单轮调试日志导出。
|
|
16809
|
+
RUNS_EXPORT_SOURCE_UNAVAILABLE: { retryable: false, exitCode: 1 },
|
|
16810
|
+
RUNS_EXPORT_SIZE_EXCEEDED: { retryable: false, exitCode: 1 },
|
|
16811
|
+
RUNS_EXPORT_FAILED: { retryable: false, exitCode: 1 },
|
|
16752
16812
|
// CLI usage
|
|
16753
16813
|
CLI_USAGE_INVALID: { retryable: false, exitCode: 1 },
|
|
16754
16814
|
UNEXPECTED_ERROR: { retryable: false, exitCode: 1 },
|
|
@@ -20806,10 +20866,10 @@ function canonicalizeBindingPath(rawPath, listRoot) {
|
|
|
20806
20866
|
}
|
|
20807
20867
|
return isSafeJsonPointer(candidate, true) ? candidate : void 0;
|
|
20808
20868
|
}
|
|
20809
|
-
function issue2(
|
|
20810
|
-
return { path:
|
|
20869
|
+
function issue2(path25, code, message) {
|
|
20870
|
+
return { path: path25, code, message };
|
|
20811
20871
|
}
|
|
20812
|
-
function exactKeys(value, allowed,
|
|
20872
|
+
function exactKeys(value, allowed, path25, issues) {
|
|
20813
20873
|
}
|
|
20814
20874
|
|
|
20815
20875
|
// ../agent-a2ui-card-contract/dist/esm/binding-analyzer.js
|
|
@@ -21039,9 +21099,9 @@ var SCHEMA_TYPES = /* @__PURE__ */ new Set([
|
|
|
21039
21099
|
"object",
|
|
21040
21100
|
"string"
|
|
21041
21101
|
]);
|
|
21042
|
-
function getJsonSchemaIssues(value,
|
|
21102
|
+
function getJsonSchemaIssues(value, path25 = "schema", options = {}) {
|
|
21043
21103
|
const issues = [];
|
|
21044
|
-
validateSchemaNode(value,
|
|
21104
|
+
validateSchemaNode(value, path25, issues, options);
|
|
21045
21105
|
return issues;
|
|
21046
21106
|
}
|
|
21047
21107
|
var OPAQUE_OBJECT_SCHEMA = {
|
|
@@ -21063,9 +21123,9 @@ function normalizeTargetJsonSchema(schema) {
|
|
|
21063
21123
|
normalizeObjectDefaults(cloned);
|
|
21064
21124
|
return cloned;
|
|
21065
21125
|
}
|
|
21066
|
-
function validateJsonSchemaValue2(schema, value,
|
|
21126
|
+
function validateJsonSchemaValue2(schema, value, path25 = "$") {
|
|
21067
21127
|
const issues = [];
|
|
21068
|
-
validateValue(schema, value,
|
|
21128
|
+
validateValue(schema, value, path25, issues);
|
|
21069
21129
|
return issues;
|
|
21070
21130
|
}
|
|
21071
21131
|
function normalizeCardDataValue(schema, value, required2 = true) {
|
|
@@ -21169,9 +21229,9 @@ function getJsonSchemaAtDataPointer(schema, pointer) {
|
|
|
21169
21229
|
return schema;
|
|
21170
21230
|
return getJsonSchemaAtPath(schema, pointer.slice(1).split("/").map(decodePointerSegment));
|
|
21171
21231
|
}
|
|
21172
|
-
function getJsonSchemaAtPath(schema,
|
|
21232
|
+
function getJsonSchemaAtPath(schema, path25) {
|
|
21173
21233
|
let current = schema;
|
|
21174
|
-
for (const segment of
|
|
21234
|
+
for (const segment of path25) {
|
|
21175
21235
|
if (!current)
|
|
21176
21236
|
return void 0;
|
|
21177
21237
|
if (segment === "*" || current.type === "array") {
|
|
@@ -21189,56 +21249,56 @@ function getJsonSchemaAtPath(schema, path24) {
|
|
|
21189
21249
|
}
|
|
21190
21250
|
return current;
|
|
21191
21251
|
}
|
|
21192
|
-
function getJsonSchemaCompatibilityIssues(source, target,
|
|
21252
|
+
function getJsonSchemaCompatibilityIssues(source, target, path25 = "$") {
|
|
21193
21253
|
const issues = [];
|
|
21194
|
-
compareSchemas(source, target,
|
|
21254
|
+
compareSchemas(source, target, path25, issues);
|
|
21195
21255
|
return issues;
|
|
21196
21256
|
}
|
|
21197
21257
|
function areJsonSchemaTypesCompatible(sourceType, targetType) {
|
|
21198
21258
|
return sourceType === targetType || sourceType === "integer" && targetType === "number";
|
|
21199
21259
|
}
|
|
21200
|
-
function validateSchemaNode(value,
|
|
21260
|
+
function validateSchemaNode(value, path25, issues, options) {
|
|
21201
21261
|
if (!isPlainRecord(value) || !isJsonValue(value)) {
|
|
21202
|
-
issues.push(issue2(
|
|
21262
|
+
issues.push(issue2(path25, "INVALID_JSON_SCHEMA", `${path25} must be a JSON object`));
|
|
21203
21263
|
return false;
|
|
21204
21264
|
}
|
|
21205
21265
|
if (value.type === void 0 && options.allowMissingType) {
|
|
21206
21266
|
return true;
|
|
21207
21267
|
}
|
|
21208
21268
|
if (typeof value.type !== "string" || !SCHEMA_TYPES.has(value.type)) {
|
|
21209
|
-
issues.push(issue2(`${
|
|
21269
|
+
issues.push(issue2(`${path25}.type`, "INVALID_JSON_SCHEMA_TYPE", `${path25}.type must be a supported scalar, object or array type`));
|
|
21210
21270
|
return false;
|
|
21211
21271
|
}
|
|
21212
21272
|
if (value.required !== void 0 && (!Array.isArray(value.required) || value.required.some((entry) => typeof entry !== "string"))) {
|
|
21213
|
-
issues.push(issue2(`${
|
|
21273
|
+
issues.push(issue2(`${path25}.required`, "INVALID_JSON_SCHEMA_REQUIRED", `${path25}.required must be a string array`));
|
|
21214
21274
|
}
|
|
21215
21275
|
if (value.type === "object") {
|
|
21216
21276
|
if (!isPlainRecord(value.properties)) {
|
|
21217
21277
|
if (options.requireCompleteStructures) {
|
|
21218
|
-
issues.push(issue2(`${
|
|
21278
|
+
issues.push(issue2(`${path25}.properties`, "INCOMPLETE_OBJECT_SCHEMA", "object schemas must declare properties"));
|
|
21219
21279
|
}
|
|
21220
21280
|
} else {
|
|
21221
21281
|
for (const [name, child] of Object.entries(value.properties)) {
|
|
21222
|
-
validateSchemaNode(child, `${
|
|
21282
|
+
validateSchemaNode(child, `${path25}.properties.${name}`, issues, options);
|
|
21223
21283
|
}
|
|
21224
21284
|
const required2 = Array.isArray(value.required) ? value.required.filter((entry) => typeof entry === "string") : [];
|
|
21225
21285
|
for (const name of required2) {
|
|
21226
21286
|
if (!(name in value.properties)) {
|
|
21227
|
-
issues.push(issue2(`${
|
|
21287
|
+
issues.push(issue2(`${path25}.required`, "UNKNOWN_REQUIRED_PROPERTY", `required property ${name} is not declared`));
|
|
21228
21288
|
}
|
|
21229
21289
|
}
|
|
21230
21290
|
}
|
|
21231
21291
|
if (value.additionalProperties !== void 0 && typeof value.additionalProperties !== "boolean" && !isPlainRecord(value.additionalProperties)) {
|
|
21232
|
-
issues.push(issue2(`${
|
|
21292
|
+
issues.push(issue2(`${path25}.additionalProperties`, "INVALID_ADDITIONAL_PROPERTIES", "additionalProperties must be a boolean or schema"));
|
|
21233
21293
|
}
|
|
21234
21294
|
}
|
|
21235
21295
|
if (value.type === "array") {
|
|
21236
21296
|
if (!isPlainRecord(value.items)) {
|
|
21237
21297
|
if (options.requireCompleteStructures) {
|
|
21238
|
-
issues.push(issue2(`${
|
|
21298
|
+
issues.push(issue2(`${path25}.items`, "INCOMPLETE_ARRAY_SCHEMA", "array schemas must declare items"));
|
|
21239
21299
|
}
|
|
21240
21300
|
} else {
|
|
21241
|
-
validateSchemaNode(value.items, `${
|
|
21301
|
+
validateSchemaNode(value.items, `${path25}.items`, issues, options);
|
|
21242
21302
|
}
|
|
21243
21303
|
}
|
|
21244
21304
|
return true;
|
|
@@ -21258,53 +21318,53 @@ function normalizeObjectDefaults(schema) {
|
|
|
21258
21318
|
normalizeObjectDefaults(schema.items);
|
|
21259
21319
|
}
|
|
21260
21320
|
}
|
|
21261
|
-
function validateValue(schema, value,
|
|
21321
|
+
function validateValue(schema, value, path25, issues) {
|
|
21262
21322
|
if (typeof schema.type === "string" && !matchesType(schema.type, value)) {
|
|
21263
|
-
issues.push(issue2(
|
|
21323
|
+
issues.push(issue2(path25, "SCHEMA_TYPE_MISMATCH", `expected ${schema.type}, received ${valueType(value)}`));
|
|
21264
21324
|
return;
|
|
21265
21325
|
}
|
|
21266
21326
|
if (Array.isArray(schema.enum) && !schema.enum.some((entry) => Object.is(entry, value))) {
|
|
21267
|
-
issues.push(issue2(
|
|
21327
|
+
issues.push(issue2(path25, "SCHEMA_ENUM_MISMATCH", "value is not in the declared enum"));
|
|
21268
21328
|
return;
|
|
21269
21329
|
}
|
|
21270
21330
|
if (schema.const !== void 0 && !Object.is(schema.const, value)) {
|
|
21271
|
-
issues.push(issue2(
|
|
21331
|
+
issues.push(issue2(path25, "SCHEMA_CONST_MISMATCH", "value does not match const"));
|
|
21272
21332
|
return;
|
|
21273
21333
|
}
|
|
21274
21334
|
if (schema.type === "object" && isPlainRecord(value)) {
|
|
21275
21335
|
const required2 = Array.isArray(schema.required) ? schema.required.filter((entry) => typeof entry === "string") : [];
|
|
21276
21336
|
for (const key of required2) {
|
|
21277
21337
|
if (!(key in value)) {
|
|
21278
|
-
issues.push(issue2(`${
|
|
21338
|
+
issues.push(issue2(`${path25}/${key}`, "SCHEMA_REQUIRED_MISSING", `required property ${key} is missing`));
|
|
21279
21339
|
}
|
|
21280
21340
|
}
|
|
21281
21341
|
const properties = isPlainRecord(schema.properties) ? schema.properties : {};
|
|
21282
21342
|
for (const [key, childSchema] of Object.entries(properties)) {
|
|
21283
21343
|
if (!(key in value) || !isPlainRecord(childSchema))
|
|
21284
21344
|
continue;
|
|
21285
|
-
validateValue(childSchema, value[key], `${
|
|
21345
|
+
validateValue(childSchema, value[key], `${path25}/${key}`, issues);
|
|
21286
21346
|
}
|
|
21287
21347
|
if (schema.additionalProperties === false) {
|
|
21288
21348
|
for (const key of Object.keys(value)) {
|
|
21289
21349
|
if (!(key in properties)) {
|
|
21290
|
-
issues.push(issue2(`${
|
|
21350
|
+
issues.push(issue2(`${path25}/${key}`, "SCHEMA_ADDITIONAL_PROPERTY", `property ${key} is not allowed`));
|
|
21291
21351
|
}
|
|
21292
21352
|
}
|
|
21293
21353
|
}
|
|
21294
21354
|
}
|
|
21295
21355
|
if (schema.type === "array" && Array.isArray(value) && isPlainRecord(schema.items)) {
|
|
21296
21356
|
value.forEach((entry, index) => {
|
|
21297
|
-
validateValue(schema.items, entry, `${
|
|
21357
|
+
validateValue(schema.items, entry, `${path25}/${index}`, issues);
|
|
21298
21358
|
});
|
|
21299
21359
|
}
|
|
21300
21360
|
}
|
|
21301
|
-
function compareSchemas(source, target,
|
|
21361
|
+
function compareSchemas(source, target, path25, issues) {
|
|
21302
21362
|
if (!areJsonSchemaTypesCompatible(source.type, target.type)) {
|
|
21303
|
-
issues.push(issue2(
|
|
21363
|
+
issues.push(issue2(path25, "SCHEMA_TYPE_INCOMPATIBLE", `source type ${String(source.type)} cannot supply ${String(target.type)}`));
|
|
21304
21364
|
return;
|
|
21305
21365
|
}
|
|
21306
21366
|
if (source.type === "array" && target.type === "array" && isPlainRecord(source.items) && isPlainRecord(target.items)) {
|
|
21307
|
-
compareSchemas(source.items, target.items, `${
|
|
21367
|
+
compareSchemas(source.items, target.items, `${path25}[*]`, issues);
|
|
21308
21368
|
}
|
|
21309
21369
|
if (source.type === "object" && target.type === "object" && isPlainRecord(source.properties) && isPlainRecord(target.properties)) {
|
|
21310
21370
|
const required2 = Array.isArray(target.required) ? target.required.filter((entry) => typeof entry === "string") : [];
|
|
@@ -21312,10 +21372,10 @@ function compareSchemas(source, target, path24, issues) {
|
|
|
21312
21372
|
const sourceChild = source.properties[name];
|
|
21313
21373
|
const targetChild = target.properties[name];
|
|
21314
21374
|
if (!isPlainRecord(sourceChild) || !isPlainRecord(targetChild)) {
|
|
21315
|
-
issues.push(issue2(`${
|
|
21375
|
+
issues.push(issue2(`${path25}.${name}`, "SCHEMA_REQUIRED_MISSING", `source does not provide required property ${name}`));
|
|
21316
21376
|
continue;
|
|
21317
21377
|
}
|
|
21318
|
-
compareSchemas(sourceChild, targetChild, `${
|
|
21378
|
+
compareSchemas(sourceChild, targetChild, `${path25}.${name}`, issues);
|
|
21319
21379
|
}
|
|
21320
21380
|
}
|
|
21321
21381
|
}
|
|
@@ -21404,37 +21464,37 @@ var A2UICardExpressionError = class extends Error {
|
|
|
21404
21464
|
this.fieldId = fieldId;
|
|
21405
21465
|
}
|
|
21406
21466
|
};
|
|
21407
|
-
function getA2UICardTransformIssues(value,
|
|
21467
|
+
function getA2UICardTransformIssues(value, path25 = "transform") {
|
|
21408
21468
|
if (!isPlainRecord(value)) {
|
|
21409
21469
|
return [
|
|
21410
|
-
issue2(
|
|
21470
|
+
issue2(path25, "CARD_EXPRESSION_INVALID", "transform must be an object")
|
|
21411
21471
|
];
|
|
21412
21472
|
}
|
|
21413
21473
|
const issues = [];
|
|
21414
21474
|
const allowedKeys = /* @__PURE__ */ new Set(["language", "profile", "expression"]);
|
|
21415
21475
|
for (const key of Object.keys(value)) {
|
|
21416
21476
|
if (!allowedKeys.has(key)) {
|
|
21417
|
-
issues.push(issue2(`${
|
|
21477
|
+
issues.push(issue2(`${path25}.${key}`, "CARD_EXPRESSION_INVALID", `${key} is not supported by transform`));
|
|
21418
21478
|
}
|
|
21419
21479
|
}
|
|
21420
21480
|
if (value.language !== A2UI_CARD_TRANSFORM_LANGUAGE) {
|
|
21421
|
-
issues.push(issue2(`${
|
|
21481
|
+
issues.push(issue2(`${path25}.language`, "CARD_EXPRESSION_INVALID", `language must be ${A2UI_CARD_TRANSFORM_LANGUAGE}`));
|
|
21422
21482
|
}
|
|
21423
21483
|
if (value.profile !== A2UI_CARD_TRANSFORM_PROFILE) {
|
|
21424
|
-
issues.push(issue2(`${
|
|
21484
|
+
issues.push(issue2(`${path25}.profile`, "CARD_EXPRESSION_INVALID", `profile must be ${A2UI_CARD_TRANSFORM_PROFILE}`));
|
|
21425
21485
|
}
|
|
21426
21486
|
if (typeof value.expression !== "string" || value.expression.trim().length === 0) {
|
|
21427
|
-
issues.push(issue2(`${
|
|
21487
|
+
issues.push(issue2(`${path25}.expression`, "CARD_EXPRESSION_INVALID", "expression must be a non-empty string"));
|
|
21428
21488
|
return issues;
|
|
21429
21489
|
}
|
|
21430
21490
|
if (value.expression.length > A2UI_CARD_EXPRESSION_MAX_LENGTH) {
|
|
21431
|
-
issues.push(issue2(`${
|
|
21491
|
+
issues.push(issue2(`${path25}.expression`, "CARD_EXPRESSION_LIMIT_EXCEEDED", `expression exceeds ${A2UI_CARD_EXPRESSION_MAX_LENGTH} characters`));
|
|
21432
21492
|
return issues;
|
|
21433
21493
|
}
|
|
21434
21494
|
try {
|
|
21435
21495
|
validateAst((0, import_jmespath2.compile)(value.expression));
|
|
21436
21496
|
} catch (error2) {
|
|
21437
|
-
issues.push(issue2(`${
|
|
21497
|
+
issues.push(issue2(`${path25}.expression`, error2 instanceof A2UICardExpressionError ? error2.code : "CARD_EXPRESSION_INVALID", error2 instanceof Error ? error2.message : "expression is invalid"));
|
|
21438
21498
|
}
|
|
21439
21499
|
return issues;
|
|
21440
21500
|
}
|
|
@@ -21546,11 +21606,11 @@ function parseA2UICardBindingContext(value) {
|
|
|
21546
21606
|
issues: []
|
|
21547
21607
|
};
|
|
21548
21608
|
}
|
|
21549
|
-
function getA2UICardBindingContextIssues(value,
|
|
21609
|
+
function getA2UICardBindingContextIssues(value, path25 = "bindingContext") {
|
|
21550
21610
|
const issues = [];
|
|
21551
21611
|
if (!isPlainRecord(value)) {
|
|
21552
21612
|
return [
|
|
21553
|
-
issue2(
|
|
21613
|
+
issue2(path25, "CARD_BINDING_CONTEXT_INVALID", "binding context must be an object")
|
|
21554
21614
|
];
|
|
21555
21615
|
}
|
|
21556
21616
|
exactKeys(value, [
|
|
@@ -21562,36 +21622,36 @@ function getA2UICardBindingContextIssues(value, path24 = "bindingContext") {
|
|
|
21562
21622
|
"generatedAt",
|
|
21563
21623
|
"candidates",
|
|
21564
21624
|
"preferredTools"
|
|
21565
|
-
],
|
|
21625
|
+
], path25, issues);
|
|
21566
21626
|
if (value.schemaVersion !== "1") {
|
|
21567
|
-
issues.push(issue2(`${
|
|
21627
|
+
issues.push(issue2(`${path25}.schemaVersion`, "CARD_BINDING_CONTEXT_INVALID", "schemaVersion must be 1"));
|
|
21568
21628
|
}
|
|
21569
21629
|
for (const key of ["draftId", "resourceId"]) {
|
|
21570
21630
|
if (!isSafeIdentifier(value[key])) {
|
|
21571
|
-
issues.push(issue2(`${
|
|
21631
|
+
issues.push(issue2(`${path25}.${key}`, "CARD_BINDING_CONTEXT_INVALID", `${key} is invalid`));
|
|
21572
21632
|
}
|
|
21573
21633
|
}
|
|
21574
21634
|
for (const key of ["draftStructureChecksum", "mcpConfigChecksum"]) {
|
|
21575
21635
|
if (typeof value[key] !== "string" || !/^[0-9a-f]{64}$/u.test(value[key])) {
|
|
21576
|
-
issues.push(issue2(`${
|
|
21636
|
+
issues.push(issue2(`${path25}.${key}`, "CARD_BINDING_CONTEXT_INVALID", `${key} must be a sha256 checksum`));
|
|
21577
21637
|
}
|
|
21578
21638
|
}
|
|
21579
21639
|
if (typeof value.generatedAt !== "string" || !Number.isFinite(Date.parse(value.generatedAt))) {
|
|
21580
|
-
issues.push(issue2(`${
|
|
21640
|
+
issues.push(issue2(`${path25}.generatedAt`, "CARD_BINDING_CONTEXT_INVALID", "generatedAt must be an ISO timestamp"));
|
|
21581
21641
|
}
|
|
21582
|
-
validateCandidates(value.candidates, `${
|
|
21583
|
-
validatePreferences(value.preferredTools, `${
|
|
21642
|
+
validateCandidates(value.candidates, `${path25}.candidates`, issues);
|
|
21643
|
+
validatePreferences(value.preferredTools, `${path25}.preferredTools`, issues);
|
|
21584
21644
|
return issues;
|
|
21585
21645
|
}
|
|
21586
|
-
function getA2UICardBindingSelectionIssues(value,
|
|
21646
|
+
function getA2UICardBindingSelectionIssues(value, path25 = "bindings", fields) {
|
|
21587
21647
|
const issues = [];
|
|
21588
21648
|
if (!Array.isArray(value)) {
|
|
21589
|
-
return [issue2(
|
|
21649
|
+
return [issue2(path25, "CARD_BINDING_INVALID", "bindings must be an array")];
|
|
21590
21650
|
}
|
|
21591
21651
|
const fieldById = new Map(fields?.map((field) => [field.fieldId, field]) ?? []);
|
|
21592
21652
|
const seen = /* @__PURE__ */ new Set();
|
|
21593
21653
|
value.forEach((candidate, index) => {
|
|
21594
|
-
const itemPath = `${
|
|
21654
|
+
const itemPath = `${path25}[${index}]`;
|
|
21595
21655
|
if (!isPlainRecord(candidate)) {
|
|
21596
21656
|
issues.push(issue2(itemPath, "CARD_BINDING_INVALID", "binding must be an object"));
|
|
21597
21657
|
return;
|
|
@@ -21704,14 +21764,14 @@ function validateA2UICardBindings(input, options = {}) {
|
|
|
21704
21764
|
validateConsistencyGroups(input.draft.manifest.fields, bindings, issues, selectedFields);
|
|
21705
21765
|
return issues;
|
|
21706
21766
|
}
|
|
21707
|
-
function validateCandidates(value,
|
|
21767
|
+
function validateCandidates(value, path25, issues) {
|
|
21708
21768
|
if (!Array.isArray(value) || value.length > 200) {
|
|
21709
|
-
issues.push(issue2(
|
|
21769
|
+
issues.push(issue2(path25, "CARD_BINDING_CONTEXT_INVALID", "candidates must be an array with at most 200 items"));
|
|
21710
21770
|
return;
|
|
21711
21771
|
}
|
|
21712
21772
|
const candidateKeys = /* @__PURE__ */ new Set();
|
|
21713
21773
|
value.forEach((candidate, index) => {
|
|
21714
|
-
const itemPath = `${
|
|
21774
|
+
const itemPath = `${path25}[${index}]`;
|
|
21715
21775
|
if (!isPlainRecord(candidate)) {
|
|
21716
21776
|
issues.push(issue2(itemPath, "CARD_BINDING_CONTEXT_INVALID", "candidate must be an object"));
|
|
21717
21777
|
return;
|
|
@@ -21752,9 +21812,9 @@ function validateCandidates(value, path24, issues) {
|
|
|
21752
21812
|
}
|
|
21753
21813
|
});
|
|
21754
21814
|
}
|
|
21755
|
-
function validateTool(value,
|
|
21815
|
+
function validateTool(value, path25, resourceId, issues) {
|
|
21756
21816
|
if (!isPlainRecord(value)) {
|
|
21757
|
-
issues.push(issue2(
|
|
21817
|
+
issues.push(issue2(path25, "CARD_BINDING_CONTEXT_INVALID", "tool must be an object"));
|
|
21758
21818
|
return;
|
|
21759
21819
|
}
|
|
21760
21820
|
exactKeys(value, [
|
|
@@ -21765,16 +21825,16 @@ function validateTool(value, path24, resourceId, issues) {
|
|
|
21765
21825
|
"outputSchema",
|
|
21766
21826
|
"outputSchemaMode",
|
|
21767
21827
|
"annotations"
|
|
21768
|
-
],
|
|
21828
|
+
], path25, issues);
|
|
21769
21829
|
if (value.resourceId !== resourceId) {
|
|
21770
|
-
issues.push(issue2(`${
|
|
21830
|
+
issues.push(issue2(`${path25}.resourceId`, "CARD_BINDING_CONTEXT_INVALID", "tool resourceId must match candidate"));
|
|
21771
21831
|
}
|
|
21772
21832
|
if (typeof value.toolName !== "string" || !value.toolName.trim()) {
|
|
21773
|
-
issues.push(issue2(`${
|
|
21833
|
+
issues.push(issue2(`${path25}.toolName`, "CARD_BINDING_CONTEXT_INVALID", "toolName is required"));
|
|
21774
21834
|
}
|
|
21775
|
-
issues.push(...getJsonSchemaIssues(value.inputSchema, `${
|
|
21835
|
+
issues.push(...getJsonSchemaIssues(value.inputSchema, `${path25}.inputSchema`));
|
|
21776
21836
|
if (value.outputSchemaMode !== void 0 && value.outputSchemaMode !== "declared" && value.outputSchemaMode !== "opaque") {
|
|
21777
|
-
issues.push(issue2(`${
|
|
21837
|
+
issues.push(issue2(`${path25}.outputSchemaMode`, "CARD_BINDING_CONTEXT_INVALID", "outputSchemaMode must be declared or opaque"));
|
|
21778
21838
|
}
|
|
21779
21839
|
}
|
|
21780
21840
|
function normalizeBindingContext(context) {
|
|
@@ -21795,16 +21855,16 @@ function normalizeBindingContext(context) {
|
|
|
21795
21855
|
});
|
|
21796
21856
|
return cloned;
|
|
21797
21857
|
}
|
|
21798
|
-
function validatePreferences(value,
|
|
21858
|
+
function validatePreferences(value, path25, issues) {
|
|
21799
21859
|
if (value === void 0)
|
|
21800
21860
|
return;
|
|
21801
21861
|
if (!Array.isArray(value) || value.length > 512) {
|
|
21802
|
-
issues.push(issue2(
|
|
21862
|
+
issues.push(issue2(path25, "CARD_BINDING_CONTEXT_INVALID", "preferredTools must be an array"));
|
|
21803
21863
|
return;
|
|
21804
21864
|
}
|
|
21805
21865
|
const fields = /* @__PURE__ */ new Set();
|
|
21806
21866
|
value.forEach((preference, index) => {
|
|
21807
|
-
const itemPath = `${
|
|
21867
|
+
const itemPath = `${path25}[${index}]`;
|
|
21808
21868
|
if (!isPlainRecord(preference)) {
|
|
21809
21869
|
issues.push(issue2(itemPath, "CARD_BINDING_CONTEXT_INVALID", "preference must be an object"));
|
|
21810
21870
|
return;
|
|
@@ -21824,14 +21884,14 @@ function validatePreferences(value, path24, issues) {
|
|
|
21824
21884
|
fields.add(preference.fieldId);
|
|
21825
21885
|
});
|
|
21826
21886
|
}
|
|
21827
|
-
function validateInputBindings(value,
|
|
21887
|
+
function validateInputBindings(value, path25, issues) {
|
|
21828
21888
|
if (!Array.isArray(value) || value.length > 64) {
|
|
21829
|
-
issues.push(issue2(
|
|
21889
|
+
issues.push(issue2(path25, "CARD_BINDING_INVALID", "inputBindings must be an array with at most 64 items"));
|
|
21830
21890
|
return;
|
|
21831
21891
|
}
|
|
21832
21892
|
const inputs = /* @__PURE__ */ new Set();
|
|
21833
21893
|
value.forEach((binding, index) => {
|
|
21834
|
-
const itemPath = `${
|
|
21894
|
+
const itemPath = `${path25}[${index}]`;
|
|
21835
21895
|
if (!isPlainRecord(binding)) {
|
|
21836
21896
|
issues.push(issue2(itemPath, "CARD_BINDING_INVALID", "input binding must be an object"));
|
|
21837
21897
|
return;
|
|
@@ -21862,18 +21922,18 @@ function validateInputBindings(value, path24, issues) {
|
|
|
21862
21922
|
}
|
|
21863
21923
|
});
|
|
21864
21924
|
}
|
|
21865
|
-
function validateRequiredToolInputs(toolSchema, presentationSchema, bindings,
|
|
21925
|
+
function validateRequiredToolInputs(toolSchema, presentationSchema, bindings, path25, issues) {
|
|
21866
21926
|
const byInput = new Map(bindings.map((binding) => [binding.inputPath, binding]));
|
|
21867
21927
|
for (const input of requiredLeafInputs(toolSchema)) {
|
|
21868
21928
|
const binding = byInput.get(input.path);
|
|
21869
21929
|
if (!binding) {
|
|
21870
|
-
issues.push(issue2(
|
|
21930
|
+
issues.push(issue2(path25, "CARD_BINDING_INCOMPLETE", `required Tool input ${input.path} is not bound`));
|
|
21871
21931
|
continue;
|
|
21872
21932
|
}
|
|
21873
21933
|
if (binding.source.kind === "invocation") {
|
|
21874
21934
|
const source = getJsonSchemaAtDataPointer(presentationSchema, binding.source.path);
|
|
21875
21935
|
if (!source || !areJsonSchemaTypesCompatible(source.type, input.schema.type)) {
|
|
21876
|
-
issues.push(issue2(
|
|
21936
|
+
issues.push(issue2(path25, "CARD_BINDING_INVALID", `invocation source ${binding.source.path} is incompatible with ${input.path}`));
|
|
21877
21937
|
}
|
|
21878
21938
|
}
|
|
21879
21939
|
}
|
|
@@ -21885,11 +21945,11 @@ function requiredLeafInputs(schema, basePath = "", parentRequired = true) {
|
|
|
21885
21945
|
return Object.entries(schema.properties).flatMap(([name, child]) => {
|
|
21886
21946
|
if (!isPlainRecord(child))
|
|
21887
21947
|
return [];
|
|
21888
|
-
const
|
|
21948
|
+
const path25 = `${basePath}/${name.replace(/~/gu, "~0").replace(/\//gu, "~1")}`;
|
|
21889
21949
|
const isRequired = parentRequired && required2.has(name);
|
|
21890
21950
|
if (child.type === "object")
|
|
21891
|
-
return requiredLeafInputs(child,
|
|
21892
|
-
return isRequired ? [{ path:
|
|
21951
|
+
return requiredLeafInputs(child, path25, isRequired);
|
|
21952
|
+
return isRequired ? [{ path: path25, schema: child }] : [];
|
|
21893
21953
|
});
|
|
21894
21954
|
}
|
|
21895
21955
|
function validateConsistencyGroups(fields, bindings, issues, selectedFields) {
|
|
@@ -22249,16 +22309,16 @@ var A2UI_V4_COMPONENT_CATALOG = Object.freeze({
|
|
|
22249
22309
|
}
|
|
22250
22310
|
}
|
|
22251
22311
|
});
|
|
22252
|
-
function getA2UIV4ProtocolIssues(value,
|
|
22312
|
+
function getA2UIV4ProtocolIssues(value, path25 = "card") {
|
|
22253
22313
|
const issues = [];
|
|
22254
22314
|
if (!Array.isArray(value) || value.length === 0)
|
|
22255
22315
|
return [
|
|
22256
|
-
issue2(
|
|
22316
|
+
issue2(path25, "INVALID_A2UI_PROTOCOL", "card must be a non-empty array")
|
|
22257
22317
|
];
|
|
22258
22318
|
const surfaces = /* @__PURE__ */ new Map();
|
|
22259
22319
|
const createdSurfaces = /* @__PURE__ */ new Set();
|
|
22260
22320
|
for (const [messageIndex, message] of value.entries()) {
|
|
22261
|
-
const messagePath = `${
|
|
22321
|
+
const messagePath = `${path25}[${messageIndex}]`;
|
|
22262
22322
|
if (!isPlainRecord(message) || message.version !== "0.9" || !Array.isArray(message.datas)) {
|
|
22263
22323
|
issues.push(issue2(messagePath, "INVALID_A2UI_MESSAGE", "V4 messages require version 0.9 and a datas array"));
|
|
22264
22324
|
continue;
|
|
@@ -22312,9 +22372,9 @@ function getA2UIV4ProtocolIssues(value, path24 = "card") {
|
|
|
22312
22372
|
}
|
|
22313
22373
|
surfaces.forEach((_components, surfaceId) => {
|
|
22314
22374
|
if (!createdSurfaces.has(surfaceId))
|
|
22315
|
-
issues.push(issue2(`${
|
|
22375
|
+
issues.push(issue2(`${path25}.surfaces.${surfaceId}`, "MISSING_CREATE_SURFACE", "every V4 surface must declare createSurface with the V4 catalog"));
|
|
22316
22376
|
});
|
|
22317
|
-
validateReferences(surfaces,
|
|
22377
|
+
validateReferences(surfaces, path25, issues);
|
|
22318
22378
|
return issues;
|
|
22319
22379
|
}
|
|
22320
22380
|
function validateV4Component(component, componentPath, issues) {
|
|
@@ -22357,15 +22417,15 @@ function validateV4Component(component, componentPath, issues) {
|
|
|
22357
22417
|
if (component.action !== void 0)
|
|
22358
22418
|
validateAction(component.action, `${componentPath}.action`, issues, 0);
|
|
22359
22419
|
}
|
|
22360
|
-
function validateComponents(payload,
|
|
22420
|
+
function validateComponents(payload, path25, surfaces, issues) {
|
|
22361
22421
|
if (!Array.isArray(payload.components)) {
|
|
22362
|
-
issues.push(issue2(`${
|
|
22422
|
+
issues.push(issue2(`${path25}.updateComponents.components`, "INVALID_A2UI_COMPONENTS", "components must be an array"));
|
|
22363
22423
|
return;
|
|
22364
22424
|
}
|
|
22365
22425
|
const surface = surfaces.get(payload.surfaceId) ?? /* @__PURE__ */ new Map();
|
|
22366
22426
|
surfaces.set(payload.surfaceId, surface);
|
|
22367
22427
|
payload.components.forEach((component, index) => {
|
|
22368
|
-
const componentPath = `${
|
|
22428
|
+
const componentPath = `${path25}.updateComponents.components[${index}]`;
|
|
22369
22429
|
if (!isPlainRecord(component) || !isSafeIdentifier(component.id) || typeof component.component !== "string") {
|
|
22370
22430
|
issues.push(issue2(componentPath, "INVALID_A2UI_COMPONENT", "component requires a safe id and component name"));
|
|
22371
22431
|
return;
|
|
@@ -22376,23 +22436,23 @@ function validateComponents(payload, path24, surfaces, issues) {
|
|
|
22376
22436
|
validateV4Component(component, componentPath, issues);
|
|
22377
22437
|
});
|
|
22378
22438
|
}
|
|
22379
|
-
function validateProperty(value, schema,
|
|
22439
|
+
function validateProperty(value, schema, path25, issues, propertyName) {
|
|
22380
22440
|
if (schema.kind === "binding") {
|
|
22381
22441
|
const stringOnly = propertyName === "label" || propertyName === "src" || propertyName === "alt" || propertyName === "image";
|
|
22382
22442
|
const literalValid = typeof value === "string" || !stringOnly && typeof value === "number" && Number.isFinite(value);
|
|
22383
22443
|
if (!literalValid && !isDisplayBinding(value, stringOnly))
|
|
22384
|
-
issues.push(issue2(
|
|
22444
|
+
issues.push(issue2(path25, "INVALID_DISPLAY_VALUE", `display value must be ${stringOnly ? "a string" : "a string or finite number"}, or a compatible display binding`));
|
|
22385
22445
|
return;
|
|
22386
22446
|
}
|
|
22387
22447
|
if (schema.kind === "child") {
|
|
22388
22448
|
if (!isSafeIdentifier(value))
|
|
22389
|
-
issues.push(issue2(
|
|
22449
|
+
issues.push(issue2(path25, "INVALID_CHILD", "child must be a safe component id"));
|
|
22390
22450
|
return;
|
|
22391
22451
|
}
|
|
22392
22452
|
if (schema.kind === "children") {
|
|
22393
22453
|
const valid = Array.isArray(value) ? value.every(isSafeIdentifier) : isPlainRecord(value) && Object.keys(value).length === 2 && isSafeIdentifier(value.componentId) && typeof value.path === "string" && isSafePath(value.path);
|
|
22394
22454
|
if (!valid)
|
|
22395
|
-
issues.push(issue2(
|
|
22455
|
+
issues.push(issue2(path25, "INVALID_CHILDREN", "children must be component ids or one dynamic children binding"));
|
|
22396
22456
|
return;
|
|
22397
22457
|
}
|
|
22398
22458
|
if (schema.kind === "action")
|
|
@@ -22400,11 +22460,11 @@ function validateProperty(value, schema, path24, issues, propertyName) {
|
|
|
22400
22460
|
if (schema.kind === "options" || schema.kind === "format")
|
|
22401
22461
|
return;
|
|
22402
22462
|
if (schema.kind === "boolean" && typeof value !== "boolean")
|
|
22403
|
-
issues.push(issue2(
|
|
22463
|
+
issues.push(issue2(path25, "INVALID_COMPONENT_PROP_TYPE", "value must be boolean"));
|
|
22404
22464
|
if (schema.kind === "number" && !Number.isFinite(value))
|
|
22405
|
-
issues.push(issue2(
|
|
22465
|
+
issues.push(issue2(path25, "INVALID_COMPONENT_PROP_VALUE", "value must be a finite number"));
|
|
22406
22466
|
if (schema.kind === "string" && typeof value !== "string")
|
|
22407
|
-
issues.push(issue2(
|
|
22467
|
+
issues.push(issue2(path25, "INVALID_COMPONENT_PROP_VALUE", "value must be a string"));
|
|
22408
22468
|
}
|
|
22409
22469
|
function isDisplayBinding(value, stringOnly = false) {
|
|
22410
22470
|
if (!isPlainRecord(value) || typeof value.path !== "string" || !isSafePath(value.path))
|
|
@@ -22418,89 +22478,89 @@ function isStrictBinding(value) {
|
|
|
22418
22478
|
function isSafePath(value) {
|
|
22419
22479
|
return (value === "/" || value.startsWith("/") || value.startsWith("./")) && !value.split("/").some((part) => ["__proto__", "constructor", "prototype"].includes(part));
|
|
22420
22480
|
}
|
|
22421
|
-
function validateAction(value,
|
|
22481
|
+
function validateAction(value, path25, issues, depth) {
|
|
22422
22482
|
if (!isPlainRecord(value) || depth > 4) {
|
|
22423
|
-
issues.push(issue2(
|
|
22483
|
+
issues.push(issue2(path25, "INVALID_ACTION", "action must be an object with at most four nested selects"));
|
|
22424
22484
|
return;
|
|
22425
22485
|
}
|
|
22426
22486
|
const branches = ["event", "function", "local", "client", "select"].filter((key) => key in value);
|
|
22427
22487
|
if (branches.length !== 1 || Object.keys(value).length !== 1) {
|
|
22428
|
-
issues.push(issue2(
|
|
22488
|
+
issues.push(issue2(path25, "INVALID_ACTION", "action must contain exactly one branch"));
|
|
22429
22489
|
return;
|
|
22430
22490
|
}
|
|
22431
22491
|
const branch = branches[0];
|
|
22432
22492
|
const body = value[branch];
|
|
22433
22493
|
if (!isPlainRecord(body))
|
|
22434
|
-
return void issues.push(issue2(`${
|
|
22494
|
+
return void issues.push(issue2(`${path25}.${branch}`, "INVALID_ACTION", `${branch} must be an object`));
|
|
22435
22495
|
if (branch === "event") {
|
|
22436
|
-
rejectUnknownKeys(body, ["name", "context", "x2-user-message", "target"], `${
|
|
22496
|
+
rejectUnknownKeys(body, ["name", "context", "x2-user-message", "target"], `${path25}.event`, issues);
|
|
22437
22497
|
if (typeof body.name !== "string" || !/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/.test(body.name) || body.name.length > 96)
|
|
22438
|
-
issues.push(issue2(`${
|
|
22498
|
+
issues.push(issue2(`${path25}.event.name`, "INVALID_ACTION_NAME", "event name is invalid"));
|
|
22439
22499
|
if (body.context !== void 0 && !isPlainRecord(body.context))
|
|
22440
|
-
issues.push(issue2(`${
|
|
22500
|
+
issues.push(issue2(`${path25}.event.context`, "INVALID_ACTION_CONTEXT", "event context must be an object"));
|
|
22441
22501
|
else if (body.context !== void 0)
|
|
22442
|
-
validateActionDynamicValue(body.context, `${
|
|
22502
|
+
validateActionDynamicValue(body.context, `${path25}.event.context`, issues);
|
|
22443
22503
|
if (body["x2-user-message"] !== void 0 && typeof body["x2-user-message"] !== "string" && !isStrictBinding(body["x2-user-message"]))
|
|
22444
|
-
issues.push(issue2(`${
|
|
22504
|
+
issues.push(issue2(`${path25}.event.x2-user-message`, "INVALID_ACTION_CONTEXT", "x2-user-message must be a string or strict binding"));
|
|
22445
22505
|
if (body.target !== void 0)
|
|
22446
|
-
validateOverlayTarget(body.target, `${
|
|
22506
|
+
validateOverlayTarget(body.target, `${path25}.event.target`, issues);
|
|
22447
22507
|
} else if (branch === "function") {
|
|
22448
|
-
rejectUnknownKeys(body, ["ref"], `${
|
|
22508
|
+
rejectUnknownKeys(body, ["ref"], `${path25}.function`, issues);
|
|
22449
22509
|
if (!isFunctionActionRef(body.ref))
|
|
22450
|
-
issues.push(issue2(`${
|
|
22510
|
+
issues.push(issue2(`${path25}.function.ref`, "INVALID_FUNCTION_ACTION_REF", "function ref must be a dot-separated identifier up to 128 characters"));
|
|
22451
22511
|
} else if (branch === "local") {
|
|
22452
|
-
rejectUnknownKeys(body, ["name", "path", "value"], `${
|
|
22512
|
+
rejectUnknownKeys(body, ["name", "path", "value"], `${path25}.local`, issues);
|
|
22453
22513
|
if (body.name !== "data.set" || typeof body.path !== "string" || !isSafePath(body.path) || !Object.prototype.hasOwnProperty.call(body, "value"))
|
|
22454
|
-
issues.push(issue2(`${
|
|
22514
|
+
issues.push(issue2(`${path25}.local`, "INVALID_LOCAL_ACTION", "local action must be data.set with a safe path and value"));
|
|
22455
22515
|
else
|
|
22456
|
-
validateActionDynamicValue(body.value, `${
|
|
22516
|
+
validateActionDynamicValue(body.value, `${path25}.local.value`, issues);
|
|
22457
22517
|
} else if (branch === "client") {
|
|
22458
|
-
validateClientAction(body, `${
|
|
22518
|
+
validateClientAction(body, `${path25}.client`, issues);
|
|
22459
22519
|
} else {
|
|
22460
|
-
rejectUnknownKeys(body, ["value", "cases", "default"], `${
|
|
22520
|
+
rejectUnknownKeys(body, ["value", "cases", "default"], `${path25}.select`, issues);
|
|
22461
22521
|
if (!isStrictBinding(body.value) || !Array.isArray(body.cases) || body.cases.length < 1 || body.cases.length > 16)
|
|
22462
|
-
return void issues.push(issue2(`${
|
|
22522
|
+
return void issues.push(issue2(`${path25}.select`, "INVALID_SELECT_ACTION", "select requires a strict binding and 1-16 cases"));
|
|
22463
22523
|
const seen = /* @__PURE__ */ new Set();
|
|
22464
22524
|
body.cases.forEach((entry, index) => {
|
|
22465
22525
|
if (!isPlainRecord(entry) || Object.keys(entry).some((key2) => key2 !== "equals" && key2 !== "action") || !["string", "number", "boolean"].includes(typeof entry.equals) && entry.equals !== null || !Object.prototype.hasOwnProperty.call(entry, "action"))
|
|
22466
|
-
return void issues.push(issue2(`${
|
|
22526
|
+
return void issues.push(issue2(`${path25}.select.cases[${index}]`, "INVALID_SELECT_CASE", "case requires only a primitive equals and action"));
|
|
22467
22527
|
const key = JSON.stringify([typeof entry.equals, entry.equals]);
|
|
22468
22528
|
if (seen.has(key))
|
|
22469
|
-
issues.push(issue2(`${
|
|
22529
|
+
issues.push(issue2(`${path25}.select.cases[${index}].equals`, "DUPLICATE_SELECT_CASE", "select case values must be unique"));
|
|
22470
22530
|
seen.add(key);
|
|
22471
|
-
validateAction(entry.action, `${
|
|
22531
|
+
validateAction(entry.action, `${path25}.select.cases[${index}].action`, issues, depth + 1);
|
|
22472
22532
|
});
|
|
22473
22533
|
if (body.default !== void 0)
|
|
22474
|
-
validateAction(body.default, `${
|
|
22534
|
+
validateAction(body.default, `${path25}.select.default`, issues, depth + 1);
|
|
22475
22535
|
}
|
|
22476
22536
|
}
|
|
22477
22537
|
function isFunctionActionRef(value) {
|
|
22478
22538
|
return typeof value === "string" && value.length <= 128 && /^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u.test(value);
|
|
22479
22539
|
}
|
|
22480
|
-
function validateClientAction(body,
|
|
22481
|
-
rejectUnknownKeys(body, ["name", "context"],
|
|
22540
|
+
function validateClientAction(body, path25, issues) {
|
|
22541
|
+
rejectUnknownKeys(body, ["name", "context"], path25, issues);
|
|
22482
22542
|
if (body.name === "ui.overlay.close") {
|
|
22483
22543
|
if (body.context !== void 0)
|
|
22484
|
-
issues.push(issue2(`${
|
|
22544
|
+
issues.push(issue2(`${path25}.context`, "INVALID_CLIENT_ACTION_CONTEXT", "ui.overlay.close does not accept context"));
|
|
22485
22545
|
return;
|
|
22486
22546
|
}
|
|
22487
22547
|
if (body.name === "ui.surface.open") {
|
|
22488
22548
|
if (!isPlainRecord(body.context) || Object.keys(body.context).length !== 1 || typeof body.context.surfaceId !== "string")
|
|
22489
|
-
issues.push(issue2(`${
|
|
22549
|
+
issues.push(issue2(`${path25}.context`, "INVALID_CLIENT_ACTION_CONTEXT", "ui.surface.open requires context.surfaceId"));
|
|
22490
22550
|
return;
|
|
22491
22551
|
}
|
|
22492
22552
|
if (body.name === "ui.page.open" || body.name === "ui.miniprogram.embed") {
|
|
22493
22553
|
if (!isPlainRecord(body.context) || Object.keys(body.context).length !== 1 || typeof body.context.url !== "string" && !isStrictBinding(body.context.url))
|
|
22494
|
-
issues.push(issue2(`${
|
|
22554
|
+
issues.push(issue2(`${path25}.context`, "INVALID_CLIENT_ACTION_CONTEXT", `${body.name} requires one literal or bound URL`));
|
|
22495
22555
|
else if (typeof body.context.url === "string" && !isSafePageUrl(body.context.url, body.name))
|
|
22496
|
-
issues.push(issue2(`${
|
|
22556
|
+
issues.push(issue2(`${path25}.context.url`, "INVALID_PAGE_URL", body.name === "ui.miniprogram.embed" ? "ui.miniprogram.embed URL must include appId parameter" : "ui.page.open URL must use https or the approved Alipay scheme"));
|
|
22497
22557
|
return;
|
|
22498
22558
|
}
|
|
22499
|
-
issues.push(issue2(`${
|
|
22559
|
+
issues.push(issue2(`${path25}.name`, "UNSUPPORTED_CLIENT_ACTION", `unsupported client action ${String(body.name)}`));
|
|
22500
22560
|
}
|
|
22501
|
-
function validateActionDynamicValue(value,
|
|
22561
|
+
function validateActionDynamicValue(value, path25, issues) {
|
|
22502
22562
|
if (Array.isArray(value)) {
|
|
22503
|
-
value.forEach((entry, index) => validateActionDynamicValue(entry, `${
|
|
22563
|
+
value.forEach((entry, index) => validateActionDynamicValue(entry, `${path25}[${index}]`, issues));
|
|
22504
22564
|
return;
|
|
22505
22565
|
}
|
|
22506
22566
|
if (!isPlainRecord(value))
|
|
@@ -22508,96 +22568,96 @@ function validateActionDynamicValue(value, path24, issues) {
|
|
|
22508
22568
|
const keys = Object.keys(value);
|
|
22509
22569
|
if (keys.includes("path") && keys.every((key) => key === "path" || key === "fallback")) {
|
|
22510
22570
|
if (!isStrictBinding(value))
|
|
22511
|
-
issues.push(issue2(
|
|
22571
|
+
issues.push(issue2(path25, "INVALID_ACTION_BINDING", "action values require a strict binding without fallback"));
|
|
22512
22572
|
return;
|
|
22513
22573
|
}
|
|
22514
|
-
Object.entries(value).forEach(([key, entry]) => validateActionDynamicValue(entry, `${
|
|
22574
|
+
Object.entries(value).forEach(([key, entry]) => validateActionDynamicValue(entry, `${path25}.${key}`, issues));
|
|
22515
22575
|
}
|
|
22516
|
-
function validateOverlayTarget(value,
|
|
22576
|
+
function validateOverlayTarget(value, path25, issues) {
|
|
22517
22577
|
if (!isPlainRecord(value) || value.type !== "overlay" || !isPlainRecord(value.presentation) || value.presentation.kind !== "bottom-sheet")
|
|
22518
|
-
issues.push(issue2(
|
|
22578
|
+
issues.push(issue2(path25, "INVALID_EVENT_TARGET", "event target must be an overlay bottom-sheet presentation"));
|
|
22519
22579
|
}
|
|
22520
|
-
function validateOptions(value,
|
|
22580
|
+
function validateOptions(value, path25, issues) {
|
|
22521
22581
|
if (isStrictBinding(value))
|
|
22522
22582
|
return;
|
|
22523
22583
|
if (!Array.isArray(value) || value.length === 0)
|
|
22524
|
-
return void issues.push(issue2(
|
|
22584
|
+
return void issues.push(issue2(path25, "INVALID_OPTIONS", "options must be a non-empty array"));
|
|
22525
22585
|
const seen = /* @__PURE__ */ new Set();
|
|
22526
22586
|
value.forEach((entry, index) => {
|
|
22527
22587
|
if (!isPlainRecord(entry) || Object.keys(entry).some((key) => key !== "label" && key !== "value") || typeof entry.label !== "string" || !entry.label || typeof entry.value !== "string" || !entry.value)
|
|
22528
|
-
issues.push(issue2(`${
|
|
22588
|
+
issues.push(issue2(`${path25}[${index}]`, "INVALID_OPTION", "option requires only non-empty label and value"));
|
|
22529
22589
|
else if (seen.has(entry.value))
|
|
22530
|
-
issues.push(issue2(`${
|
|
22590
|
+
issues.push(issue2(`${path25}[${index}].value`, "DUPLICATE_OPTION_VALUE", "option values must be unique"));
|
|
22531
22591
|
else
|
|
22532
22592
|
seen.add(entry.value);
|
|
22533
22593
|
});
|
|
22534
22594
|
}
|
|
22535
|
-
function validateTextField(component,
|
|
22595
|
+
function validateTextField(component, path25, issues) {
|
|
22536
22596
|
if (!isStrictBinding(component.value))
|
|
22537
|
-
issues.push(issue2(`${
|
|
22597
|
+
issues.push(issue2(`${path25}.value`, "INPUT_REQUIRES_BINDING", "TextField.value must be a strict writable binding"));
|
|
22538
22598
|
if (component["x2-limit"] !== void 0 && (!Number.isInteger(component["x2-limit"]) || Number(component["x2-limit"]) < 1 || Number(component["x2-limit"]) > 1e4))
|
|
22539
|
-
issues.push(issue2(`${
|
|
22599
|
+
issues.push(issue2(`${path25}.x2-limit`, "INVALID_TEXT_LIMIT", "x2-limit must be an integer from 1 to 10000"));
|
|
22540
22600
|
if (typeof component.validationRegexp === "string") {
|
|
22541
22601
|
if (component.validationRegexp.length > 512)
|
|
22542
|
-
issues.push(issue2(`${
|
|
22602
|
+
issues.push(issue2(`${path25}.validationRegexp`, "INVALID_VALIDATION_REGEXP", "validationRegexp is too long"));
|
|
22543
22603
|
else
|
|
22544
22604
|
try {
|
|
22545
22605
|
RegExp(component.validationRegexp);
|
|
22546
22606
|
} catch {
|
|
22547
|
-
issues.push(issue2(`${
|
|
22607
|
+
issues.push(issue2(`${path25}.validationRegexp`, "INVALID_VALIDATION_REGEXP", "validationRegexp is invalid"));
|
|
22548
22608
|
}
|
|
22549
22609
|
}
|
|
22550
22610
|
}
|
|
22551
|
-
function validateStepper(component,
|
|
22611
|
+
function validateStepper(component, path25, issues) {
|
|
22552
22612
|
if (!isStrictBinding(component.value))
|
|
22553
|
-
issues.push(issue2(`${
|
|
22613
|
+
issues.push(issue2(`${path25}.value`, "INPUT_REQUIRES_BINDING", "Stepper.value must be a strict writable binding"));
|
|
22554
22614
|
if (component.step !== void 0 && (!Number.isFinite(component.step) || Number(component.step) <= 0))
|
|
22555
|
-
issues.push(issue2(`${
|
|
22615
|
+
issues.push(issue2(`${path25}.step`, "INVALID_STEPPER_RANGE", "step must be greater than zero"));
|
|
22556
22616
|
if (Number.isFinite(component.min) && Number.isFinite(component.max) && Number(component.min) > Number(component.max))
|
|
22557
|
-
issues.push(issue2(`${
|
|
22617
|
+
issues.push(issue2(`${path25}`, "INVALID_STEPPER_RANGE", "min must not exceed max"));
|
|
22558
22618
|
}
|
|
22559
|
-
function validateChecks(value,
|
|
22619
|
+
function validateChecks(value, path25, issues) {
|
|
22560
22620
|
if (!Array.isArray(value))
|
|
22561
|
-
return void issues.push(issue2(
|
|
22621
|
+
return void issues.push(issue2(path25, "INVALID_CHECKS", "checks must be an array"));
|
|
22562
22622
|
value.forEach((entry, index) => {
|
|
22563
22623
|
if (!isPlainRecord(entry) || Object.keys(entry).some((key) => key !== "required" && key !== "value" && key !== "message") || entry.required !== true || !isStrictBinding(entry.value) || entry.message !== void 0 && typeof entry.message !== "string") {
|
|
22564
|
-
issues.push(issue2(`${
|
|
22624
|
+
issues.push(issue2(`${path25}[${index}]`, "INVALID_CHECK", "check must be an implemented required check with a strict binding"));
|
|
22565
22625
|
}
|
|
22566
22626
|
});
|
|
22567
22627
|
}
|
|
22568
|
-
function validateOverflow(component,
|
|
22628
|
+
function validateOverflow(component, path25, issues) {
|
|
22569
22629
|
const value = component["x2-overflow"];
|
|
22570
22630
|
const children = component.children;
|
|
22571
22631
|
if (!isPlainRecord(children) || !isPlainRecord(value)) {
|
|
22572
|
-
issues.push(issue2(`${
|
|
22632
|
+
issues.push(issue2(`${path25}.x2-overflow`, "INVALID_OVERFLOW", "x2-overflow requires dynamic children and an object value"));
|
|
22573
22633
|
return;
|
|
22574
22634
|
}
|
|
22575
|
-
rejectUnknownKeys(value, ["mode", "previewCount", "trigger", "overlay"], `${
|
|
22635
|
+
rejectUnknownKeys(value, ["mode", "previewCount", "trigger", "overlay"], `${path25}.x2-overflow`, issues);
|
|
22576
22636
|
if (value.mode !== "overlay-all" || !Number.isInteger(value.previewCount) || Number(value.previewCount) < 0 || Number(value.previewCount) > 100) {
|
|
22577
|
-
issues.push(issue2(`${
|
|
22637
|
+
issues.push(issue2(`${path25}.x2-overflow`, "INVALID_OVERFLOW", "overlay-all requires an integer previewCount from 0 to 100"));
|
|
22578
22638
|
}
|
|
22579
22639
|
if (!isPlainRecord(value.trigger)) {
|
|
22580
|
-
issues.push(issue2(`${
|
|
22640
|
+
issues.push(issue2(`${path25}.x2-overflow.trigger`, "INVALID_OVERFLOW_TRIGGER", "trigger must contain display text"));
|
|
22581
22641
|
} else {
|
|
22582
|
-
rejectUnknownKeys(value.trigger, ["text"], `${
|
|
22642
|
+
rejectUnknownKeys(value.trigger, ["text"], `${path25}.x2-overflow.trigger`, issues);
|
|
22583
22643
|
if (!isDisplayBinding(value.trigger.text, true) && typeof value.trigger.text !== "string") {
|
|
22584
|
-
issues.push(issue2(`${
|
|
22644
|
+
issues.push(issue2(`${path25}.x2-overflow.trigger.text`, "INVALID_OVERFLOW_TRIGGER", "trigger.text must be a string or display binding"));
|
|
22585
22645
|
}
|
|
22586
22646
|
}
|
|
22587
22647
|
if (!isPlainRecord(value.overlay)) {
|
|
22588
|
-
issues.push(issue2(`${
|
|
22648
|
+
issues.push(issue2(`${path25}.x2-overflow.overlay`, "INVALID_OVERFLOW_PRESENTATION", "overlay must be a bottom-sheet presentation"));
|
|
22589
22649
|
} else {
|
|
22590
|
-
rejectUnknownKeys(value.overlay, ["kind", "title", "size"], `${
|
|
22650
|
+
rejectUnknownKeys(value.overlay, ["kind", "title", "size"], `${path25}.x2-overflow.overlay`, issues);
|
|
22591
22651
|
if (value.overlay.kind !== "bottom-sheet" || value.overlay.title !== void 0 && typeof value.overlay.title !== "string" || value.overlay.size !== void 0 && !["medium", "large", "full"].includes(String(value.overlay.size))) {
|
|
22592
|
-
issues.push(issue2(`${
|
|
22652
|
+
issues.push(issue2(`${path25}.x2-overflow.overlay`, "INVALID_OVERFLOW_PRESENTATION", "overlay must be a bottom-sheet with an optional string title and supported size"));
|
|
22593
22653
|
}
|
|
22594
22654
|
}
|
|
22595
22655
|
}
|
|
22596
|
-
function rejectUnknownKeys(value, allowed,
|
|
22656
|
+
function rejectUnknownKeys(value, allowed, path25, issues) {
|
|
22597
22657
|
const allowedKeys = new Set(allowed);
|
|
22598
22658
|
Object.keys(value).forEach((key) => {
|
|
22599
22659
|
if (!allowedKeys.has(key))
|
|
22600
|
-
issues.push(issue2(`${
|
|
22660
|
+
issues.push(issue2(`${path25}.${key}`, "UNKNOWN_PROTOCOL_FIELD", `unknown field ${key}`));
|
|
22601
22661
|
});
|
|
22602
22662
|
}
|
|
22603
22663
|
function isSafePageUrl(value, actionName) {
|
|
@@ -22612,23 +22672,23 @@ function isSafePageUrl(value, actionName) {
|
|
|
22612
22672
|
}
|
|
22613
22673
|
return value.startsWith("https://") || value.startsWith("alipays://");
|
|
22614
22674
|
}
|
|
22615
|
-
function validateReferences(surfaces,
|
|
22675
|
+
function validateReferences(surfaces, path25, issues) {
|
|
22616
22676
|
for (const [surfaceId, components] of surfaces) {
|
|
22617
22677
|
if (!components.has("root"))
|
|
22618
|
-
issues.push(issue2(`${
|
|
22678
|
+
issues.push(issue2(`${path25}.surfaces.${surfaceId}`, "MISSING_ROOT_COMPONENT", "surface must define root"));
|
|
22619
22679
|
const edges = /* @__PURE__ */ new Map();
|
|
22620
22680
|
for (const [id, component] of components) {
|
|
22621
22681
|
const refs = getComponentReferences(component);
|
|
22622
22682
|
edges.set(id, refs);
|
|
22623
22683
|
refs.forEach((ref) => {
|
|
22624
22684
|
if (!components.has(ref))
|
|
22625
|
-
issues.push(issue2(`${
|
|
22685
|
+
issues.push(issue2(`${path25}.surfaces.${surfaceId}.components.${id}.${component.child !== void 0 ? "child" : "children"}`, "MISSING_COMPONENT_REFERENCE", `component ${ref} does not exist`));
|
|
22626
22686
|
});
|
|
22627
22687
|
if ((component.component === "Button" || component.component === "Card" && component.action !== void 0) && refs.some((ref) => hasInteractiveDescendant(ref, components, /* @__PURE__ */ new Set())))
|
|
22628
|
-
issues.push(issue2(`${
|
|
22688
|
+
issues.push(issue2(`${path25}.surfaces.${surfaceId}.components.${id}.${component.child !== void 0 ? "child" : "children"}`, "NESTED_INTERACTION", "action components cannot contain interactive descendants"));
|
|
22629
22689
|
collectSurfaceOpenReferences(component.action).forEach((targetSurfaceId) => {
|
|
22630
22690
|
if (!surfaces.has(targetSurfaceId))
|
|
22631
|
-
issues.push(issue2(`${
|
|
22691
|
+
issues.push(issue2(`${path25}.surfaces.${surfaceId}.components.${id}.action`, "MISSING_SURFACE_REFERENCE", `surface ${targetSurfaceId} does not exist`));
|
|
22632
22692
|
});
|
|
22633
22693
|
}
|
|
22634
22694
|
components.forEach((component, id) => {
|
|
@@ -22636,14 +22696,14 @@ function validateReferences(surfaces, path24, issues) {
|
|
|
22636
22696
|
return;
|
|
22637
22697
|
const parents = [...components.values()].filter((parent) => getComponentReferences(parent).includes(id));
|
|
22638
22698
|
if (id === "root" || parents.length === 0 || parents.some((parent) => parent.component !== "Row" && parent.component !== "Column")) {
|
|
22639
|
-
issues.push(issue2(`${
|
|
22699
|
+
issues.push(issue2(`${path25}.surfaces.${surfaceId}.components.${id}.grow`, "INVALID_LAYOUT_PARENT", "grow requires a direct Row or Column parent in every occurrence"));
|
|
22640
22700
|
}
|
|
22641
22701
|
});
|
|
22642
22702
|
const visiting = /* @__PURE__ */ new Set();
|
|
22643
22703
|
const visited = /* @__PURE__ */ new Set();
|
|
22644
22704
|
const walk = (id) => {
|
|
22645
22705
|
if (visiting.has(id))
|
|
22646
|
-
return void issues.push(issue2(`${
|
|
22706
|
+
return void issues.push(issue2(`${path25}.surfaces.${surfaceId}.components.${id}`, "CIRCULAR_COMPONENT_REFERENCE", "component references must not contain a cycle"));
|
|
22647
22707
|
if (visited.has(id))
|
|
22648
22708
|
return;
|
|
22649
22709
|
visiting.add(id);
|
|
@@ -22772,29 +22832,29 @@ function getA2UICardDraftBundleIssues(value) {
|
|
|
22772
22832
|
}
|
|
22773
22833
|
return issues;
|
|
22774
22834
|
}
|
|
22775
|
-
function getPersistedV4ProtocolIssues(card,
|
|
22835
|
+
function getPersistedV4ProtocolIssues(card, path25) {
|
|
22776
22836
|
const issues = [];
|
|
22777
22837
|
if (card.length !== 1) {
|
|
22778
|
-
issues.push(issue2(
|
|
22838
|
+
issues.push(issue2(path25, "INVALID_PERSISTED_V4_MESSAGES", "V4 persisted cards must use exactly one message"));
|
|
22779
22839
|
}
|
|
22780
22840
|
const instructions = card.flatMap((message) => message.datas);
|
|
22781
22841
|
const creates = instructions.filter((instruction) => "createSurface" in instruction);
|
|
22782
22842
|
const updates = instructions.filter((instruction) => "updateComponents" in instruction);
|
|
22783
22843
|
if (creates.length < 1 || creates.length !== updates.length || instructions.length !== creates.length + updates.length) {
|
|
22784
|
-
issues.push(issue2(
|
|
22844
|
+
issues.push(issue2(path25, "INVALID_PERSISTED_V4_INSTRUCTIONS", "V4 persisted cards require one createSurface and one complete updateComponents per Surface"));
|
|
22785
22845
|
}
|
|
22786
22846
|
const createIds = creates.flatMap((instruction) => "createSurface" in instruction ? [instruction.createSurface.surfaceId] : []);
|
|
22787
22847
|
const updateIds = updates.flatMap((instruction) => "updateComponents" in instruction ? [instruction.updateComponents.surfaceId] : []);
|
|
22788
22848
|
for (const surfaceId of /* @__PURE__ */ new Set([...createIds, ...updateIds])) {
|
|
22789
22849
|
if (createIds.filter((id) => id === surfaceId).length !== 1 || updateIds.filter((id) => id === surfaceId).length !== 1) {
|
|
22790
|
-
issues.push(issue2(`${
|
|
22850
|
+
issues.push(issue2(`${path25}.surfaces.${surfaceId}`, "SURFACE_INSTRUCTION_MISMATCH", "each persisted Surface requires exactly one create and one component update"));
|
|
22791
22851
|
}
|
|
22792
22852
|
}
|
|
22793
22853
|
return issues;
|
|
22794
22854
|
}
|
|
22795
|
-
function validateV4Fixture(value, fields,
|
|
22855
|
+
function validateV4Fixture(value, fields, path25, issues) {
|
|
22796
22856
|
if (!isPlainRecord(value)) {
|
|
22797
|
-
issues.push(issue2(
|
|
22857
|
+
issues.push(issue2(path25, "INVALID_FIXTURE", "fixture must be a JSON object"));
|
|
22798
22858
|
return;
|
|
22799
22859
|
}
|
|
22800
22860
|
for (const field of fields) {
|
|
@@ -22803,17 +22863,17 @@ function validateV4Fixture(value, fields, path24, issues) {
|
|
|
22803
22863
|
const resolved = getFixtureValue(value, field.path);
|
|
22804
22864
|
if (!resolved.found) {
|
|
22805
22865
|
if (field.required)
|
|
22806
|
-
issues.push(issue2(`${
|
|
22866
|
+
issues.push(issue2(`${path25}${field.path}`, "REQUIRED_FIXTURE_FIELD_MISSING", `fixture is missing required field ${field.fieldId}`));
|
|
22807
22867
|
continue;
|
|
22808
22868
|
}
|
|
22809
|
-
issues.push(...validateJsonSchemaValue2(field.valueSchema, resolved.value, `${
|
|
22869
|
+
issues.push(...validateJsonSchemaValue2(field.valueSchema, resolved.value, `${path25}${field.path}`));
|
|
22810
22870
|
}
|
|
22811
22871
|
}
|
|
22812
|
-
function validateV4BindingContracts(card, occurrences, fields,
|
|
22872
|
+
function validateV4BindingContracts(card, occurrences, fields, path25, issues, dataModelSchema) {
|
|
22813
22873
|
const ordered = fields.slice().sort((left, right) => right.path.length - left.path.length);
|
|
22814
22874
|
for (const occurrence of occurrences) {
|
|
22815
22875
|
const field = ordered.find((candidate) => occurrence.canonicalPath === candidate.path || occurrence.canonicalPath.startsWith(`${candidate.path}/*/`) || occurrence.canonicalPath.startsWith(`${candidate.path}/`));
|
|
22816
|
-
const issuePath = `${
|
|
22876
|
+
const issuePath = `${path25}.surfaces.${occurrence.surfaceId ?? "unknown"}.components.${occurrence.componentId}.${occurrence.propertyPath}`;
|
|
22817
22877
|
if (!field && !dataModelSchema) {
|
|
22818
22878
|
issues.push(issue2(issuePath, "UNDECLARED_BINDING_PATH", `binding path ${occurrence.rawPath} is not declared by a manifest field`));
|
|
22819
22879
|
continue;
|
|
@@ -23021,14 +23081,14 @@ function getA2UICardResourceConfigV3Issues(value) {
|
|
|
23021
23081
|
}
|
|
23022
23082
|
return issues;
|
|
23023
23083
|
}
|
|
23024
|
-
function validateDataSources(value,
|
|
23084
|
+
function validateDataSources(value, path25, issues, options = {}) {
|
|
23025
23085
|
if (!Array.isArray(value)) {
|
|
23026
|
-
issues.push(issue2(
|
|
23086
|
+
issues.push(issue2(path25, "INVALID_DATA_SOURCES", "dataSources must be a non-empty array"));
|
|
23027
23087
|
return void 0;
|
|
23028
23088
|
}
|
|
23029
23089
|
const ids = /* @__PURE__ */ new Set();
|
|
23030
23090
|
value.forEach((candidate, index) => {
|
|
23031
|
-
const itemPath = `${
|
|
23091
|
+
const itemPath = `${path25}[${index}]`;
|
|
23032
23092
|
if (!isPlainRecord(candidate)) {
|
|
23033
23093
|
issues.push(issue2(itemPath, "INVALID_DATA_SOURCE", "data source must be an object"));
|
|
23034
23094
|
return;
|
|
@@ -23066,7 +23126,7 @@ function validateDataSources(value, path24, issues, options = {}) {
|
|
|
23066
23126
|
for (const [index, source] of value.entries()) {
|
|
23067
23127
|
for (const dependency of source.dependsOn ?? []) {
|
|
23068
23128
|
if (!ids.has(dependency) || dependency === source.sourceId) {
|
|
23069
|
-
issues.push(issue2(`${
|
|
23129
|
+
issues.push(issue2(`${path25}[${index}].dependsOn`, "UNKNOWN_SOURCE_DEPENDENCY", `Unknown dependency ${dependency}`));
|
|
23070
23130
|
}
|
|
23071
23131
|
}
|
|
23072
23132
|
}
|
|
@@ -23085,29 +23145,29 @@ function validateDataSources(value, path24, issues, options = {}) {
|
|
|
23085
23145
|
return cyclic;
|
|
23086
23146
|
};
|
|
23087
23147
|
if ([...byId.keys()].some(visit)) {
|
|
23088
|
-
issues.push(issue2(
|
|
23148
|
+
issues.push(issue2(path25, "CYCLIC_SOURCE_DEPENDENCY", "data source dependencies must be acyclic"));
|
|
23089
23149
|
}
|
|
23090
23150
|
return value;
|
|
23091
23151
|
}
|
|
23092
|
-
function validateModelPipelineArguments(value, sources,
|
|
23152
|
+
function validateModelPipelineArguments(value, sources, path25, issues) {
|
|
23093
23153
|
sources.forEach((source, index) => {
|
|
23094
23154
|
if (isPlainRecord(source.fixedInput) && Object.keys(source.fixedInput).length || Array.isArray(source.inputBindings) && source.inputBindings.length) {
|
|
23095
|
-
issues.push(issue2(`${
|
|
23155
|
+
issues.push(issue2(`${path25}.dataSources[${index}]`, "MODEL_ARGUMENTS_CONFLICT", "model arguments cannot be combined with fixedInput or inputBindings"));
|
|
23096
23156
|
}
|
|
23097
23157
|
});
|
|
23098
23158
|
const expected = createA2UICardPipelineModelInputSchema(sources);
|
|
23099
23159
|
if (isJsonValue(value.presentationInputSchema) && stableJsonStringify(value.presentationInputSchema) !== stableJsonStringify(expected)) {
|
|
23100
|
-
issues.push(issue2(`${
|
|
23160
|
+
issues.push(issue2(`${path25}.presentationInputSchema`, "MODEL_ARGUMENT_SCHEMA_MISMATCH", "presentationInputSchema must match the configured MCP input schemas"));
|
|
23101
23161
|
}
|
|
23102
23162
|
}
|
|
23103
|
-
function validatePipelineDataSources(value,
|
|
23163
|
+
function validatePipelineDataSources(value, path25, issues) {
|
|
23104
23164
|
if (!Array.isArray(value) || value.length === 0) {
|
|
23105
|
-
issues.push(issue2(
|
|
23165
|
+
issues.push(issue2(path25, "INVALID_DATA_SOURCES", "pipeline dataSources must be a non-empty array"));
|
|
23106
23166
|
return void 0;
|
|
23107
23167
|
}
|
|
23108
23168
|
const ids = /* @__PURE__ */ new Set();
|
|
23109
23169
|
value.forEach((candidate, index) => {
|
|
23110
|
-
const itemPath = `${
|
|
23170
|
+
const itemPath = `${path25}[${index}]`;
|
|
23111
23171
|
if (!isPlainRecord(candidate)) {
|
|
23112
23172
|
issues.push(issue2(itemPath, "INVALID_DATA_SOURCE", "data source must be an object"));
|
|
23113
23173
|
return;
|
|
@@ -23151,24 +23211,24 @@ function validatePipelineDataSources(value, path24, issues) {
|
|
|
23151
23211
|
});
|
|
23152
23212
|
return value;
|
|
23153
23213
|
}
|
|
23154
|
-
function validateDataTransform(value,
|
|
23214
|
+
function validateDataTransform(value, path25, issues) {
|
|
23155
23215
|
if (!isPlainRecord(value)) {
|
|
23156
|
-
issues.push(issue2(
|
|
23216
|
+
issues.push(issue2(path25, "INVALID_DATA_TRANSFORM", "dataTransform must be an object"));
|
|
23157
23217
|
return;
|
|
23158
23218
|
}
|
|
23159
|
-
exactKeys(value, ["language", "profile", "source"],
|
|
23219
|
+
exactKeys(value, ["language", "profile", "source"], path25, issues);
|
|
23160
23220
|
if (value.language !== A2UI_CARD_DATA_TRANSFORM_LANGUAGE) {
|
|
23161
|
-
issues.push(issue2(`${
|
|
23221
|
+
issues.push(issue2(`${path25}.language`, "INVALID_DATA_TRANSFORM_LANGUAGE", `language must be ${A2UI_CARD_DATA_TRANSFORM_LANGUAGE}`));
|
|
23162
23222
|
}
|
|
23163
23223
|
if (value.profile !== A2UI_CARD_DATA_TRANSFORM_PROFILE) {
|
|
23164
|
-
issues.push(issue2(`${
|
|
23224
|
+
issues.push(issue2(`${path25}.profile`, "INVALID_DATA_TRANSFORM_PROFILE", `profile must be ${A2UI_CARD_DATA_TRANSFORM_PROFILE}`));
|
|
23165
23225
|
}
|
|
23166
23226
|
if (typeof value.source !== "string" || value.source.trim().length === 0) {
|
|
23167
|
-
issues.push(issue2(`${
|
|
23227
|
+
issues.push(issue2(`${path25}.source`, "INVALID_DATA_TRANSFORM_SOURCE", "source must be a non-empty string"));
|
|
23168
23228
|
} else if (new TextEncoder().encode(value.source).byteLength > A2UI_CARD_DATA_TRANSFORM_MAX_SOURCE_BYTES) {
|
|
23169
|
-
issues.push(issue2(`${
|
|
23229
|
+
issues.push(issue2(`${path25}.source`, "DATA_TRANSFORM_SOURCE_TOO_LARGE", `source exceeds ${A2UI_CARD_DATA_TRANSFORM_MAX_SOURCE_BYTES} bytes`));
|
|
23170
23230
|
} else if (!/^\s*function\s+transform\s*\(\s*input\s*\)\s*\{/u.test(value.source)) {
|
|
23171
|
-
issues.push(issue2(`${
|
|
23231
|
+
issues.push(issue2(`${path25}.source`, "INVALID_DATA_TRANSFORM_SOURCE", "source must declare function transform(input) { ... }"));
|
|
23172
23232
|
}
|
|
23173
23233
|
}
|
|
23174
23234
|
function validatePipelineFieldSchemas(fields, dataModelSchema, issues) {
|
|
@@ -23181,14 +23241,14 @@ function validatePipelineFieldSchemas(fields, dataModelSchema, issues) {
|
|
|
23181
23241
|
}
|
|
23182
23242
|
});
|
|
23183
23243
|
}
|
|
23184
|
-
function validateV3OutputBindings(value,
|
|
23244
|
+
function validateV3OutputBindings(value, path25, issues) {
|
|
23185
23245
|
if (!Array.isArray(value)) {
|
|
23186
|
-
issues.push(issue2(
|
|
23246
|
+
issues.push(issue2(path25, "INVALID_OUTPUT_BINDINGS", "bindings must be an array"));
|
|
23187
23247
|
return void 0;
|
|
23188
23248
|
}
|
|
23189
23249
|
const fields = /* @__PURE__ */ new Set();
|
|
23190
23250
|
value.forEach((candidate, index) => {
|
|
23191
|
-
const itemPath = `${
|
|
23251
|
+
const itemPath = `${path25}[${index}]`;
|
|
23192
23252
|
if (!isPlainRecord(candidate)) {
|
|
23193
23253
|
issues.push(issue2(itemPath, "INVALID_OUTPUT_BINDING", "binding must be an object"));
|
|
23194
23254
|
return;
|
|
@@ -23231,9 +23291,9 @@ function validateV3Coverage(fields, dataSources, bindings, issues, options = {})
|
|
|
23231
23291
|
}
|
|
23232
23292
|
}
|
|
23233
23293
|
}
|
|
23234
|
-
function validateV3BindingSelections(value,
|
|
23294
|
+
function validateV3BindingSelections(value, path25, fields, issues) {
|
|
23235
23295
|
if (!Array.isArray(value)) {
|
|
23236
|
-
issues.push(issue2(
|
|
23296
|
+
issues.push(issue2(path25, "INVALID_BINDINGS", "bindings must be an array"));
|
|
23237
23297
|
return;
|
|
23238
23298
|
}
|
|
23239
23299
|
if (value.length === 0)
|
|
@@ -23242,7 +23302,7 @@ function validateV3BindingSelections(value, path24, fields, issues) {
|
|
|
23242
23302
|
const outputBindings = [];
|
|
23243
23303
|
const dataSources = [];
|
|
23244
23304
|
value.forEach((candidate, index) => {
|
|
23245
|
-
const itemPath = `${
|
|
23305
|
+
const itemPath = `${path25}[${index}]`;
|
|
23246
23306
|
if (!isPlainRecord(candidate)) {
|
|
23247
23307
|
issues.push(issue2(itemPath, "INVALID_BINDING", "binding must be an object"));
|
|
23248
23308
|
return;
|
|
@@ -23287,19 +23347,19 @@ function validateV3BindingSelections(value, path24, fields, issues) {
|
|
|
23287
23347
|
});
|
|
23288
23348
|
}
|
|
23289
23349
|
});
|
|
23290
|
-
validateDataSources(dataSources, `${
|
|
23350
|
+
validateDataSources(dataSources, `${path25}.dataSources`, issues, {
|
|
23291
23351
|
validateOutputSchema: false
|
|
23292
23352
|
});
|
|
23293
|
-
validateV3OutputBindings(outputBindings, `${
|
|
23353
|
+
validateV3OutputBindings(outputBindings, `${path25}.outputs`, issues);
|
|
23294
23354
|
if (fields) {
|
|
23295
23355
|
validateV3Coverage(fields, dataSources, outputBindings, issues, {
|
|
23296
23356
|
requireComplete: false
|
|
23297
23357
|
});
|
|
23298
23358
|
}
|
|
23299
23359
|
}
|
|
23300
|
-
function validateManifest(value,
|
|
23360
|
+
function validateManifest(value, path25, issues) {
|
|
23301
23361
|
if (!isPlainRecord(value)) {
|
|
23302
|
-
issues.push(issue2(
|
|
23362
|
+
issues.push(issue2(path25, "INVALID_MANIFEST", `${path25} must be an object`));
|
|
23303
23363
|
return void 0;
|
|
23304
23364
|
}
|
|
23305
23365
|
if (value.schemaVersion === "4" && value.dataMode === "pipeline") {
|
|
@@ -23319,35 +23379,35 @@ function validateManifest(value, path24, issues) {
|
|
|
23319
23379
|
"dataSources",
|
|
23320
23380
|
"dataTransform",
|
|
23321
23381
|
"dataModelSchema"
|
|
23322
|
-
],
|
|
23382
|
+
], path25, issues);
|
|
23323
23383
|
if (!isSafeIdentifier(value.draftId)) {
|
|
23324
|
-
issues.push(issue2(`${
|
|
23384
|
+
issues.push(issue2(`${path25}.draftId`, "INVALID_DRAFT_ID", "draftId is invalid"));
|
|
23325
23385
|
}
|
|
23326
23386
|
if (value.argumentMode !== void 0 && value.argumentMode !== "model") {
|
|
23327
|
-
issues.push(issue2(`${
|
|
23387
|
+
issues.push(issue2(`${path25}.argumentMode`, "INVALID_ARGUMENT_MODE", "argumentMode must be model"));
|
|
23328
23388
|
}
|
|
23329
23389
|
if (!isSafeIdentifier(value.resourceId)) {
|
|
23330
|
-
issues.push(issue2(`${
|
|
23331
|
-
}
|
|
23332
|
-
optionalString(value.baseRevision, `${
|
|
23333
|
-
requiredString(value.displayName, `${
|
|
23334
|
-
requiredString(value.description, `${
|
|
23335
|
-
requiredString(value.whenToUse, `${
|
|
23336
|
-
optionalString(value.whenNotToUse, `${
|
|
23337
|
-
validateLooseJsonSchema(value.presentationInputSchema, `${
|
|
23338
|
-
const fields2 = validateFields(value.fields, `${
|
|
23339
|
-
const pipelineSources = validatePipelineDataSources(value.dataSources, `${
|
|
23390
|
+
issues.push(issue2(`${path25}.resourceId`, "INVALID_RESOURCE_ID", "resourceId is invalid"));
|
|
23391
|
+
}
|
|
23392
|
+
optionalString(value.baseRevision, `${path25}.baseRevision`, issues);
|
|
23393
|
+
requiredString(value.displayName, `${path25}.displayName`, issues);
|
|
23394
|
+
requiredString(value.description, `${path25}.description`, issues);
|
|
23395
|
+
requiredString(value.whenToUse, `${path25}.whenToUse`, issues);
|
|
23396
|
+
optionalString(value.whenNotToUse, `${path25}.whenNotToUse`, issues);
|
|
23397
|
+
validateLooseJsonSchema(value.presentationInputSchema, `${path25}.presentationInputSchema`, issues);
|
|
23398
|
+
const fields2 = validateFields(value.fields, `${path25}.fields`, issues);
|
|
23399
|
+
const pipelineSources = validatePipelineDataSources(value.dataSources, `${path25}.dataSources`, issues);
|
|
23340
23400
|
if (value.argumentMode === "model" && pipelineSources) {
|
|
23341
|
-
validateModelPipelineArguments(value, pipelineSources,
|
|
23401
|
+
validateModelPipelineArguments(value, pipelineSources, path25, issues);
|
|
23342
23402
|
}
|
|
23343
|
-
validateDataTransform(value.dataTransform, `${
|
|
23344
|
-
const dataModelSchema = validateLooseJsonSchema(value.dataModelSchema, `${
|
|
23403
|
+
validateDataTransform(value.dataTransform, `${path25}.dataTransform`, issues);
|
|
23404
|
+
const dataModelSchema = validateLooseJsonSchema(value.dataModelSchema, `${path25}.dataModelSchema`, issues);
|
|
23345
23405
|
if (fields2 && dataModelSchema) {
|
|
23346
23406
|
fields2.forEach((field, index) => {
|
|
23347
23407
|
if (field.source !== "business")
|
|
23348
23408
|
return;
|
|
23349
23409
|
if (!getJsonSchemaAtDataPointer(value.dataModelSchema, field.path)) {
|
|
23350
|
-
issues.push(issue2(`${
|
|
23410
|
+
issues.push(issue2(`${path25}.fields[${index}].path`, "DATA_MODEL_FIELD_MISSING", `dataModelSchema does not define ${field.path}`));
|
|
23351
23411
|
}
|
|
23352
23412
|
});
|
|
23353
23413
|
}
|
|
@@ -23355,10 +23415,10 @@ function validateManifest(value, path24, issues) {
|
|
|
23355
23415
|
}
|
|
23356
23416
|
if (value.schemaVersion === "3" || value.schemaVersion === "4") {
|
|
23357
23417
|
if (value.dataMode !== void 0 && (value.schemaVersion !== "4" || value.dataMode !== "bindings")) {
|
|
23358
|
-
issues.push(issue2(`${
|
|
23418
|
+
issues.push(issue2(`${path25}.dataMode`, "INVALID_DATA_MODE", "bindings dataMode is only available for schemaVersion 4"));
|
|
23359
23419
|
}
|
|
23360
23420
|
if (value.actionBindings !== void 0) {
|
|
23361
|
-
issues.push(issue2(`${
|
|
23421
|
+
issues.push(issue2(`${path25}.actionBindings`, "LEGACY_PAYMENT_ACTION_BINDINGS_UNSUPPORTED", "payment actions must be defined inline in card JSON"));
|
|
23362
23422
|
}
|
|
23363
23423
|
exactKeys(value, [
|
|
23364
23424
|
"schemaVersion",
|
|
@@ -23372,24 +23432,24 @@ function validateManifest(value, path24, issues) {
|
|
|
23372
23432
|
"whenNotToUse",
|
|
23373
23433
|
"fields",
|
|
23374
23434
|
"bindings"
|
|
23375
|
-
],
|
|
23435
|
+
], path25, issues);
|
|
23376
23436
|
if (!isSafeIdentifier(value.draftId)) {
|
|
23377
|
-
issues.push(issue2(`${
|
|
23437
|
+
issues.push(issue2(`${path25}.draftId`, "INVALID_DRAFT_ID", "draftId is invalid"));
|
|
23378
23438
|
}
|
|
23379
23439
|
if (!isSafeIdentifier(value.resourceId)) {
|
|
23380
|
-
issues.push(issue2(`${
|
|
23381
|
-
}
|
|
23382
|
-
optionalString(value.baseRevision, `${
|
|
23383
|
-
requiredString(value.displayName, `${
|
|
23384
|
-
requiredString(value.description, `${
|
|
23385
|
-
requiredString(value.whenToUse, `${
|
|
23386
|
-
optionalString(value.whenNotToUse, `${
|
|
23387
|
-
const fields2 = validateFields(value.fields, `${
|
|
23440
|
+
issues.push(issue2(`${path25}.resourceId`, "INVALID_RESOURCE_ID", "resourceId is invalid"));
|
|
23441
|
+
}
|
|
23442
|
+
optionalString(value.baseRevision, `${path25}.baseRevision`, issues);
|
|
23443
|
+
requiredString(value.displayName, `${path25}.displayName`, issues);
|
|
23444
|
+
requiredString(value.description, `${path25}.description`, issues);
|
|
23445
|
+
requiredString(value.whenToUse, `${path25}.whenToUse`, issues);
|
|
23446
|
+
optionalString(value.whenNotToUse, `${path25}.whenNotToUse`, issues);
|
|
23447
|
+
const fields2 = validateFields(value.fields, `${path25}.fields`, issues);
|
|
23388
23448
|
if (fields2?.some((field) => field.source === "invocation")) {
|
|
23389
|
-
issues.push(issue2(`${
|
|
23449
|
+
issues.push(issue2(`${path25}.fields`, "INVOCATION_FIELD_UNSUPPORTED", `schema v${value.schemaVersion} does not support invocation fields`));
|
|
23390
23450
|
}
|
|
23391
23451
|
if (value.bindings !== void 0) {
|
|
23392
|
-
validateV3BindingSelections(value.bindings, `${
|
|
23452
|
+
validateV3BindingSelections(value.bindings, `${path25}.bindings`, fields2, issues);
|
|
23393
23453
|
}
|
|
23394
23454
|
return fields2 ? value : void 0;
|
|
23395
23455
|
}
|
|
@@ -23405,37 +23465,37 @@ function validateManifest(value, path24, issues) {
|
|
|
23405
23465
|
"presentationInputSchema",
|
|
23406
23466
|
"fields",
|
|
23407
23467
|
"bindings"
|
|
23408
|
-
],
|
|
23468
|
+
], path25, issues);
|
|
23409
23469
|
if (value.schemaVersion !== "2") {
|
|
23410
|
-
issues.push(issue2(`${
|
|
23470
|
+
issues.push(issue2(`${path25}.schemaVersion`, "UNSUPPORTED_DRAFT_VERSION", "schemaVersion must be 2, 3 or 4"));
|
|
23411
23471
|
}
|
|
23412
23472
|
if (!isSafeIdentifier(value.draftId)) {
|
|
23413
|
-
issues.push(issue2(`${
|
|
23473
|
+
issues.push(issue2(`${path25}.draftId`, "INVALID_DRAFT_ID", "draftId is invalid"));
|
|
23414
23474
|
}
|
|
23415
23475
|
if (!isSafeIdentifier(value.resourceId)) {
|
|
23416
|
-
issues.push(issue2(`${
|
|
23417
|
-
}
|
|
23418
|
-
optionalString(value.baseRevision, `${
|
|
23419
|
-
requiredString(value.displayName, `${
|
|
23420
|
-
requiredString(value.description, `${
|
|
23421
|
-
requiredString(value.whenToUse, `${
|
|
23422
|
-
optionalString(value.whenNotToUse, `${
|
|
23423
|
-
const schema = validateLooseJsonSchema(value.presentationInputSchema, `${
|
|
23424
|
-
const fields = validateFields(value.fields, `${
|
|
23476
|
+
issues.push(issue2(`${path25}.resourceId`, "INVALID_RESOURCE_ID", "resourceId is invalid"));
|
|
23477
|
+
}
|
|
23478
|
+
optionalString(value.baseRevision, `${path25}.baseRevision`, issues);
|
|
23479
|
+
requiredString(value.displayName, `${path25}.displayName`, issues);
|
|
23480
|
+
requiredString(value.description, `${path25}.description`, issues);
|
|
23481
|
+
requiredString(value.whenToUse, `${path25}.whenToUse`, issues);
|
|
23482
|
+
optionalString(value.whenNotToUse, `${path25}.whenNotToUse`, issues);
|
|
23483
|
+
const schema = validateLooseJsonSchema(value.presentationInputSchema, `${path25}.presentationInputSchema`, issues);
|
|
23484
|
+
const fields = validateFields(value.fields, `${path25}.fields`, issues);
|
|
23425
23485
|
if (value.bindings !== void 0) {
|
|
23426
|
-
issues.push(...getA2UICardBindingSelectionIssues(value.bindings, `${
|
|
23486
|
+
issues.push(...getA2UICardBindingSelectionIssues(value.bindings, `${path25}.bindings`, fields));
|
|
23427
23487
|
}
|
|
23428
23488
|
return schema && fields ? value : void 0;
|
|
23429
23489
|
}
|
|
23430
23490
|
function hasOverlappingJsonPointer(fixedInput, inputPath) {
|
|
23431
23491
|
const fixedPaths = [];
|
|
23432
|
-
const visit = (value,
|
|
23433
|
-
fixedPaths.push(
|
|
23492
|
+
const visit = (value, path25) => {
|
|
23493
|
+
fixedPaths.push(path25);
|
|
23434
23494
|
if (!isPlainRecord(value))
|
|
23435
23495
|
return;
|
|
23436
23496
|
for (const [key, child] of Object.entries(value)) {
|
|
23437
23497
|
const escaped = key.replace(/~/gu, "~0").replace(/\//gu, "~1");
|
|
23438
|
-
visit(child, `${
|
|
23498
|
+
visit(child, `${path25}/${escaped}`);
|
|
23439
23499
|
}
|
|
23440
23500
|
};
|
|
23441
23501
|
for (const [key, value] of Object.entries(fixedInput)) {
|
|
@@ -23444,15 +23504,15 @@ function hasOverlappingJsonPointer(fixedInput, inputPath) {
|
|
|
23444
23504
|
}
|
|
23445
23505
|
return fixedPaths.some((fixedPath) => fixedPath === inputPath || fixedPath.startsWith(`${inputPath}/`) || inputPath.startsWith(`${fixedPath}/`));
|
|
23446
23506
|
}
|
|
23447
|
-
function validateFields(value,
|
|
23507
|
+
function validateFields(value, path25, issues) {
|
|
23448
23508
|
if (!Array.isArray(value)) {
|
|
23449
|
-
issues.push(issue2(
|
|
23509
|
+
issues.push(issue2(path25, "INVALID_FIELDS", `${path25} must be an array`));
|
|
23450
23510
|
return void 0;
|
|
23451
23511
|
}
|
|
23452
23512
|
const ids = /* @__PURE__ */ new Set();
|
|
23453
23513
|
const paths = /* @__PURE__ */ new Set();
|
|
23454
23514
|
value.forEach((candidate, index) => {
|
|
23455
|
-
const itemPath = `${
|
|
23515
|
+
const itemPath = `${path25}[${index}]`;
|
|
23456
23516
|
if (!isPlainRecord(candidate)) {
|
|
23457
23517
|
issues.push(issue2(itemPath, "INVALID_FIELD", `${itemPath} must be an object`));
|
|
23458
23518
|
return;
|
|
@@ -23511,24 +23571,24 @@ function validateFields(value, path24, issues) {
|
|
|
23511
23571
|
function validateFieldPresentation(value, itemPath, issues) {
|
|
23512
23572
|
if (value === void 0)
|
|
23513
23573
|
return;
|
|
23514
|
-
const
|
|
23574
|
+
const path25 = `${itemPath}.presentation`;
|
|
23515
23575
|
if (!isPlainRecord(value)) {
|
|
23516
|
-
issues.push(issue2(
|
|
23576
|
+
issues.push(issue2(path25, "INVALID_FIELD_PRESENTATION", `${path25} must be an object`));
|
|
23517
23577
|
return;
|
|
23518
23578
|
}
|
|
23519
23579
|
if (!["echo", "reference-only", "never"].includes(String(value.visibility))) {
|
|
23520
|
-
issues.push(issue2(`${
|
|
23580
|
+
issues.push(issue2(`${path25}.visibility`, "INVALID_PRESENTATION_VISIBILITY", "presentation visibility must be echo, reference-only or never"));
|
|
23521
23581
|
}
|
|
23522
23582
|
if (value.labelPath !== void 0 && !isSafeJsonPointer(value.labelPath)) {
|
|
23523
|
-
issues.push(issue2(`${
|
|
23583
|
+
issues.push(issue2(`${path25}.labelPath`, "INVALID_PRESENTATION_PATH", "labelPath must be a safe JSON pointer"));
|
|
23524
23584
|
}
|
|
23525
23585
|
if (value.attributePaths !== void 0) {
|
|
23526
23586
|
if (!Array.isArray(value.attributePaths) || value.attributePaths.length > 3 || value.attributePaths.some((candidate) => !isSafeJsonPointer(candidate))) {
|
|
23527
|
-
issues.push(issue2(`${
|
|
23587
|
+
issues.push(issue2(`${path25}.attributePaths`, "INVALID_PRESENTATION_PATHS", "attributePaths must contain at most 3 safe JSON pointers"));
|
|
23528
23588
|
}
|
|
23529
23589
|
}
|
|
23530
23590
|
if (value.maxItems !== void 0 && (!Number.isInteger(value.maxItems) || Number(value.maxItems) < 1 || Number(value.maxItems) > 10)) {
|
|
23531
|
-
issues.push(issue2(`${
|
|
23591
|
+
issues.push(issue2(`${path25}.maxItems`, "INVALID_PRESENTATION_MAX_ITEMS", "maxItems must be an integer between 1 and 10"));
|
|
23532
23592
|
}
|
|
23533
23593
|
}
|
|
23534
23594
|
function validateFieldSource(candidate, itemPath, issues) {
|
|
@@ -23547,35 +23607,35 @@ function validateFieldSource(candidate, itemPath, issues) {
|
|
|
23547
23607
|
issues.push(issue2(`${itemPath}.runtimeContextKey`, "UNEXPECTED_RUNTIME_CONTEXT", "runtimeContextKey is only allowed for runtime-context fields"));
|
|
23548
23608
|
}
|
|
23549
23609
|
}
|
|
23550
|
-
function validateResolver(value,
|
|
23610
|
+
function validateResolver(value, path25, issues) {
|
|
23551
23611
|
if (!isPlainRecord(value)) {
|
|
23552
|
-
issues.push(issue2(
|
|
23612
|
+
issues.push(issue2(path25, "INVALID_RESOLVER", "resolver must be an object"));
|
|
23553
23613
|
return void 0;
|
|
23554
23614
|
}
|
|
23555
|
-
exactKeys(value, ["version", "calls", "outputBindings"],
|
|
23615
|
+
exactKeys(value, ["version", "calls", "outputBindings"], path25, issues);
|
|
23556
23616
|
if (value.version !== 2) {
|
|
23557
|
-
issues.push(issue2(`${
|
|
23617
|
+
issues.push(issue2(`${path25}.version`, "UNSUPPORTED_RESOLVER_VERSION", "resolver version must be 2"));
|
|
23558
23618
|
}
|
|
23559
|
-
const calls = validateResolverCalls(value.calls, `${
|
|
23560
|
-
const outputs = validateOutputBindings(value.outputBindings, `${
|
|
23619
|
+
const calls = validateResolverCalls(value.calls, `${path25}.calls`, issues);
|
|
23620
|
+
const outputs = validateOutputBindings(value.outputBindings, `${path25}.outputBindings`, issues);
|
|
23561
23621
|
if (!calls || !outputs)
|
|
23562
23622
|
return void 0;
|
|
23563
23623
|
const callIds = new Set(calls.map((call) => call.callId));
|
|
23564
23624
|
outputs.forEach((binding, index) => {
|
|
23565
23625
|
if (!callIds.has(binding.callId)) {
|
|
23566
|
-
issues.push(issue2(`${
|
|
23626
|
+
issues.push(issue2(`${path25}.outputBindings[${index}].callId`, "UNKNOWN_RESOLVER_CALL", `Unknown resolver call ${binding.callId}`));
|
|
23567
23627
|
}
|
|
23568
23628
|
});
|
|
23569
23629
|
return value;
|
|
23570
23630
|
}
|
|
23571
|
-
function validateResolverCalls(value,
|
|
23631
|
+
function validateResolverCalls(value, path25, issues) {
|
|
23572
23632
|
if (!Array.isArray(value)) {
|
|
23573
|
-
issues.push(issue2(
|
|
23633
|
+
issues.push(issue2(path25, "INVALID_RESOLVER_CALLS", "calls must be an array"));
|
|
23574
23634
|
return void 0;
|
|
23575
23635
|
}
|
|
23576
23636
|
const callIds = /* @__PURE__ */ new Set();
|
|
23577
23637
|
value.forEach((candidate, index) => {
|
|
23578
|
-
const itemPath = `${
|
|
23638
|
+
const itemPath = `${path25}[${index}]`;
|
|
23579
23639
|
if (!isPlainRecord(candidate)) {
|
|
23580
23640
|
issues.push(issue2(itemPath, "INVALID_RESOLVER_CALL", "call must be an object"));
|
|
23581
23641
|
return;
|
|
@@ -23596,14 +23656,14 @@ function validateResolverCalls(value, path24, issues) {
|
|
|
23596
23656
|
});
|
|
23597
23657
|
return value;
|
|
23598
23658
|
}
|
|
23599
|
-
function validateInputBindings2(value,
|
|
23659
|
+
function validateInputBindings2(value, path25, issues) {
|
|
23600
23660
|
if (!Array.isArray(value)) {
|
|
23601
|
-
issues.push(issue2(
|
|
23661
|
+
issues.push(issue2(path25, "INVALID_INPUT_BINDINGS", "inputBindings must be an array"));
|
|
23602
23662
|
return void 0;
|
|
23603
23663
|
}
|
|
23604
23664
|
const paths = /* @__PURE__ */ new Set();
|
|
23605
23665
|
value.forEach((candidate, index) => {
|
|
23606
|
-
const itemPath = `${
|
|
23666
|
+
const itemPath = `${path25}[${index}]`;
|
|
23607
23667
|
if (!isPlainRecord(candidate)) {
|
|
23608
23668
|
issues.push(issue2(itemPath, "INVALID_INPUT_BINDING", "binding must be an object"));
|
|
23609
23669
|
return;
|
|
@@ -23620,35 +23680,35 @@ function validateInputBindings2(value, path24, issues) {
|
|
|
23620
23680
|
});
|
|
23621
23681
|
return value;
|
|
23622
23682
|
}
|
|
23623
|
-
function validateInputSource(value,
|
|
23683
|
+
function validateInputSource(value, path25, issues) {
|
|
23624
23684
|
if (!isPlainRecord(value)) {
|
|
23625
|
-
issues.push(issue2(
|
|
23685
|
+
issues.push(issue2(path25, "INVALID_INPUT_SOURCE", "source must be an object"));
|
|
23626
23686
|
return;
|
|
23627
23687
|
}
|
|
23628
23688
|
if (value.kind === "invocation") {
|
|
23629
|
-
exactKeys(value, ["kind", "path"],
|
|
23689
|
+
exactKeys(value, ["kind", "path"], path25, issues);
|
|
23630
23690
|
if (!isSafeJsonPointer(value.path)) {
|
|
23631
|
-
issues.push(issue2(`${
|
|
23691
|
+
issues.push(issue2(`${path25}.path`, "INVALID_INPUT_SOURCE_PATH", "invocation source path must be a safe JSON pointer"));
|
|
23632
23692
|
}
|
|
23633
23693
|
return;
|
|
23634
23694
|
}
|
|
23635
23695
|
if (value.kind === "runtime-context") {
|
|
23636
|
-
exactKeys(value, ["kind", "key"],
|
|
23696
|
+
exactKeys(value, ["kind", "key"], path25, issues);
|
|
23637
23697
|
if (!RUNTIME_CONTEXT_KEYS2.has(value.key)) {
|
|
23638
|
-
issues.push(issue2(`${
|
|
23698
|
+
issues.push(issue2(`${path25}.key`, "INVALID_RUNTIME_CONTEXT", "runtime context key is invalid"));
|
|
23639
23699
|
}
|
|
23640
23700
|
return;
|
|
23641
23701
|
}
|
|
23642
|
-
issues.push(issue2(`${
|
|
23702
|
+
issues.push(issue2(`${path25}.kind`, "INVALID_INPUT_SOURCE", "source.kind must be invocation or runtime-context"));
|
|
23643
23703
|
}
|
|
23644
|
-
function validateOutputBindings(value,
|
|
23704
|
+
function validateOutputBindings(value, path25, issues) {
|
|
23645
23705
|
if (!Array.isArray(value)) {
|
|
23646
|
-
issues.push(issue2(
|
|
23706
|
+
issues.push(issue2(path25, "INVALID_OUTPUT_BINDINGS", "outputBindings must be an array"));
|
|
23647
23707
|
return void 0;
|
|
23648
23708
|
}
|
|
23649
23709
|
const fields = /* @__PURE__ */ new Set();
|
|
23650
23710
|
value.forEach((candidate, index) => {
|
|
23651
|
-
const itemPath = `${
|
|
23711
|
+
const itemPath = `${path25}[${index}]`;
|
|
23652
23712
|
if (!isPlainRecord(candidate)) {
|
|
23653
23713
|
issues.push(issue2(itemPath, "INVALID_OUTPUT_BINDING", "binding must be an object"));
|
|
23654
23714
|
return;
|
|
@@ -23668,33 +23728,33 @@ function validateOutputBindings(value, path24, issues) {
|
|
|
23668
23728
|
});
|
|
23669
23729
|
return value;
|
|
23670
23730
|
}
|
|
23671
|
-
function validateTransformShape(value,
|
|
23731
|
+
function validateTransformShape(value, path25, issues) {
|
|
23672
23732
|
if (!isPlainRecord(value)) {
|
|
23673
|
-
issues.push(issue2(
|
|
23733
|
+
issues.push(issue2(path25, "INVALID_TRANSFORM", "transform must be an object"));
|
|
23674
23734
|
return false;
|
|
23675
23735
|
}
|
|
23676
|
-
exactKeys(value, ["language", "profile", "expression"],
|
|
23736
|
+
exactKeys(value, ["language", "profile", "expression"], path25, issues);
|
|
23677
23737
|
if (value.language !== A2UI_CARD_TRANSFORM_LANGUAGE) {
|
|
23678
|
-
issues.push(issue2(`${
|
|
23738
|
+
issues.push(issue2(`${path25}.language`, "INVALID_TRANSFORM_LANGUAGE", `language must be ${A2UI_CARD_TRANSFORM_LANGUAGE}`));
|
|
23679
23739
|
}
|
|
23680
23740
|
if (value.profile !== A2UI_CARD_TRANSFORM_PROFILE) {
|
|
23681
|
-
issues.push(issue2(`${
|
|
23741
|
+
issues.push(issue2(`${path25}.profile`, "INVALID_TRANSFORM_PROFILE", `profile must be ${A2UI_CARD_TRANSFORM_PROFILE}`));
|
|
23682
23742
|
}
|
|
23683
23743
|
if (typeof value.expression !== "string" || value.expression.trim().length === 0) {
|
|
23684
|
-
issues.push(issue2(`${
|
|
23744
|
+
issues.push(issue2(`${path25}.expression`, "INVALID_TRANSFORM_EXPRESSION", "expression must be a non-empty string"));
|
|
23685
23745
|
} else if (value.expression.length > A2UI_CARD_EXPRESSION_MAX_LENGTH) {
|
|
23686
|
-
issues.push(issue2(`${
|
|
23746
|
+
issues.push(issue2(`${path25}.expression`, "TRANSFORM_EXPRESSION_TOO_LONG", `expression exceeds ${A2UI_CARD_EXPRESSION_MAX_LENGTH} characters`));
|
|
23687
23747
|
}
|
|
23688
23748
|
return true;
|
|
23689
23749
|
}
|
|
23690
|
-
function validateProtocol(value,
|
|
23750
|
+
function validateProtocol(value, path25, issues) {
|
|
23691
23751
|
if (!Array.isArray(value) || value.length === 0) {
|
|
23692
|
-
issues.push(issue2(
|
|
23752
|
+
issues.push(issue2(path25, "INVALID_A2UI_PROTOCOL", "card must be a non-empty array"));
|
|
23693
23753
|
return void 0;
|
|
23694
23754
|
}
|
|
23695
23755
|
const issueCountBeforeValidation = issues.length;
|
|
23696
23756
|
value.forEach((message, messageIndex) => {
|
|
23697
|
-
const messagePath = `${
|
|
23757
|
+
const messagePath = `${path25}[${messageIndex}]`;
|
|
23698
23758
|
if (!isPlainRecord(message)) {
|
|
23699
23759
|
issues.push(issue2(messagePath, "INVALID_A2UI_MESSAGE", "A2UI message must be an object"));
|
|
23700
23760
|
return;
|
|
@@ -23723,7 +23783,7 @@ function validateProtocol(value, path24, issues) {
|
|
|
23723
23783
|
return void 0;
|
|
23724
23784
|
return value;
|
|
23725
23785
|
}
|
|
23726
|
-
function validateInstructionShape(instruction,
|
|
23786
|
+
function validateInstructionShape(instruction, path25, issues) {
|
|
23727
23787
|
const knownKeys = [
|
|
23728
23788
|
"createSurface",
|
|
23729
23789
|
"updateComponents",
|
|
@@ -23732,31 +23792,31 @@ function validateInstructionShape(instruction, path24, issues) {
|
|
|
23732
23792
|
"x2DeleteComponent"
|
|
23733
23793
|
].filter((key) => key in instruction);
|
|
23734
23794
|
if (knownKeys.length !== 1) {
|
|
23735
|
-
issues.push(issue2(
|
|
23795
|
+
issues.push(issue2(path25, "INVALID_A2UI_INSTRUCTION", "instruction must contain exactly one supported operation"));
|
|
23736
23796
|
return;
|
|
23737
23797
|
}
|
|
23738
23798
|
const operation = knownKeys[0];
|
|
23739
23799
|
const payload = instruction[operation];
|
|
23740
23800
|
if (!isPlainRecord(payload)) {
|
|
23741
|
-
issues.push(issue2(`${
|
|
23801
|
+
issues.push(issue2(`${path25}.${operation}`, "INVALID_A2UI_INSTRUCTION_PAYLOAD", `${operation} must be an object`));
|
|
23742
23802
|
return;
|
|
23743
23803
|
}
|
|
23744
23804
|
if (!isSafeIdentifier(payload.surfaceId)) {
|
|
23745
|
-
issues.push(issue2(`${
|
|
23805
|
+
issues.push(issue2(`${path25}.${operation}.surfaceId`, "INVALID_SURFACE_ID", "surfaceId must be a non-empty safe identifier"));
|
|
23746
23806
|
}
|
|
23747
23807
|
if (operation === "updateComponents") {
|
|
23748
23808
|
if (!Array.isArray(payload.components)) {
|
|
23749
|
-
issues.push(issue2(`${
|
|
23809
|
+
issues.push(issue2(`${path25}.${operation}.components`, "INVALID_A2UI_COMPONENTS", "components must be an array"));
|
|
23750
23810
|
return;
|
|
23751
23811
|
}
|
|
23752
23812
|
payload.components.forEach((component, componentIndex) => {
|
|
23753
23813
|
if (!isPlainRecord(component) || !isJsonValue(component)) {
|
|
23754
|
-
issues.push(issue2(`${
|
|
23814
|
+
issues.push(issue2(`${path25}.${operation}.components[${componentIndex}]`, "INVALID_A2UI_COMPONENT", "component must be a JSON object"));
|
|
23755
23815
|
}
|
|
23756
23816
|
});
|
|
23757
23817
|
}
|
|
23758
23818
|
if (operation === "x2DeleteComponent" && !isSafeIdentifier(payload.componentId)) {
|
|
23759
|
-
issues.push(issue2(`${
|
|
23819
|
+
issues.push(issue2(`${path25}.${operation}.componentId`, "INVALID_COMPONENT_ID", "componentId must be a non-empty safe identifier"));
|
|
23760
23820
|
}
|
|
23761
23821
|
}
|
|
23762
23822
|
function validateTemplate(value, fields, issues) {
|
|
@@ -23782,8 +23842,8 @@ function validateTemplate(value, fields, issues) {
|
|
|
23782
23842
|
}
|
|
23783
23843
|
return void 0;
|
|
23784
23844
|
}
|
|
23785
|
-
function validateLooseJsonSchema(value,
|
|
23786
|
-
const schemaIssues = getJsonSchemaIssues(value,
|
|
23845
|
+
function validateLooseJsonSchema(value, path25, issues) {
|
|
23846
|
+
const schemaIssues = getJsonSchemaIssues(value, path25, {
|
|
23787
23847
|
allowMissingType: true
|
|
23788
23848
|
});
|
|
23789
23849
|
issues.push(...schemaIssues);
|
|
@@ -23805,14 +23865,14 @@ function validateResolverCoverage(fields, resolver, issues, card) {
|
|
|
23805
23865
|
}
|
|
23806
23866
|
}
|
|
23807
23867
|
}
|
|
23808
|
-
function requiredString(value,
|
|
23868
|
+
function requiredString(value, path25, issues) {
|
|
23809
23869
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
23810
|
-
issues.push(issue2(
|
|
23870
|
+
issues.push(issue2(path25, "REQUIRED_STRING", `${path25} must be a non-empty string`));
|
|
23811
23871
|
}
|
|
23812
23872
|
}
|
|
23813
|
-
function optionalString(value,
|
|
23873
|
+
function optionalString(value, path25, issues) {
|
|
23814
23874
|
if (value !== void 0 && typeof value !== "string") {
|
|
23815
|
-
issues.push(issue2(
|
|
23875
|
+
issues.push(issue2(path25, "INVALID_STRING", `${path25} must be a string`));
|
|
23816
23876
|
}
|
|
23817
23877
|
}
|
|
23818
23878
|
|
|
@@ -24335,8 +24395,8 @@ function extractA2UICardAuthoringModel(bundle, options = {}) {
|
|
|
24335
24395
|
const fields = bundle.manifest.fields.filter((field) => field.source === "business");
|
|
24336
24396
|
if (bundle.manifest.schemaVersion === "4" && bundle.manifest.dataMode === "pipeline") {
|
|
24337
24397
|
for (const [key, schema] of Object.entries(bundle.manifest.dataModelSchema.properties ?? {})) {
|
|
24338
|
-
const
|
|
24339
|
-
if (!isPlainRecord(schema) || fields.some((field) => field.path ===
|
|
24398
|
+
const path25 = `/${key.replace(/~/g, "~0").replace(/\//g, "~1")}`;
|
|
24399
|
+
if (!isPlainRecord(schema) || fields.some((field) => field.path === path25))
|
|
24340
24400
|
continue;
|
|
24341
24401
|
if (!["string", "number", "integer", "boolean", "object", "array"].includes(String(schema.type)))
|
|
24342
24402
|
continue;
|
|
@@ -24345,7 +24405,7 @@ function extractA2UICardAuthoringModel(bundle, options = {}) {
|
|
|
24345
24405
|
idIndex += 1;
|
|
24346
24406
|
fields.push({
|
|
24347
24407
|
fieldId: `pipeline-field-${idIndex}`,
|
|
24348
|
-
path:
|
|
24408
|
+
path: path25,
|
|
24349
24409
|
label: key,
|
|
24350
24410
|
type: schema.type,
|
|
24351
24411
|
source: "business",
|
|
@@ -24497,8 +24557,8 @@ function isSafePageUrl2(url2, actionName) {
|
|
|
24497
24557
|
tokenCount++;
|
|
24498
24558
|
if (tokenCount > 32)
|
|
24499
24559
|
return false;
|
|
24500
|
-
const
|
|
24501
|
-
if (!(
|
|
24560
|
+
const path25 = match[1]?.trim() ?? "";
|
|
24561
|
+
if (!(path25 === "/" || path25.startsWith("/") || path25.startsWith("./")) || path25.split("/").some((part) => ["..", "__proto__", "constructor", "prototype"].includes(part))) {
|
|
24502
24562
|
return false;
|
|
24503
24563
|
}
|
|
24504
24564
|
}
|
|
@@ -25701,8 +25761,8 @@ function getErrorMap() {
|
|
|
25701
25761
|
|
|
25702
25762
|
// ../../node_modules/zod/v3/helpers/parseUtil.js
|
|
25703
25763
|
var makeIssue = (params) => {
|
|
25704
|
-
const { data, path:
|
|
25705
|
-
const fullPath = [...
|
|
25764
|
+
const { data, path: path25, errorMaps, issueData } = params;
|
|
25765
|
+
const fullPath = [...path25, ...issueData.path || []];
|
|
25706
25766
|
const fullIssue = {
|
|
25707
25767
|
...issueData,
|
|
25708
25768
|
path: fullPath
|
|
@@ -25818,11 +25878,11 @@ var errorUtil;
|
|
|
25818
25878
|
|
|
25819
25879
|
// ../../node_modules/zod/v3/types.js
|
|
25820
25880
|
var ParseInputLazyPath = class {
|
|
25821
|
-
constructor(parent, value,
|
|
25881
|
+
constructor(parent, value, path25, key) {
|
|
25822
25882
|
this._cachedPath = [];
|
|
25823
25883
|
this.parent = parent;
|
|
25824
25884
|
this.data = value;
|
|
25825
|
-
this._path =
|
|
25885
|
+
this._path = path25;
|
|
25826
25886
|
this._key = key;
|
|
25827
25887
|
}
|
|
25828
25888
|
get path() {
|
|
@@ -29460,10 +29520,10 @@ function assignProp(target, prop, value) {
|
|
|
29460
29520
|
configurable: true
|
|
29461
29521
|
});
|
|
29462
29522
|
}
|
|
29463
|
-
function getElementAtPath(obj,
|
|
29464
|
-
if (!
|
|
29523
|
+
function getElementAtPath(obj, path25) {
|
|
29524
|
+
if (!path25)
|
|
29465
29525
|
return obj;
|
|
29466
|
-
return
|
|
29526
|
+
return path25.reduce((acc, key) => acc?.[key], obj);
|
|
29467
29527
|
}
|
|
29468
29528
|
function promiseAllObject(promisesObj) {
|
|
29469
29529
|
const keys = Object.keys(promisesObj);
|
|
@@ -29783,11 +29843,11 @@ function aborted(x, startIndex = 0) {
|
|
|
29783
29843
|
}
|
|
29784
29844
|
return false;
|
|
29785
29845
|
}
|
|
29786
|
-
function prefixIssues(
|
|
29846
|
+
function prefixIssues(path25, issues) {
|
|
29787
29847
|
return issues.map((iss) => {
|
|
29788
29848
|
var _a;
|
|
29789
29849
|
(_a = iss).path ?? (_a.path = []);
|
|
29790
|
-
iss.path.unshift(
|
|
29850
|
+
iss.path.unshift(path25);
|
|
29791
29851
|
return iss;
|
|
29792
29852
|
});
|
|
29793
29853
|
}
|
|
@@ -38458,6 +38518,7 @@ var ERR_INVALID_UNIX_ID_SIZE = "uid/gid must be 0..65535 for unixExtraFieldType
|
|
|
38458
38518
|
var ERR_INVALID_MSDOS_ATTRIBUTES = "Invalid msdosAttributesRaw (must be integer 0..255)";
|
|
38459
38519
|
var ERR_INVALID_MSDOS_DATA = "Invalid msdosAttributes (must be an object with boolean flags)";
|
|
38460
38520
|
var ERR_INVALID_LEVEL = "Invalid level (must be integer 0..9)";
|
|
38521
|
+
var ERR_INVALID_UNCOMPRESSED_SIZE_OPTION = "Invalid uncompressedSize option (must be a non-negative integer)";
|
|
38461
38522
|
var ERR_INVALID_SIGNATURE_DATA = "Signature data exceeds 64KB";
|
|
38462
38523
|
var ERR_INVALID_ENTRY = "Invalid entry option (must be an entry returned by ZipReader#getEntries())";
|
|
38463
38524
|
var ERR_ZIP_CRYPTO_LAST_MOD_DATE = "The last modification date of an entry encrypted with ZipCrypto cannot be changed when passThrough is set";
|
|
@@ -39230,8 +39291,10 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
|
|
|
39230
39291
|
let maximumCompressedSize = 0;
|
|
39231
39292
|
let uncompressedSize = 0;
|
|
39232
39293
|
let unknownSize = false;
|
|
39294
|
+
const uncompressedSizeOption = toNumber(options[PROPERTY_NAME_UNCOMPRESSED_SIZE]);
|
|
39295
|
+
checkIntegerOption(uncompressedSizeOption, Number.MAX_SAFE_INTEGER, ERR_INVALID_UNCOMPRESSED_SIZE_OPTION);
|
|
39233
39296
|
if (passThroughCompression && hasContent) {
|
|
39234
|
-
uncompressedSize =
|
|
39297
|
+
uncompressedSize = uncompressedSizeOption;
|
|
39235
39298
|
if (uncompressedSize === UNDEFINED_VALUE) {
|
|
39236
39299
|
throw new Error(ERR_UNDEFINED_UNCOMPRESSED_SIZE);
|
|
39237
39300
|
}
|
|
@@ -39252,14 +39315,14 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
|
|
|
39252
39315
|
const encryptionOverhead = getEncryptionOverhead(encryptedEntry, zipCrypto, encryptionStrength);
|
|
39253
39316
|
if (hasContent) {
|
|
39254
39317
|
if (!passThroughCompression) {
|
|
39255
|
-
|
|
39256
|
-
|
|
39318
|
+
const expectedSize = contentSize === UNDEFINED_VALUE ? uncompressedSizeOption : contentSize;
|
|
39319
|
+
if (expectedSize === UNDEFINED_VALUE) {
|
|
39257
39320
|
if (zip64 || zip64 === UNDEFINED_VALUE) {
|
|
39258
39321
|
zip64 = unknownSize = true;
|
|
39259
39322
|
maximumCompressedSize = MAX_32_BITS + 1;
|
|
39260
39323
|
}
|
|
39261
39324
|
} else {
|
|
39262
|
-
options.uncompressedSize = uncompressedSize =
|
|
39325
|
+
options.uncompressedSize = uncompressedSize = expectedSize;
|
|
39263
39326
|
maximumCompressedSize = (isCompressed(compressionMethod, level) ? getMaximumCompressedSize(uncompressedSize) : uncompressedSize) + encryptionOverhead;
|
|
39264
39327
|
}
|
|
39265
39328
|
} else {
|
|
@@ -39268,7 +39331,9 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
|
|
|
39268
39331
|
}
|
|
39269
39332
|
}
|
|
39270
39333
|
const emptyEntry = !encryptedEntry && (!hasContent || contentSize === 0 && !passThroughCompression) && !isCompressed(compressionMethod, level);
|
|
39271
|
-
|
|
39334
|
+
const crc32Provided = options.crc32 !== UNDEFINED_VALUE || options[PROPERTY_NAME_SIGNATURE] !== UNDEFINED_VALUE;
|
|
39335
|
+
const completeHeader = passThroughCompression && hasContent && contentSize !== UNDEFINED_VALUE && !(encryptedEntry && zipCrypto) && (crc32Provided || encryptedEntry && !zipCrypto);
|
|
39336
|
+
if ((emptyEntry || completeHeader) && getOptionValue2(zipWriter, options, OPTION_DATA_DESCRIPTOR) === UNDEFINED_VALUE) {
|
|
39272
39337
|
dataDescriptor = false;
|
|
39273
39338
|
}
|
|
39274
39339
|
const zip64UncompressedSize = zip64Enabled || unknownSize || uncompressedSize >= MAX_32_BITS;
|
|
@@ -39286,6 +39351,8 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
|
|
|
39286
39351
|
resolvedOptions: {
|
|
39287
39352
|
dataDescriptor,
|
|
39288
39353
|
emptyEntry,
|
|
39354
|
+
completeHeader,
|
|
39355
|
+
knownCompressedSize: completeHeader ? maximumCompressedSize : UNDEFINED_VALUE,
|
|
39289
39356
|
zip64,
|
|
39290
39357
|
zip64Enabled,
|
|
39291
39358
|
unknownSize,
|
|
@@ -39307,6 +39374,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
39307
39374
|
keepOrder,
|
|
39308
39375
|
dataDescriptor,
|
|
39309
39376
|
emptyEntry,
|
|
39377
|
+
completeHeader,
|
|
39310
39378
|
signal
|
|
39311
39379
|
} = options;
|
|
39312
39380
|
const {
|
|
@@ -39328,7 +39396,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
39328
39396
|
const lockPreviousFileEntry = keepOrder && previousFileEntry ? previousFileEntry.lockFileEntry : UNDEFINED_VALUE;
|
|
39329
39397
|
fileEntries.set(name, fileEntry);
|
|
39330
39398
|
try {
|
|
39331
|
-
if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || zipWriter.directWrites || !dataDescriptor && !emptyEntry) {
|
|
39399
|
+
if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || zipWriter.directWrites || !dataDescriptor && !emptyEntry && !completeHeader) {
|
|
39332
39400
|
bufferedWrite = true;
|
|
39333
39401
|
zipWriter.bufferedWrites++;
|
|
39334
39402
|
if (options.createTempStream) {
|
|
@@ -39671,10 +39739,12 @@ function getHeaderInfo(options) {
|
|
|
39671
39739
|
zip64UncompressedSize,
|
|
39672
39740
|
zip64CompressedSize,
|
|
39673
39741
|
uncompressedSize,
|
|
39742
|
+
knownCompressedSize,
|
|
39674
39743
|
unknownSize,
|
|
39675
39744
|
crc32
|
|
39676
39745
|
} = options;
|
|
39677
39746
|
let { version: version3, compressionMethod } = options;
|
|
39747
|
+
const compressedSize = dataDescriptor ? UNDEFINED_VALUE : knownCompressedSize;
|
|
39678
39748
|
const compressed = !directory && isCompressed(compressionMethod, level);
|
|
39679
39749
|
let rawLocalExtraFieldZip64;
|
|
39680
39750
|
const uncompressedFile = passThroughCompression || !compressed;
|
|
@@ -39690,7 +39760,7 @@ function getHeaderInfo(options) {
|
|
|
39690
39760
|
extraFieldZip64.writeUint64(uncompressedSize);
|
|
39691
39761
|
if (uncompressedFile) {
|
|
39692
39762
|
const encryptionOverhead = getEncryptionOverhead(encrypted, zipCrypto, encryptionStrength);
|
|
39693
|
-
extraFieldZip64.writeUint64(passThroughCompression ? 0 : uncompressedSize + encryptionOverhead);
|
|
39763
|
+
extraFieldZip64.writeUint64(passThroughCompression ? compressedSize === UNDEFINED_VALUE ? 0 : compressedSize : uncompressedSize + encryptionOverhead);
|
|
39694
39764
|
}
|
|
39695
39765
|
}
|
|
39696
39766
|
} else {
|
|
@@ -39828,6 +39898,7 @@ function getHeaderInfo(options) {
|
|
|
39828
39898
|
bitFlag: getBitFlag(level, useUnicodeFileNames, dataDescriptor, encrypted, compressionMethod),
|
|
39829
39899
|
compressionMethod,
|
|
39830
39900
|
uncompressedSize,
|
|
39901
|
+
compressedSize,
|
|
39831
39902
|
lastModDate: clampedLastModDate,
|
|
39832
39903
|
rawLastModDate: rawLastModDateOption,
|
|
39833
39904
|
rawFilename,
|
|
@@ -39835,6 +39906,9 @@ function getHeaderInfo(options) {
|
|
|
39835
39906
|
zip64UncompressedSize,
|
|
39836
39907
|
extraFieldLength
|
|
39837
39908
|
});
|
|
39909
|
+
if (compressedSize !== UNDEFINED_VALUE && passThroughCompression && crc32 !== UNDEFINED_VALUE) {
|
|
39910
|
+
setUint32(headerView, HEADER_OFFSET_SIGNATURE, crc32);
|
|
39911
|
+
}
|
|
39838
39912
|
const localHeader = createRecordWriter(HEADER_SIZE + getLength(rawFilename) + extraFieldLength);
|
|
39839
39913
|
const localHeaderArray = localHeader.array;
|
|
39840
39914
|
const localHeaderView = getDataView(localHeaderArray);
|
|
@@ -43676,11 +43750,11 @@ var decodeSpan = (source, span, byteRange, push) => {
|
|
|
43676
43750
|
startedAt: nanoToMs(event.timeUnixNano),
|
|
43677
43751
|
outcome: strAttr(eventAttributes, ETelemetryAttribute.HARNESS_OPERATION_OUTCOME),
|
|
43678
43752
|
byteRange
|
|
43679
|
-
});
|
|
43753
|
+
}, event);
|
|
43680
43754
|
}
|
|
43681
43755
|
}
|
|
43682
43756
|
};
|
|
43683
|
-
function
|
|
43757
|
+
function decodeLine(line, source, byteRange, onRecord) {
|
|
43684
43758
|
const warnings = [];
|
|
43685
43759
|
let json;
|
|
43686
43760
|
try {
|
|
@@ -43714,13 +43788,52 @@ function decodeOtlpLine(line, source, byteRange) {
|
|
|
43714
43788
|
warnings.push(logs ? "logs_without_resourceLogs" : "traces_without_resourceSpans");
|
|
43715
43789
|
return { facts, warnings };
|
|
43716
43790
|
}
|
|
43791
|
+
const envelopeRoot = { ...root };
|
|
43792
|
+
delete envelopeRoot[resourceKey];
|
|
43717
43793
|
for (const resource of objects(root[resourceKey], resourceKey)) {
|
|
43794
|
+
const envelopeResource = { ...resource };
|
|
43795
|
+
delete envelopeResource[scopeKey];
|
|
43718
43796
|
for (const scope of objects(resource[scopeKey], scopeKey)) {
|
|
43797
|
+
const envelopeScope = { ...scope };
|
|
43798
|
+
delete envelopeScope[recordKey];
|
|
43719
43799
|
for (const record2 of objects(scope[recordKey], recordKey)) {
|
|
43720
43800
|
const decoded = [];
|
|
43801
|
+
let primaryFact;
|
|
43802
|
+
const spanEvents = [];
|
|
43721
43803
|
try {
|
|
43722
|
-
(logs ? decodeLogRecord : decodeSpan)(source, record2, byteRange, (fact) =>
|
|
43804
|
+
(logs ? decodeLogRecord : decodeSpan)(source, record2, byteRange, (fact, event) => {
|
|
43805
|
+
decoded.push(fact);
|
|
43806
|
+
if (event) {
|
|
43807
|
+
if (onRecord)
|
|
43808
|
+
spanEvents.push({ record: event, fact });
|
|
43809
|
+
} else {
|
|
43810
|
+
primaryFact = fact;
|
|
43811
|
+
}
|
|
43812
|
+
});
|
|
43813
|
+
if (!primaryFact)
|
|
43814
|
+
throw new TypeError("Missing primary record fact");
|
|
43723
43815
|
facts.push(...decoded);
|
|
43816
|
+
onRecord?.({
|
|
43817
|
+
source,
|
|
43818
|
+
record: record2,
|
|
43819
|
+
facts: decoded,
|
|
43820
|
+
primaryFact,
|
|
43821
|
+
spanEvents,
|
|
43822
|
+
envelopeContext: {
|
|
43823
|
+
root: envelopeRoot,
|
|
43824
|
+
resource: envelopeResource,
|
|
43825
|
+
scope: envelopeScope
|
|
43826
|
+
},
|
|
43827
|
+
envelope: {
|
|
43828
|
+
...envelopeRoot,
|
|
43829
|
+
[resourceKey]: [
|
|
43830
|
+
{
|
|
43831
|
+
...envelopeResource,
|
|
43832
|
+
[scopeKey]: [{ ...envelopeScope, [recordKey]: [record2] }]
|
|
43833
|
+
}
|
|
43834
|
+
]
|
|
43835
|
+
}
|
|
43836
|
+
});
|
|
43724
43837
|
} catch {
|
|
43725
43838
|
warnings.push(`invalid_${recordKey}_record`);
|
|
43726
43839
|
}
|
|
@@ -43729,6 +43842,14 @@ function decodeOtlpLine(line, source, byteRange) {
|
|
|
43729
43842
|
}
|
|
43730
43843
|
return { facts, warnings };
|
|
43731
43844
|
}
|
|
43845
|
+
function decodeOtlpLine(line, source, byteRange) {
|
|
43846
|
+
return decodeLine(line, source, byteRange);
|
|
43847
|
+
}
|
|
43848
|
+
function decodeOtlpRecords(line, source) {
|
|
43849
|
+
const records = [];
|
|
43850
|
+
const result = decodeLine(line, source, void 0, (record2) => records.push(record2));
|
|
43851
|
+
return { ...result, records };
|
|
43852
|
+
}
|
|
43732
43853
|
|
|
43733
43854
|
// ../linkque-agent-runtime-trace/dist/esm/summarize.js
|
|
43734
43855
|
var import_node_crypto3 = require("node:crypto");
|
|
@@ -43971,6 +44092,173 @@ function summarize(input) {
|
|
|
43971
44092
|
};
|
|
43972
44093
|
}
|
|
43973
44094
|
|
|
44095
|
+
// ../linkque-agent-runtime-trace/dist/esm/turnRecords.js
|
|
44096
|
+
function isTurnShareContentAllowed(fact) {
|
|
44097
|
+
const section = fact.body?.section;
|
|
44098
|
+
return section !== ETelemetryContentSection.MODEL_INPUT_DIGEST && section !== ETelemetryContentSection.FOLLOW_UP_QUESTION_INPUT;
|
|
44099
|
+
}
|
|
44100
|
+
function belongsToTurn(fact, identity) {
|
|
44101
|
+
return fact.identity.threadId === identity.threadId && fact.identity.runId === identity.runId && fact.identity.advanceId === identity.advanceId;
|
|
44102
|
+
}
|
|
44103
|
+
function selectTurnRecords(records, identity) {
|
|
44104
|
+
if (!identity.threadId || !identity.runId || !identity.advanceId)
|
|
44105
|
+
throw new TypeError("\u5206\u4EAB\u5FC5\u987B\u6307\u5B9A\u5B8C\u6574\u6267\u884C\u8EAB\u4EFD");
|
|
44106
|
+
return records.flatMap((entry) => {
|
|
44107
|
+
const primary = entry.primaryFact;
|
|
44108
|
+
if (!belongsToTurn(primary, identity))
|
|
44109
|
+
return [];
|
|
44110
|
+
if (!isTurnShareContentAllowed(primary))
|
|
44111
|
+
return [];
|
|
44112
|
+
if (entry.source !== "traces" || !Array.isArray(entry.record.events))
|
|
44113
|
+
return [entry];
|
|
44114
|
+
const spanEvents = entry.spanEvents.filter(({ fact }) => belongsToTurn(fact, identity) && isTurnShareContentAllowed(fact));
|
|
44115
|
+
const events = spanEvents.map(({ record: record3 }) => record3);
|
|
44116
|
+
const record2 = { ...entry.record, events };
|
|
44117
|
+
const { root, resource, scope } = entry.envelopeContext;
|
|
44118
|
+
return [
|
|
44119
|
+
{
|
|
44120
|
+
...entry,
|
|
44121
|
+
record: record2,
|
|
44122
|
+
spanEvents,
|
|
44123
|
+
facts: [primary, ...spanEvents.map(({ fact }) => fact)],
|
|
44124
|
+
envelope: {
|
|
44125
|
+
...root,
|
|
44126
|
+
resourceSpans: [
|
|
44127
|
+
{ ...resource, scopeSpans: [{ ...scope, spans: [record2] }] }
|
|
44128
|
+
]
|
|
44129
|
+
}
|
|
44130
|
+
}
|
|
44131
|
+
];
|
|
44132
|
+
});
|
|
44133
|
+
}
|
|
44134
|
+
|
|
44135
|
+
// ../linkque-agent-runtime-trace/dist/esm/queryContent.js
|
|
44136
|
+
var matchContentRef = (fact, ref) => {
|
|
44137
|
+
const { advanceId, operationId, recordId, section } = ref;
|
|
44138
|
+
if (advanceId && fact.identity.advanceId !== advanceId)
|
|
44139
|
+
return false;
|
|
44140
|
+
if (operationId && fact.identity.operationId !== operationId)
|
|
44141
|
+
return false;
|
|
44142
|
+
if (recordId && fact.identity.recordId !== recordId)
|
|
44143
|
+
return false;
|
|
44144
|
+
const body = fact.body;
|
|
44145
|
+
return body?.section === section;
|
|
44146
|
+
};
|
|
44147
|
+
function parseTraceContentSelection(input) {
|
|
44148
|
+
const { contentRef, cursor, maxBytes: requestedMaxBytes } = input;
|
|
44149
|
+
if (!contentRef || typeof contentRef !== "object" || Array.isArray(contentRef))
|
|
44150
|
+
return null;
|
|
44151
|
+
const ref = contentRef;
|
|
44152
|
+
if (typeof ref.section !== "string" || !ref.section)
|
|
44153
|
+
return null;
|
|
44154
|
+
for (const value of [ref.advanceId, ref.operationId, ref.recordId]) {
|
|
44155
|
+
if (value !== void 0 && (typeof value !== "string" || !value))
|
|
44156
|
+
return null;
|
|
44157
|
+
}
|
|
44158
|
+
if (ref.recordIds !== void 0 && (!Array.isArray(ref.recordIds) || !ref.recordIds.length || ref.recordIds.length > 128 || ref.recordIds.some((id) => typeof id !== "string" || !id)))
|
|
44159
|
+
return null;
|
|
44160
|
+
if (cursor !== void 0 && (typeof cursor !== "string" || !/^(0|[1-9][0-9]*)$/.test(cursor)))
|
|
44161
|
+
return null;
|
|
44162
|
+
const offset = cursor === void 0 ? 0 : Number(cursor);
|
|
44163
|
+
if (!Number.isSafeInteger(offset))
|
|
44164
|
+
return null;
|
|
44165
|
+
if (requestedMaxBytes !== void 0 && (typeof requestedMaxBytes !== "number" || !Number.isSafeInteger(requestedMaxBytes) || requestedMaxBytes < 1))
|
|
44166
|
+
return null;
|
|
44167
|
+
return {
|
|
44168
|
+
contentRef: ref,
|
|
44169
|
+
offset,
|
|
44170
|
+
maxBytes: requestedMaxBytes ?? 1024 * 1024
|
|
44171
|
+
};
|
|
44172
|
+
}
|
|
44173
|
+
function readTraceContent(input) {
|
|
44174
|
+
const { facts, identity, contentRef, offset, maxBytes } = input;
|
|
44175
|
+
let matched = facts.find((f3) => f3.name === ETelemetryEventName.CONTENT_RECORDED && (!identity.threadId || f3.identity.threadId === identity.threadId) && (!identity.advanceId || f3.identity.advanceId === identity.advanceId) && (!identity.runId || f3.identity.runId === identity.runId) && matchContentRef(f3, contentRef));
|
|
44176
|
+
if (contentRef.recordIds) {
|
|
44177
|
+
const byRecord = new Map(facts.filter((f3) => f3.name === ETelemetryEventName.CONTENT_RECORDED && f3.identity.advanceId === identity.advanceId && (!identity.threadId || f3.identity.threadId === identity.threadId) && (!identity.runId || f3.identity.runId === identity.runId) && f3.identity.operationId === contentRef.operationId).map((f3) => [f3.identity.recordId, f3]));
|
|
44178
|
+
const chunks = contentRef.recordIds.map((id) => byRecord.get(id));
|
|
44179
|
+
if (chunks.some((chunk) => !chunk))
|
|
44180
|
+
return { availability: "unavailable" };
|
|
44181
|
+
const values = chunks.map((chunk) => chunk.body);
|
|
44182
|
+
if (values.some((value) => value.section !== "model.output" || typeof value.value !== "string"))
|
|
44183
|
+
return null;
|
|
44184
|
+
const prefix = [];
|
|
44185
|
+
for (const value of values) {
|
|
44186
|
+
if (value.chunkIndex !== prefix.length)
|
|
44187
|
+
break;
|
|
44188
|
+
prefix.push(value);
|
|
44189
|
+
}
|
|
44190
|
+
if (!prefix.length)
|
|
44191
|
+
return { availability: "unavailable" };
|
|
44192
|
+
const complete = prefix.length === values.length && prefix.at(-1)?.final && prefix.at(-1)?.availability === "available";
|
|
44193
|
+
matched = {
|
|
44194
|
+
...chunks[0],
|
|
44195
|
+
body: {
|
|
44196
|
+
value: prefix.map((value) => value.value).join(""),
|
|
44197
|
+
availability: complete ? "available" : "partial"
|
|
44198
|
+
}
|
|
44199
|
+
};
|
|
44200
|
+
}
|
|
44201
|
+
if (!matched) {
|
|
44202
|
+
return { availability: "unavailable" };
|
|
44203
|
+
}
|
|
44204
|
+
const body = matched.body;
|
|
44205
|
+
let availability = "available";
|
|
44206
|
+
if (body.availability === "partial") {
|
|
44207
|
+
availability = "partial";
|
|
44208
|
+
} else if (body.availability === "unavailable") {
|
|
44209
|
+
availability = "unavailable";
|
|
44210
|
+
}
|
|
44211
|
+
if (body.value === void 0)
|
|
44212
|
+
return { availability: "not_recorded" };
|
|
44213
|
+
const serialized = JSON.stringify(body.value);
|
|
44214
|
+
const buf = Buffer.from(serialized, "utf8");
|
|
44215
|
+
const totalBytes = buf.length;
|
|
44216
|
+
if (offset < totalBytes && (buf[offset] & 192) === 128)
|
|
44217
|
+
return null;
|
|
44218
|
+
if (offset >= totalBytes) {
|
|
44219
|
+
return { availability: "available" };
|
|
44220
|
+
}
|
|
44221
|
+
const remaining = totalBytes - offset;
|
|
44222
|
+
const pageBytes = Math.min(maxBytes, remaining);
|
|
44223
|
+
const isFullContent = offset === 0 && totalBytes <= maxBytes;
|
|
44224
|
+
const titles = body.fieldTitles;
|
|
44225
|
+
const fieldTitles = titles && typeof titles === "object" && !Array.isArray(titles) ? Object.fromEntries(Object.entries(titles).filter(([path25, title]) => path25.startsWith("/") && typeof title === "string")) : void 0;
|
|
44226
|
+
const evidence = {
|
|
44227
|
+
...body.originalBytes !== void 0 ? { originalBytes: body.originalBytes } : {},
|
|
44228
|
+
...body.storedBytes !== void 0 ? { storedBytes: body.storedBytes } : {},
|
|
44229
|
+
...fieldTitles && Object.keys(fieldTitles).length ? { fieldTitles } : {}
|
|
44230
|
+
};
|
|
44231
|
+
if (isFullContent) {
|
|
44232
|
+
return {
|
|
44233
|
+
content: body.value,
|
|
44234
|
+
contentType: body.contentType,
|
|
44235
|
+
encoding: body.encoding,
|
|
44236
|
+
availability,
|
|
44237
|
+
...Object.keys(evidence).length ? { evidence } : {}
|
|
44238
|
+
};
|
|
44239
|
+
}
|
|
44240
|
+
let end = offset + pageBytes;
|
|
44241
|
+
while (end > offset && end < totalBytes && (buf[end] & 192) === 128) {
|
|
44242
|
+
end--;
|
|
44243
|
+
}
|
|
44244
|
+
if (end === offset) {
|
|
44245
|
+
end = Math.min(offset + 1, totalBytes);
|
|
44246
|
+
while (end < totalBytes && (buf[end] & 192) === 128)
|
|
44247
|
+
end++;
|
|
44248
|
+
}
|
|
44249
|
+
const pageContent = buf.subarray(offset, end).toString("utf8");
|
|
44250
|
+
const nextOffset = end;
|
|
44251
|
+
const hasNext = nextOffset < totalBytes;
|
|
44252
|
+
return {
|
|
44253
|
+
content: pageContent,
|
|
44254
|
+
contentType: "application/json-fragment",
|
|
44255
|
+
encoding: body.encoding,
|
|
44256
|
+
availability: hasNext ? "partial" : availability,
|
|
44257
|
+
nextCursor: hasNext ? String(nextOffset) : void 0,
|
|
44258
|
+
...Object.keys(evidence).length ? { evidence } : {}
|
|
44259
|
+
};
|
|
44260
|
+
}
|
|
44261
|
+
|
|
43974
44262
|
// src/utils/otlpScanner.ts
|
|
43975
44263
|
var import_node_path13 = __toESM(require("node:path"));
|
|
43976
44264
|
var import_node_crypto4 = require("node:crypto");
|
|
@@ -44010,7 +44298,7 @@ var parseDetailRef = (ref) => {
|
|
|
44010
44298
|
};
|
|
44011
44299
|
|
|
44012
44300
|
// src/utils/otlpScanner.ts
|
|
44013
|
-
var scanFile = (content, source) => {
|
|
44301
|
+
var scanFile = (content, source, rawRecords) => {
|
|
44014
44302
|
if (!content) return { facts: [], warnings: [] };
|
|
44015
44303
|
const facts = [];
|
|
44016
44304
|
const warnings = [];
|
|
@@ -44018,16 +44306,15 @@ var scanFile = (content, source) => {
|
|
|
44018
44306
|
if (lines.pop()) warnings.push("incomplete_tail");
|
|
44019
44307
|
for (const line of lines) {
|
|
44020
44308
|
if (!line) continue;
|
|
44021
|
-
const
|
|
44022
|
-
|
|
44023
|
-
|
|
44024
|
-
);
|
|
44309
|
+
const decoded = rawRecords ? decodeOtlpRecords(line, source) : decodeOtlpLine(line, source);
|
|
44310
|
+
if (rawRecords && decoded.records) rawRecords.push(...decoded.records);
|
|
44311
|
+
const { facts: lineFacts, warnings: lineWarnings } = decoded;
|
|
44025
44312
|
for (const fact of lineFacts) facts.push(fact);
|
|
44026
44313
|
for (const w2 of lineWarnings) warnings.push(w2);
|
|
44027
44314
|
}
|
|
44028
44315
|
return { facts, warnings };
|
|
44029
44316
|
};
|
|
44030
|
-
async function scanRetainedLogs(cwd, pinned) {
|
|
44317
|
+
async function scanRetainedLogs(cwd, pinned, options) {
|
|
44031
44318
|
const dir = import_node_path13.default.join(cwd, LOGS_ROOT);
|
|
44032
44319
|
let files;
|
|
44033
44320
|
try {
|
|
@@ -44041,6 +44328,8 @@ async function scanRetainedLogs(cwd, pinned) {
|
|
|
44041
44328
|
const warnings = [];
|
|
44042
44329
|
const readWindow = [];
|
|
44043
44330
|
const remaining = new Set(pinned);
|
|
44331
|
+
const rawRecords = options?.collectRaw ? [] : void 0;
|
|
44332
|
+
let scannedBytes = 0;
|
|
44044
44333
|
const retainedFiles = /* @__PURE__ */ new Map();
|
|
44045
44334
|
for (const [source, file] of Object.entries(OTLP_LOG_FILES)) {
|
|
44046
44335
|
for (let index = 0; index <= 3; index++) {
|
|
@@ -44053,7 +44342,12 @@ async function scanRetainedLogs(cwd, pinned) {
|
|
|
44053
44342
|
const source = retainedFiles.get(file);
|
|
44054
44343
|
const filePath = import_node_path13.default.join(dir, file);
|
|
44055
44344
|
const before = await (0, import_promises20.stat)(filePath);
|
|
44345
|
+
if (options && scannedBytes + before.size > options.maxBytes)
|
|
44346
|
+
throw new RangeError("\u539F\u59CB\u65E5\u5FD7\u8D85\u8FC7\u5F52\u6863\u8BFB\u53D6\u4E0A\u9650");
|
|
44056
44347
|
const content = await (0, import_promises20.readFile)(filePath);
|
|
44348
|
+
scannedBytes += content.length;
|
|
44349
|
+
if (options && scannedBytes > options.maxBytes)
|
|
44350
|
+
throw new RangeError("\u539F\u59CB\u65E5\u5FD7\u8D85\u8FC7\u5F52\u6863\u8BFB\u53D6\u4E0A\u9650");
|
|
44057
44351
|
const after = await (0, import_promises20.stat)(filePath);
|
|
44058
44352
|
if (before.ino !== after.ino || after.size < before.size) {
|
|
44059
44353
|
warnings.push("log_rotated_during_read");
|
|
@@ -44078,7 +44372,7 @@ async function scanRetainedLogs(cwd, pinned) {
|
|
|
44078
44372
|
};
|
|
44079
44373
|
}
|
|
44080
44374
|
readWindow.push(window);
|
|
44081
|
-
const decoded = scanFile(complete.toString("utf8"), source);
|
|
44375
|
+
const decoded = scanFile(complete.toString("utf8"), source, rawRecords);
|
|
44082
44376
|
for (const fact of decoded.facts) facts.push(fact);
|
|
44083
44377
|
for (const warning of decoded.warnings) warnings.push(warning);
|
|
44084
44378
|
} catch (error2) {
|
|
@@ -44089,7 +44383,12 @@ async function scanRetainedLogs(cwd, pinned) {
|
|
|
44089
44383
|
if (!selected.some((file) => retainedFiles.get(file) === "logs") || !selected.some((file) => retainedFiles.get(file) === "traces"))
|
|
44090
44384
|
warnings.push("signal_unavailable");
|
|
44091
44385
|
if (pinned && remaining.size) warnings.push("read_window_expired");
|
|
44092
|
-
return {
|
|
44386
|
+
return {
|
|
44387
|
+
facts,
|
|
44388
|
+
warnings: [...new Set(warnings)],
|
|
44389
|
+
readWindow,
|
|
44390
|
+
...rawRecords ? { rawRecords } : {}
|
|
44391
|
+
};
|
|
44093
44392
|
}
|
|
44094
44393
|
|
|
44095
44394
|
// src/commands/runs/listScanner.ts
|
|
@@ -44249,14 +44548,6 @@ var scanExecution = async (input) => {
|
|
|
44249
44548
|
};
|
|
44250
44549
|
|
|
44251
44550
|
// src/commands/runs/contentScanner.ts
|
|
44252
|
-
var matchContentRef = (fact, ref) => {
|
|
44253
|
-
const { advanceId, operationId, recordId, section } = ref;
|
|
44254
|
-
if (advanceId && fact.identity.advanceId !== advanceId) return false;
|
|
44255
|
-
if (operationId && fact.identity.operationId !== operationId) return false;
|
|
44256
|
-
if (recordId && fact.identity.recordId !== recordId) return false;
|
|
44257
|
-
const body = fact.body;
|
|
44258
|
-
return body?.section === section;
|
|
44259
|
-
};
|
|
44260
44551
|
var scanContent = async (input) => {
|
|
44261
44552
|
const identity = parseDetailRef(input.detailRef);
|
|
44262
44553
|
if (!identity) return null;
|
|
@@ -44268,125 +44559,121 @@ var scanContent = async (input) => {
|
|
|
44268
44559
|
} catch {
|
|
44269
44560
|
return null;
|
|
44270
44561
|
}
|
|
44271
|
-
|
|
44272
|
-
|
|
44273
|
-
for (const value of [
|
|
44274
|
-
contentRef.advanceId,
|
|
44275
|
-
contentRef.operationId,
|
|
44276
|
-
contentRef.recordId
|
|
44277
|
-
]) {
|
|
44278
|
-
if (value !== void 0 && (typeof value !== "string" || !value))
|
|
44279
|
-
return null;
|
|
44280
|
-
}
|
|
44281
|
-
if (contentRef.recordIds !== void 0 && (!Array.isArray(contentRef.recordIds) || !contentRef.recordIds.length || contentRef.recordIds.length > 128 || contentRef.recordIds.some((id) => typeof id !== "string" || !id)))
|
|
44282
|
-
return null;
|
|
44283
|
-
if (input.cursor !== void 0 && !/^(0|[1-9][0-9]*)$/.test(input.cursor))
|
|
44284
|
-
return null;
|
|
44285
|
-
if (input.maxBytes !== void 0 && (!Number.isSafeInteger(input.maxBytes) || input.maxBytes < 1))
|
|
44286
|
-
return null;
|
|
44562
|
+
const selection = parseTraceContentSelection({ ...input, contentRef });
|
|
44563
|
+
if (!selection) return null;
|
|
44287
44564
|
const { facts, warnings } = await scanRetainedLogs(
|
|
44288
44565
|
input.cwd,
|
|
44289
44566
|
identity.readWindow
|
|
44290
44567
|
);
|
|
44291
44568
|
if (warnings.includes("read_window_expired"))
|
|
44292
44569
|
return { availability: "unavailable" };
|
|
44293
|
-
|
|
44294
|
-
|
|
44295
|
-
|
|
44296
|
-
|
|
44297
|
-
|
|
44298
|
-
|
|
44299
|
-
|
|
44300
|
-
|
|
44301
|
-
|
|
44302
|
-
|
|
44303
|
-
|
|
44304
|
-
|
|
44305
|
-
|
|
44570
|
+
return readTraceContent({ ...selection, facts, identity });
|
|
44571
|
+
};
|
|
44572
|
+
|
|
44573
|
+
// src/commands/runs/exportScanner.ts
|
|
44574
|
+
var import_node_path14 = __toESM(require("node:path"));
|
|
44575
|
+
var import_node_fs9 = require("node:fs");
|
|
44576
|
+
var import_node_stream2 = require("node:stream");
|
|
44577
|
+
var import_promises21 = require("node:stream/promises");
|
|
44578
|
+
var import_node_zlib2 = require("node:zlib");
|
|
44579
|
+
var import_promises22 = require("node:fs/promises");
|
|
44580
|
+
var TURN_ARCHIVE_MAX_BYTES = 16 * 1024 * 1024;
|
|
44581
|
+
var TURN_SOURCE_MAX_BYTES = 64 * 1024 * 1024;
|
|
44582
|
+
var TURN_UNCOMPRESSED_ARCHIVE_MAX_BYTES = 64 * 1024 * 1024;
|
|
44583
|
+
async function exportTurn(cwd, identity) {
|
|
44584
|
+
let records;
|
|
44585
|
+
let sourceWarnings;
|
|
44586
|
+
try {
|
|
44587
|
+
const scanned = await scanRetainedLogs(cwd, void 0, {
|
|
44588
|
+
collectRaw: true,
|
|
44589
|
+
maxBytes: TURN_SOURCE_MAX_BYTES
|
|
44590
|
+
});
|
|
44591
|
+
records = selectTurnRecords(scanned.rawRecords ?? [], identity);
|
|
44592
|
+
sourceWarnings = scanned.warnings;
|
|
44593
|
+
} catch (cause) {
|
|
44594
|
+
throw new LinkqueCliError(
|
|
44595
|
+
cause instanceof RangeError ? "RUNS_EXPORT_SIZE_EXCEEDED" : "RUNS_EXPORT_FAILED",
|
|
44596
|
+
"\u8C03\u8BD5\u65E5\u5FD7\u8BFB\u53D6\u5931\u8D25",
|
|
44597
|
+
{ cause }
|
|
44306
44598
|
);
|
|
44307
|
-
if (values.some(
|
|
44308
|
-
(value) => value.section !== "model.output" || typeof value.value !== "string"
|
|
44309
|
-
))
|
|
44310
|
-
return null;
|
|
44311
|
-
const prefix = [];
|
|
44312
|
-
for (const value of values) {
|
|
44313
|
-
if (value.chunkIndex !== prefix.length) break;
|
|
44314
|
-
prefix.push(value);
|
|
44315
|
-
}
|
|
44316
|
-
if (!prefix.length) return { availability: "unavailable" };
|
|
44317
|
-
const complete = prefix.length === values.length && prefix.at(-1)?.final && prefix.at(-1)?.availability === "available";
|
|
44318
|
-
matched = {
|
|
44319
|
-
...chunks[0],
|
|
44320
|
-
body: {
|
|
44321
|
-
value: prefix.map((value) => value.value).join(""),
|
|
44322
|
-
availability: complete ? "available" : "partial"
|
|
44323
|
-
}
|
|
44324
|
-
};
|
|
44325
|
-
}
|
|
44326
|
-
if (!matched) {
|
|
44327
|
-
return { availability: "unavailable" };
|
|
44328
44599
|
}
|
|
44329
|
-
|
|
44330
|
-
|
|
44331
|
-
|
|
44332
|
-
|
|
44333
|
-
|
|
44334
|
-
|
|
44335
|
-
}
|
|
44336
|
-
const
|
|
44337
|
-
|
|
44338
|
-
|
|
44339
|
-
|
|
44340
|
-
|
|
44341
|
-
|
|
44342
|
-
|
|
44343
|
-
|
|
44344
|
-
|
|
44345
|
-
|
|
44346
|
-
|
|
44347
|
-
|
|
44348
|
-
|
|
44349
|
-
const isFullContent = offset === 0 && totalBytes <= maxBytes;
|
|
44350
|
-
const titles = body.fieldTitles;
|
|
44351
|
-
const fieldTitles = titles && typeof titles === "object" && !Array.isArray(titles) ? Object.fromEntries(
|
|
44352
|
-
Object.entries(titles).filter(
|
|
44353
|
-
([path24, title]) => path24.startsWith("/") && typeof title === "string"
|
|
44354
|
-
)
|
|
44355
|
-
) : void 0;
|
|
44356
|
-
const evidence = {
|
|
44357
|
-
...body.originalBytes !== void 0 ? { originalBytes: body.originalBytes } : {},
|
|
44358
|
-
...body.storedBytes !== void 0 ? { storedBytes: body.storedBytes } : {},
|
|
44359
|
-
...fieldTitles && Object.keys(fieldTitles).length ? { fieldTitles } : {}
|
|
44360
|
-
};
|
|
44361
|
-
if (isFullContent) {
|
|
44362
|
-
return {
|
|
44363
|
-
content: body.value,
|
|
44364
|
-
contentType: body.contentType,
|
|
44365
|
-
encoding: body.encoding,
|
|
44366
|
-
availability,
|
|
44367
|
-
...Object.keys(evidence).length ? { evidence } : {}
|
|
44600
|
+
if (!records.length)
|
|
44601
|
+
throw new LinkqueCliError(
|
|
44602
|
+
"RUNS_EXPORT_SOURCE_UNAVAILABLE",
|
|
44603
|
+
"\u76EE\u6807\u8F6E\u6B21\u65E5\u5FD7\u4E0D\u53EF\u7528"
|
|
44604
|
+
);
|
|
44605
|
+
const root = import_node_path14.default.join(cwd, ".linkque", "tmp");
|
|
44606
|
+
await (0, import_promises22.mkdir)(root, { recursive: true });
|
|
44607
|
+
const directory = await (0, import_promises22.mkdtemp)(import_node_path14.default.join(root, "turn-share-"));
|
|
44608
|
+
const archivePath = import_node_path14.default.join(directory, "logs.tar.gz");
|
|
44609
|
+
let result;
|
|
44610
|
+
try {
|
|
44611
|
+
const files = {
|
|
44612
|
+
"manifest.json": JSON.stringify({
|
|
44613
|
+
formatVersion: 1,
|
|
44614
|
+
identity,
|
|
44615
|
+
producerVersion: CLI_VERSION,
|
|
44616
|
+
sourceWarnings
|
|
44617
|
+
}),
|
|
44618
|
+
"logs.jsonl": records.filter((entry) => entry.source === "logs").map((entry) => JSON.stringify(entry.envelope)).join("\n") + "\n",
|
|
44619
|
+
"traces.jsonl": records.filter((entry) => entry.source === "traces").map((entry) => JSON.stringify(entry.envelope)).join("\n") + "\n"
|
|
44368
44620
|
};
|
|
44621
|
+
const payloadBytes = Object.values(files).reduce(
|
|
44622
|
+
(total, value) => total + Buffer.byteLength(value),
|
|
44623
|
+
0
|
|
44624
|
+
);
|
|
44625
|
+
if (payloadBytes > TURN_UNCOMPRESSED_ARCHIVE_MAX_BYTES)
|
|
44626
|
+
throw new RangeError("\u672A\u538B\u7F29\u5F52\u6863\u5185\u5BB9\u8D85\u8FC7\u4E0A\u9650");
|
|
44627
|
+
for (const [name, value] of Object.entries(files))
|
|
44628
|
+
await (0, import_promises22.writeFile)(import_node_path14.default.join(directory, name), value, { flag: "wx" });
|
|
44629
|
+
let uncompressedBytes = 0;
|
|
44630
|
+
let compressedBytes = 0;
|
|
44631
|
+
const rawBudget = new import_node_stream2.Transform({
|
|
44632
|
+
transform(chunk, _encoding, callback) {
|
|
44633
|
+
uncompressedBytes += chunk.length;
|
|
44634
|
+
callback(
|
|
44635
|
+
uncompressedBytes > TURN_UNCOMPRESSED_ARCHIVE_MAX_BYTES ? new RangeError("\u65E5\u5FD7\u8D85\u8FC7\u89E3\u538B\u4E0A\u9650") : null,
|
|
44636
|
+
chunk
|
|
44637
|
+
);
|
|
44638
|
+
}
|
|
44639
|
+
});
|
|
44640
|
+
const compressedBudget = new import_node_stream2.Transform({
|
|
44641
|
+
transform(chunk, _encoding, callback) {
|
|
44642
|
+
compressedBytes += chunk.length;
|
|
44643
|
+
callback(
|
|
44644
|
+
compressedBytes > TURN_ARCHIVE_MAX_BYTES ? new RangeError("\u538B\u7F29\u65E5\u5FD7\u8D85\u8FC7\u5F52\u6863\u4E0A\u9650") : null,
|
|
44645
|
+
chunk
|
|
44646
|
+
);
|
|
44647
|
+
}
|
|
44648
|
+
});
|
|
44649
|
+
await (0, import_promises21.pipeline)(
|
|
44650
|
+
Qn(
|
|
44651
|
+
{ cwd: directory, portable: true },
|
|
44652
|
+
Object.keys(files)
|
|
44653
|
+
),
|
|
44654
|
+
rawBudget,
|
|
44655
|
+
(0, import_node_zlib2.createGzip)(),
|
|
44656
|
+
compressedBudget,
|
|
44657
|
+
(0, import_node_fs9.createWriteStream)(archivePath, { flags: "wx" })
|
|
44658
|
+
);
|
|
44659
|
+
result = { archivePath, compressedBytes, uncompressedBytes };
|
|
44660
|
+
} catch (cause) {
|
|
44661
|
+
await (0, import_promises22.rm)(directory, { recursive: true, force: true }).catch(
|
|
44662
|
+
() => void 0
|
|
44663
|
+
);
|
|
44664
|
+
throw new LinkqueCliError(
|
|
44665
|
+
cause instanceof RangeError ? "RUNS_EXPORT_SIZE_EXCEEDED" : "RUNS_EXPORT_FAILED",
|
|
44666
|
+
"\u672C\u8F6E\u65E5\u5FD7\u5F52\u6863\u5931\u8D25",
|
|
44667
|
+
{ cause }
|
|
44668
|
+
);
|
|
44369
44669
|
}
|
|
44370
|
-
|
|
44371
|
-
|
|
44372
|
-
|
|
44373
|
-
|
|
44374
|
-
if (end === offset) {
|
|
44375
|
-
end = Math.min(offset + 1, totalBytes);
|
|
44376
|
-
while (end < totalBytes && (buf[end] & 192) === 128) end++;
|
|
44670
|
+
for (const name of ["manifest.json", "logs.jsonl", "traces.jsonl"]) {
|
|
44671
|
+
await (0, import_promises22.rm)(import_node_path14.default.join(directory, name), { force: true }).catch(
|
|
44672
|
+
() => void 0
|
|
44673
|
+
);
|
|
44377
44674
|
}
|
|
44378
|
-
|
|
44379
|
-
|
|
44380
|
-
const hasNext = nextOffset < totalBytes;
|
|
44381
|
-
return {
|
|
44382
|
-
content: pageContent,
|
|
44383
|
-
contentType: "application/json-fragment",
|
|
44384
|
-
encoding: body.encoding,
|
|
44385
|
-
availability: hasNext ? "partial" : availability,
|
|
44386
|
-
nextCursor: hasNext ? String(nextOffset) : void 0,
|
|
44387
|
-
...Object.keys(evidence).length ? { evidence } : {}
|
|
44388
|
-
};
|
|
44389
|
-
};
|
|
44675
|
+
return result;
|
|
44676
|
+
}
|
|
44390
44677
|
|
|
44391
44678
|
// src/commands/runs/index.ts
|
|
44392
44679
|
var parseLimit = (value) => {
|
|
@@ -44508,6 +44795,39 @@ var runsContent = {
|
|
|
44508
44795
|
return { content };
|
|
44509
44796
|
}
|
|
44510
44797
|
};
|
|
44798
|
+
var runsExport = {
|
|
44799
|
+
name: "runs.export",
|
|
44800
|
+
description: "\u5BFC\u51FA\u6307\u5B9A\u8F6E\u6B21\u7684\u539F\u59CB\u8C03\u8BD5\u65E5\u5FD7",
|
|
44801
|
+
options: [
|
|
44802
|
+
{
|
|
44803
|
+
flags: "--thread-id <threadId>",
|
|
44804
|
+
description: "\u76EE\u6807\u4F1A\u8BDD",
|
|
44805
|
+
key: "threadId"
|
|
44806
|
+
},
|
|
44807
|
+
{ flags: "--run-id <runId>", description: "\u76EE\u6807\u8F6E\u6B21", key: "runId" },
|
|
44808
|
+
{
|
|
44809
|
+
flags: "--advance-id <advanceId>",
|
|
44810
|
+
description: "\u56FA\u5B9A\u6267\u884C\u8EAB\u4EFD",
|
|
44811
|
+
key: "advanceId"
|
|
44812
|
+
}
|
|
44813
|
+
],
|
|
44814
|
+
summarize: ({ compressedBytes }) => `\u5DF2\u5BFC\u51FA\u672C\u8F6E\u65E5\u5FD7\uFF08${compressedBytes}\u5B57\u8282\uFF09\u3002
|
|
44815
|
+
`,
|
|
44816
|
+
run: (cwd, options) => {
|
|
44817
|
+
const { threadId, runId, advanceId } = options;
|
|
44818
|
+
if (![threadId, runId, advanceId].every(
|
|
44819
|
+
(value) => typeof value === "string" && value.trim()
|
|
44820
|
+
))
|
|
44821
|
+
throw new InvalidArgumentError(
|
|
44822
|
+
"--thread-id\u3001--run-id\u3001--advance-id \u5FC5\u987B\u6307\u5B9A"
|
|
44823
|
+
);
|
|
44824
|
+
return exportTurn(cwd, {
|
|
44825
|
+
threadId,
|
|
44826
|
+
runId,
|
|
44827
|
+
advanceId
|
|
44828
|
+
});
|
|
44829
|
+
}
|
|
44830
|
+
};
|
|
44511
44831
|
|
|
44512
44832
|
// src/commands/registry.ts
|
|
44513
44833
|
var parsePort = (value) => {
|
|
@@ -45179,6 +45499,7 @@ var COMMANDS = [
|
|
|
45179
45499
|
runsList,
|
|
45180
45500
|
runsShow,
|
|
45181
45501
|
runsContent,
|
|
45502
|
+
runsExport,
|
|
45182
45503
|
version2
|
|
45183
45504
|
];
|
|
45184
45505
|
|