linkque-cli-v2 1.3.8-beta.1 → 1.3.8
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 +337 -1086
- package/package.json +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-BU3S4JYG.js → chunk-AACYYAZ6.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-EFUO43CY.js → chunk-RHMVQTA7.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-7MJID6LL.js → chunk-ZNU4GVF3.js} +19 -103
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js +4 -40
- 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 +45 -153
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 path23 = 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 = path23.resolve(baseDir, baseName);
|
|
2213
2213
|
if (fs2.existsSync(localBin)) return localBin;
|
|
2214
|
-
if (sourceExt.includes(
|
|
2214
|
+
if (sourceExt.includes(path23.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 = path23.resolve(
|
|
2233
|
+
path23.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 = path23.basename(
|
|
2241
2241
|
this._scriptPath,
|
|
2242
|
-
|
|
2242
|
+
path23.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(path23.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 = path23.basename(filename, path23.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(path24) {
|
|
3183
|
+
if (path24 === void 0) return this._executableDir;
|
|
3184
|
+
this._executableDir = path24;
|
|
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(path23) {
|
|
6692
|
+
let input = path23;
|
|
6693
6693
|
const output = [];
|
|
6694
6694
|
let nextSlash = -1;
|
|
6695
6695
|
let len = 0;
|
|
@@ -7098,8 +7098,8 @@ var require_schemes = __commonJS({
|
|
|
7098
7098
|
}
|
|
7099
7099
|
if (wsComponent.resourceName) {
|
|
7100
7100
|
const queryIndex = wsComponent.resourceName.indexOf("?");
|
|
7101
|
-
const
|
|
7102
|
-
wsComponent.path =
|
|
7101
|
+
const path23 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
|
|
7102
|
+
wsComponent.path = path23 && path23 !== "/" ? path23 : void 0;
|
|
7103
7103
|
wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
|
|
7104
7104
|
wsComponent.resourceName = void 0;
|
|
7105
7105
|
}
|
|
@@ -20147,10 +20147,10 @@ function canonicalizeBindingPath(rawPath, listRoot) {
|
|
|
20147
20147
|
}
|
|
20148
20148
|
return isSafeJsonPointer(candidate, true) ? candidate : void 0;
|
|
20149
20149
|
}
|
|
20150
|
-
function issue2(
|
|
20151
|
-
return { path:
|
|
20150
|
+
function issue2(path23, code, message) {
|
|
20151
|
+
return { path: path23, code, message };
|
|
20152
20152
|
}
|
|
20153
|
-
function exactKeys(value, allowed,
|
|
20153
|
+
function exactKeys(value, allowed, path23, issues) {
|
|
20154
20154
|
}
|
|
20155
20155
|
|
|
20156
20156
|
// ../agent-a2ui-card-contract/dist/esm/binding-analyzer.js
|
|
@@ -20378,9 +20378,9 @@ var SCHEMA_TYPES = /* @__PURE__ */ new Set([
|
|
|
20378
20378
|
"object",
|
|
20379
20379
|
"string"
|
|
20380
20380
|
]);
|
|
20381
|
-
function getJsonSchemaIssues(value,
|
|
20381
|
+
function getJsonSchemaIssues(value, path23 = "schema", options = {}) {
|
|
20382
20382
|
const issues = [];
|
|
20383
|
-
validateSchemaNode(value,
|
|
20383
|
+
validateSchemaNode(value, path23, issues, options);
|
|
20384
20384
|
return issues;
|
|
20385
20385
|
}
|
|
20386
20386
|
var OPAQUE_OBJECT_SCHEMA = {
|
|
@@ -20402,9 +20402,9 @@ function normalizeTargetJsonSchema(schema) {
|
|
|
20402
20402
|
normalizeObjectDefaults(cloned);
|
|
20403
20403
|
return cloned;
|
|
20404
20404
|
}
|
|
20405
|
-
function validateJsonSchemaValue2(schema, value,
|
|
20405
|
+
function validateJsonSchemaValue2(schema, value, path23 = "$") {
|
|
20406
20406
|
const issues = [];
|
|
20407
|
-
validateValue(schema, value,
|
|
20407
|
+
validateValue(schema, value, path23, issues);
|
|
20408
20408
|
return issues;
|
|
20409
20409
|
}
|
|
20410
20410
|
function generateJsonSchemaSample(schema) {
|
|
@@ -20481,9 +20481,9 @@ function getJsonSchemaAtDataPointer(schema, pointer) {
|
|
|
20481
20481
|
return schema;
|
|
20482
20482
|
return getJsonSchemaAtPath(schema, pointer.slice(1).split("/").map(decodePointerSegment));
|
|
20483
20483
|
}
|
|
20484
|
-
function getJsonSchemaAtPath(schema,
|
|
20484
|
+
function getJsonSchemaAtPath(schema, path23) {
|
|
20485
20485
|
let current = schema;
|
|
20486
|
-
for (const segment of
|
|
20486
|
+
for (const segment of path23) {
|
|
20487
20487
|
if (!current)
|
|
20488
20488
|
return void 0;
|
|
20489
20489
|
if (segment === "*" || current.type === "array") {
|
|
@@ -20501,56 +20501,56 @@ function getJsonSchemaAtPath(schema, path26) {
|
|
|
20501
20501
|
}
|
|
20502
20502
|
return current;
|
|
20503
20503
|
}
|
|
20504
|
-
function getJsonSchemaCompatibilityIssues(source, target,
|
|
20504
|
+
function getJsonSchemaCompatibilityIssues(source, target, path23 = "$") {
|
|
20505
20505
|
const issues = [];
|
|
20506
|
-
compareSchemas(source, target,
|
|
20506
|
+
compareSchemas(source, target, path23, issues);
|
|
20507
20507
|
return issues;
|
|
20508
20508
|
}
|
|
20509
20509
|
function areJsonSchemaTypesCompatible(sourceType, targetType) {
|
|
20510
20510
|
return sourceType === targetType || sourceType === "integer" && targetType === "number";
|
|
20511
20511
|
}
|
|
20512
|
-
function validateSchemaNode(value,
|
|
20512
|
+
function validateSchemaNode(value, path23, issues, options) {
|
|
20513
20513
|
if (!isPlainRecord(value) || !isJsonValue(value)) {
|
|
20514
|
-
issues.push(issue2(
|
|
20514
|
+
issues.push(issue2(path23, "INVALID_JSON_SCHEMA", `${path23} must be a JSON object`));
|
|
20515
20515
|
return false;
|
|
20516
20516
|
}
|
|
20517
20517
|
if (value.type === void 0 && options.allowMissingType) {
|
|
20518
20518
|
return true;
|
|
20519
20519
|
}
|
|
20520
20520
|
if (typeof value.type !== "string" || !SCHEMA_TYPES.has(value.type)) {
|
|
20521
|
-
issues.push(issue2(`${
|
|
20521
|
+
issues.push(issue2(`${path23}.type`, "INVALID_JSON_SCHEMA_TYPE", `${path23}.type must be a supported scalar, object or array type`));
|
|
20522
20522
|
return false;
|
|
20523
20523
|
}
|
|
20524
20524
|
if (value.required !== void 0 && (!Array.isArray(value.required) || value.required.some((entry) => typeof entry !== "string"))) {
|
|
20525
|
-
issues.push(issue2(`${
|
|
20525
|
+
issues.push(issue2(`${path23}.required`, "INVALID_JSON_SCHEMA_REQUIRED", `${path23}.required must be a string array`));
|
|
20526
20526
|
}
|
|
20527
20527
|
if (value.type === "object") {
|
|
20528
20528
|
if (!isPlainRecord(value.properties)) {
|
|
20529
20529
|
if (options.requireCompleteStructures) {
|
|
20530
|
-
issues.push(issue2(`${
|
|
20530
|
+
issues.push(issue2(`${path23}.properties`, "INCOMPLETE_OBJECT_SCHEMA", "object schemas must declare properties"));
|
|
20531
20531
|
}
|
|
20532
20532
|
} else {
|
|
20533
20533
|
for (const [name, child] of Object.entries(value.properties)) {
|
|
20534
|
-
validateSchemaNode(child, `${
|
|
20534
|
+
validateSchemaNode(child, `${path23}.properties.${name}`, issues, options);
|
|
20535
20535
|
}
|
|
20536
20536
|
const required2 = Array.isArray(value.required) ? value.required.filter((entry) => typeof entry === "string") : [];
|
|
20537
20537
|
for (const name of required2) {
|
|
20538
20538
|
if (!(name in value.properties)) {
|
|
20539
|
-
issues.push(issue2(`${
|
|
20539
|
+
issues.push(issue2(`${path23}.required`, "UNKNOWN_REQUIRED_PROPERTY", `required property ${name} is not declared`));
|
|
20540
20540
|
}
|
|
20541
20541
|
}
|
|
20542
20542
|
}
|
|
20543
20543
|
if (value.additionalProperties !== void 0 && typeof value.additionalProperties !== "boolean" && !isPlainRecord(value.additionalProperties)) {
|
|
20544
|
-
issues.push(issue2(`${
|
|
20544
|
+
issues.push(issue2(`${path23}.additionalProperties`, "INVALID_ADDITIONAL_PROPERTIES", "additionalProperties must be a boolean or schema"));
|
|
20545
20545
|
}
|
|
20546
20546
|
}
|
|
20547
20547
|
if (value.type === "array") {
|
|
20548
20548
|
if (!isPlainRecord(value.items)) {
|
|
20549
20549
|
if (options.requireCompleteStructures) {
|
|
20550
|
-
issues.push(issue2(`${
|
|
20550
|
+
issues.push(issue2(`${path23}.items`, "INCOMPLETE_ARRAY_SCHEMA", "array schemas must declare items"));
|
|
20551
20551
|
}
|
|
20552
20552
|
} else {
|
|
20553
|
-
validateSchemaNode(value.items, `${
|
|
20553
|
+
validateSchemaNode(value.items, `${path23}.items`, issues, options);
|
|
20554
20554
|
}
|
|
20555
20555
|
}
|
|
20556
20556
|
return true;
|
|
@@ -20570,53 +20570,53 @@ function normalizeObjectDefaults(schema) {
|
|
|
20570
20570
|
normalizeObjectDefaults(schema.items);
|
|
20571
20571
|
}
|
|
20572
20572
|
}
|
|
20573
|
-
function validateValue(schema, value,
|
|
20573
|
+
function validateValue(schema, value, path23, issues) {
|
|
20574
20574
|
if (typeof schema.type === "string" && !matchesType(schema.type, value)) {
|
|
20575
|
-
issues.push(issue2(
|
|
20575
|
+
issues.push(issue2(path23, "SCHEMA_TYPE_MISMATCH", `expected ${schema.type}, received ${valueType(value)}`));
|
|
20576
20576
|
return;
|
|
20577
20577
|
}
|
|
20578
20578
|
if (Array.isArray(schema.enum) && !schema.enum.some((entry) => Object.is(entry, value))) {
|
|
20579
|
-
issues.push(issue2(
|
|
20579
|
+
issues.push(issue2(path23, "SCHEMA_ENUM_MISMATCH", "value is not in the declared enum"));
|
|
20580
20580
|
return;
|
|
20581
20581
|
}
|
|
20582
20582
|
if (schema.const !== void 0 && !Object.is(schema.const, value)) {
|
|
20583
|
-
issues.push(issue2(
|
|
20583
|
+
issues.push(issue2(path23, "SCHEMA_CONST_MISMATCH", "value does not match const"));
|
|
20584
20584
|
return;
|
|
20585
20585
|
}
|
|
20586
20586
|
if (schema.type === "object" && isPlainRecord(value)) {
|
|
20587
20587
|
const required2 = Array.isArray(schema.required) ? schema.required.filter((entry) => typeof entry === "string") : [];
|
|
20588
20588
|
for (const key of required2) {
|
|
20589
20589
|
if (!(key in value)) {
|
|
20590
|
-
issues.push(issue2(`${
|
|
20590
|
+
issues.push(issue2(`${path23}/${key}`, "SCHEMA_REQUIRED_MISSING", `required property ${key} is missing`));
|
|
20591
20591
|
}
|
|
20592
20592
|
}
|
|
20593
20593
|
const properties = isPlainRecord(schema.properties) ? schema.properties : {};
|
|
20594
20594
|
for (const [key, childSchema] of Object.entries(properties)) {
|
|
20595
20595
|
if (!(key in value) || !isPlainRecord(childSchema))
|
|
20596
20596
|
continue;
|
|
20597
|
-
validateValue(childSchema, value[key], `${
|
|
20597
|
+
validateValue(childSchema, value[key], `${path23}/${key}`, issues);
|
|
20598
20598
|
}
|
|
20599
20599
|
if (schema.additionalProperties === false) {
|
|
20600
20600
|
for (const key of Object.keys(value)) {
|
|
20601
20601
|
if (!(key in properties)) {
|
|
20602
|
-
issues.push(issue2(`${
|
|
20602
|
+
issues.push(issue2(`${path23}/${key}`, "SCHEMA_ADDITIONAL_PROPERTY", `property ${key} is not allowed`));
|
|
20603
20603
|
}
|
|
20604
20604
|
}
|
|
20605
20605
|
}
|
|
20606
20606
|
}
|
|
20607
20607
|
if (schema.type === "array" && Array.isArray(value) && isPlainRecord(schema.items)) {
|
|
20608
20608
|
value.forEach((entry, index) => {
|
|
20609
|
-
validateValue(schema.items, entry, `${
|
|
20609
|
+
validateValue(schema.items, entry, `${path23}/${index}`, issues);
|
|
20610
20610
|
});
|
|
20611
20611
|
}
|
|
20612
20612
|
}
|
|
20613
|
-
function compareSchemas(source, target,
|
|
20613
|
+
function compareSchemas(source, target, path23, issues) {
|
|
20614
20614
|
if (!areJsonSchemaTypesCompatible(source.type, target.type)) {
|
|
20615
|
-
issues.push(issue2(
|
|
20615
|
+
issues.push(issue2(path23, "SCHEMA_TYPE_INCOMPATIBLE", `source type ${String(source.type)} cannot supply ${String(target.type)}`));
|
|
20616
20616
|
return;
|
|
20617
20617
|
}
|
|
20618
20618
|
if (source.type === "array" && target.type === "array" && isPlainRecord(source.items) && isPlainRecord(target.items)) {
|
|
20619
|
-
compareSchemas(source.items, target.items, `${
|
|
20619
|
+
compareSchemas(source.items, target.items, `${path23}[*]`, issues);
|
|
20620
20620
|
}
|
|
20621
20621
|
if (source.type === "object" && target.type === "object" && isPlainRecord(source.properties) && isPlainRecord(target.properties)) {
|
|
20622
20622
|
const required2 = Array.isArray(target.required) ? target.required.filter((entry) => typeof entry === "string") : [];
|
|
@@ -20624,10 +20624,10 @@ function compareSchemas(source, target, path26, issues) {
|
|
|
20624
20624
|
const sourceChild = source.properties[name];
|
|
20625
20625
|
const targetChild = target.properties[name];
|
|
20626
20626
|
if (!isPlainRecord(sourceChild) || !isPlainRecord(targetChild)) {
|
|
20627
|
-
issues.push(issue2(`${
|
|
20627
|
+
issues.push(issue2(`${path23}.${name}`, "SCHEMA_REQUIRED_MISSING", `source does not provide required property ${name}`));
|
|
20628
20628
|
continue;
|
|
20629
20629
|
}
|
|
20630
|
-
compareSchemas(sourceChild, targetChild, `${
|
|
20630
|
+
compareSchemas(sourceChild, targetChild, `${path23}.${name}`, issues);
|
|
20631
20631
|
}
|
|
20632
20632
|
}
|
|
20633
20633
|
}
|
|
@@ -20716,37 +20716,37 @@ var A2UICardExpressionError = class extends Error {
|
|
|
20716
20716
|
this.fieldId = fieldId;
|
|
20717
20717
|
}
|
|
20718
20718
|
};
|
|
20719
|
-
function getA2UICardTransformIssues(value,
|
|
20719
|
+
function getA2UICardTransformIssues(value, path23 = "transform") {
|
|
20720
20720
|
if (!isPlainRecord(value)) {
|
|
20721
20721
|
return [
|
|
20722
|
-
issue2(
|
|
20722
|
+
issue2(path23, "CARD_EXPRESSION_INVALID", "transform must be an object")
|
|
20723
20723
|
];
|
|
20724
20724
|
}
|
|
20725
20725
|
const issues = [];
|
|
20726
20726
|
const allowedKeys = /* @__PURE__ */ new Set(["language", "profile", "expression"]);
|
|
20727
20727
|
for (const key of Object.keys(value)) {
|
|
20728
20728
|
if (!allowedKeys.has(key)) {
|
|
20729
|
-
issues.push(issue2(`${
|
|
20729
|
+
issues.push(issue2(`${path23}.${key}`, "CARD_EXPRESSION_INVALID", `${key} is not supported by transform`));
|
|
20730
20730
|
}
|
|
20731
20731
|
}
|
|
20732
20732
|
if (value.language !== A2UI_CARD_TRANSFORM_LANGUAGE) {
|
|
20733
|
-
issues.push(issue2(`${
|
|
20733
|
+
issues.push(issue2(`${path23}.language`, "CARD_EXPRESSION_INVALID", `language must be ${A2UI_CARD_TRANSFORM_LANGUAGE}`));
|
|
20734
20734
|
}
|
|
20735
20735
|
if (value.profile !== A2UI_CARD_TRANSFORM_PROFILE) {
|
|
20736
|
-
issues.push(issue2(`${
|
|
20736
|
+
issues.push(issue2(`${path23}.profile`, "CARD_EXPRESSION_INVALID", `profile must be ${A2UI_CARD_TRANSFORM_PROFILE}`));
|
|
20737
20737
|
}
|
|
20738
20738
|
if (typeof value.expression !== "string" || value.expression.trim().length === 0) {
|
|
20739
|
-
issues.push(issue2(`${
|
|
20739
|
+
issues.push(issue2(`${path23}.expression`, "CARD_EXPRESSION_INVALID", "expression must be a non-empty string"));
|
|
20740
20740
|
return issues;
|
|
20741
20741
|
}
|
|
20742
20742
|
if (value.expression.length > A2UI_CARD_EXPRESSION_MAX_LENGTH) {
|
|
20743
|
-
issues.push(issue2(`${
|
|
20743
|
+
issues.push(issue2(`${path23}.expression`, "CARD_EXPRESSION_LIMIT_EXCEEDED", `expression exceeds ${A2UI_CARD_EXPRESSION_MAX_LENGTH} characters`));
|
|
20744
20744
|
return issues;
|
|
20745
20745
|
}
|
|
20746
20746
|
try {
|
|
20747
20747
|
validateAst((0, import_jmespath2.compile)(value.expression));
|
|
20748
20748
|
} catch (error2) {
|
|
20749
|
-
issues.push(issue2(`${
|
|
20749
|
+
issues.push(issue2(`${path23}.expression`, error2 instanceof A2UICardExpressionError ? error2.code : "CARD_EXPRESSION_INVALID", error2 instanceof Error ? error2.message : "expression is invalid"));
|
|
20750
20750
|
}
|
|
20751
20751
|
return issues;
|
|
20752
20752
|
}
|
|
@@ -20858,11 +20858,11 @@ function parseA2UICardBindingContext(value) {
|
|
|
20858
20858
|
issues: []
|
|
20859
20859
|
};
|
|
20860
20860
|
}
|
|
20861
|
-
function getA2UICardBindingContextIssues(value,
|
|
20861
|
+
function getA2UICardBindingContextIssues(value, path23 = "bindingContext") {
|
|
20862
20862
|
const issues = [];
|
|
20863
20863
|
if (!isPlainRecord(value)) {
|
|
20864
20864
|
return [
|
|
20865
|
-
issue2(
|
|
20865
|
+
issue2(path23, "CARD_BINDING_CONTEXT_INVALID", "binding context must be an object")
|
|
20866
20866
|
];
|
|
20867
20867
|
}
|
|
20868
20868
|
exactKeys(value, [
|
|
@@ -20874,36 +20874,36 @@ function getA2UICardBindingContextIssues(value, path26 = "bindingContext") {
|
|
|
20874
20874
|
"generatedAt",
|
|
20875
20875
|
"candidates",
|
|
20876
20876
|
"preferredTools"
|
|
20877
|
-
],
|
|
20877
|
+
], path23, issues);
|
|
20878
20878
|
if (value.schemaVersion !== "1") {
|
|
20879
|
-
issues.push(issue2(`${
|
|
20879
|
+
issues.push(issue2(`${path23}.schemaVersion`, "CARD_BINDING_CONTEXT_INVALID", "schemaVersion must be 1"));
|
|
20880
20880
|
}
|
|
20881
20881
|
for (const key of ["draftId", "resourceId"]) {
|
|
20882
20882
|
if (!isSafeIdentifier(value[key])) {
|
|
20883
|
-
issues.push(issue2(`${
|
|
20883
|
+
issues.push(issue2(`${path23}.${key}`, "CARD_BINDING_CONTEXT_INVALID", `${key} is invalid`));
|
|
20884
20884
|
}
|
|
20885
20885
|
}
|
|
20886
20886
|
for (const key of ["draftStructureChecksum", "mcpConfigChecksum"]) {
|
|
20887
20887
|
if (typeof value[key] !== "string" || !/^[0-9a-f]{64}$/u.test(value[key])) {
|
|
20888
|
-
issues.push(issue2(`${
|
|
20888
|
+
issues.push(issue2(`${path23}.${key}`, "CARD_BINDING_CONTEXT_INVALID", `${key} must be a sha256 checksum`));
|
|
20889
20889
|
}
|
|
20890
20890
|
}
|
|
20891
20891
|
if (typeof value.generatedAt !== "string" || !Number.isFinite(Date.parse(value.generatedAt))) {
|
|
20892
|
-
issues.push(issue2(`${
|
|
20892
|
+
issues.push(issue2(`${path23}.generatedAt`, "CARD_BINDING_CONTEXT_INVALID", "generatedAt must be an ISO timestamp"));
|
|
20893
20893
|
}
|
|
20894
|
-
validateCandidates(value.candidates, `${
|
|
20895
|
-
validatePreferences(value.preferredTools, `${
|
|
20894
|
+
validateCandidates(value.candidates, `${path23}.candidates`, issues);
|
|
20895
|
+
validatePreferences(value.preferredTools, `${path23}.preferredTools`, issues);
|
|
20896
20896
|
return issues;
|
|
20897
20897
|
}
|
|
20898
|
-
function getA2UICardBindingSelectionIssues(value,
|
|
20898
|
+
function getA2UICardBindingSelectionIssues(value, path23 = "bindings", fields) {
|
|
20899
20899
|
const issues = [];
|
|
20900
20900
|
if (!Array.isArray(value)) {
|
|
20901
|
-
return [issue2(
|
|
20901
|
+
return [issue2(path23, "CARD_BINDING_INVALID", "bindings must be an array")];
|
|
20902
20902
|
}
|
|
20903
20903
|
const fieldById = new Map(fields?.map((field) => [field.fieldId, field]) ?? []);
|
|
20904
20904
|
const seen = /* @__PURE__ */ new Set();
|
|
20905
20905
|
value.forEach((candidate, index) => {
|
|
20906
|
-
const itemPath = `${
|
|
20906
|
+
const itemPath = `${path23}[${index}]`;
|
|
20907
20907
|
if (!isPlainRecord(candidate)) {
|
|
20908
20908
|
issues.push(issue2(itemPath, "CARD_BINDING_INVALID", "binding must be an object"));
|
|
20909
20909
|
return;
|
|
@@ -21016,14 +21016,14 @@ function validateA2UICardBindings(input, options = {}) {
|
|
|
21016
21016
|
validateConsistencyGroups(input.draft.manifest.fields, bindings, issues, selectedFields);
|
|
21017
21017
|
return issues;
|
|
21018
21018
|
}
|
|
21019
|
-
function validateCandidates(value,
|
|
21019
|
+
function validateCandidates(value, path23, issues) {
|
|
21020
21020
|
if (!Array.isArray(value) || value.length > 200) {
|
|
21021
|
-
issues.push(issue2(
|
|
21021
|
+
issues.push(issue2(path23, "CARD_BINDING_CONTEXT_INVALID", "candidates must be an array with at most 200 items"));
|
|
21022
21022
|
return;
|
|
21023
21023
|
}
|
|
21024
21024
|
const candidateKeys = /* @__PURE__ */ new Set();
|
|
21025
21025
|
value.forEach((candidate, index) => {
|
|
21026
|
-
const itemPath = `${
|
|
21026
|
+
const itemPath = `${path23}[${index}]`;
|
|
21027
21027
|
if (!isPlainRecord(candidate)) {
|
|
21028
21028
|
issues.push(issue2(itemPath, "CARD_BINDING_CONTEXT_INVALID", "candidate must be an object"));
|
|
21029
21029
|
return;
|
|
@@ -21064,9 +21064,9 @@ function validateCandidates(value, path26, issues) {
|
|
|
21064
21064
|
}
|
|
21065
21065
|
});
|
|
21066
21066
|
}
|
|
21067
|
-
function validateTool(value,
|
|
21067
|
+
function validateTool(value, path23, resourceId, issues) {
|
|
21068
21068
|
if (!isPlainRecord(value)) {
|
|
21069
|
-
issues.push(issue2(
|
|
21069
|
+
issues.push(issue2(path23, "CARD_BINDING_CONTEXT_INVALID", "tool must be an object"));
|
|
21070
21070
|
return;
|
|
21071
21071
|
}
|
|
21072
21072
|
exactKeys(value, [
|
|
@@ -21077,16 +21077,16 @@ function validateTool(value, path26, resourceId, issues) {
|
|
|
21077
21077
|
"outputSchema",
|
|
21078
21078
|
"outputSchemaMode",
|
|
21079
21079
|
"annotations"
|
|
21080
|
-
],
|
|
21080
|
+
], path23, issues);
|
|
21081
21081
|
if (value.resourceId !== resourceId) {
|
|
21082
|
-
issues.push(issue2(`${
|
|
21082
|
+
issues.push(issue2(`${path23}.resourceId`, "CARD_BINDING_CONTEXT_INVALID", "tool resourceId must match candidate"));
|
|
21083
21083
|
}
|
|
21084
21084
|
if (typeof value.toolName !== "string" || !value.toolName.trim()) {
|
|
21085
|
-
issues.push(issue2(`${
|
|
21085
|
+
issues.push(issue2(`${path23}.toolName`, "CARD_BINDING_CONTEXT_INVALID", "toolName is required"));
|
|
21086
21086
|
}
|
|
21087
|
-
issues.push(...getJsonSchemaIssues(value.inputSchema, `${
|
|
21087
|
+
issues.push(...getJsonSchemaIssues(value.inputSchema, `${path23}.inputSchema`));
|
|
21088
21088
|
if (value.outputSchemaMode !== void 0 && value.outputSchemaMode !== "declared" && value.outputSchemaMode !== "opaque") {
|
|
21089
|
-
issues.push(issue2(`${
|
|
21089
|
+
issues.push(issue2(`${path23}.outputSchemaMode`, "CARD_BINDING_CONTEXT_INVALID", "outputSchemaMode must be declared or opaque"));
|
|
21090
21090
|
}
|
|
21091
21091
|
}
|
|
21092
21092
|
function normalizeBindingContext(context) {
|
|
@@ -21107,16 +21107,16 @@ function normalizeBindingContext(context) {
|
|
|
21107
21107
|
});
|
|
21108
21108
|
return cloned;
|
|
21109
21109
|
}
|
|
21110
|
-
function validatePreferences(value,
|
|
21110
|
+
function validatePreferences(value, path23, issues) {
|
|
21111
21111
|
if (value === void 0)
|
|
21112
21112
|
return;
|
|
21113
21113
|
if (!Array.isArray(value) || value.length > 512) {
|
|
21114
|
-
issues.push(issue2(
|
|
21114
|
+
issues.push(issue2(path23, "CARD_BINDING_CONTEXT_INVALID", "preferredTools must be an array"));
|
|
21115
21115
|
return;
|
|
21116
21116
|
}
|
|
21117
21117
|
const fields = /* @__PURE__ */ new Set();
|
|
21118
21118
|
value.forEach((preference, index) => {
|
|
21119
|
-
const itemPath = `${
|
|
21119
|
+
const itemPath = `${path23}[${index}]`;
|
|
21120
21120
|
if (!isPlainRecord(preference)) {
|
|
21121
21121
|
issues.push(issue2(itemPath, "CARD_BINDING_CONTEXT_INVALID", "preference must be an object"));
|
|
21122
21122
|
return;
|
|
@@ -21136,14 +21136,14 @@ function validatePreferences(value, path26, issues) {
|
|
|
21136
21136
|
fields.add(preference.fieldId);
|
|
21137
21137
|
});
|
|
21138
21138
|
}
|
|
21139
|
-
function validateInputBindings(value,
|
|
21139
|
+
function validateInputBindings(value, path23, issues) {
|
|
21140
21140
|
if (!Array.isArray(value) || value.length > 64) {
|
|
21141
|
-
issues.push(issue2(
|
|
21141
|
+
issues.push(issue2(path23, "CARD_BINDING_INVALID", "inputBindings must be an array with at most 64 items"));
|
|
21142
21142
|
return;
|
|
21143
21143
|
}
|
|
21144
21144
|
const inputs = /* @__PURE__ */ new Set();
|
|
21145
21145
|
value.forEach((binding, index) => {
|
|
21146
|
-
const itemPath = `${
|
|
21146
|
+
const itemPath = `${path23}[${index}]`;
|
|
21147
21147
|
if (!isPlainRecord(binding)) {
|
|
21148
21148
|
issues.push(issue2(itemPath, "CARD_BINDING_INVALID", "input binding must be an object"));
|
|
21149
21149
|
return;
|
|
@@ -21174,18 +21174,18 @@ function validateInputBindings(value, path26, issues) {
|
|
|
21174
21174
|
}
|
|
21175
21175
|
});
|
|
21176
21176
|
}
|
|
21177
|
-
function validateRequiredToolInputs(toolSchema, presentationSchema, bindings,
|
|
21177
|
+
function validateRequiredToolInputs(toolSchema, presentationSchema, bindings, path23, issues) {
|
|
21178
21178
|
const byInput = new Map(bindings.map((binding) => [binding.inputPath, binding]));
|
|
21179
21179
|
for (const input of requiredLeafInputs(toolSchema)) {
|
|
21180
21180
|
const binding = byInput.get(input.path);
|
|
21181
21181
|
if (!binding) {
|
|
21182
|
-
issues.push(issue2(
|
|
21182
|
+
issues.push(issue2(path23, "CARD_BINDING_INCOMPLETE", `required Tool input ${input.path} is not bound`));
|
|
21183
21183
|
continue;
|
|
21184
21184
|
}
|
|
21185
21185
|
if (binding.source.kind === "invocation") {
|
|
21186
21186
|
const source = getJsonSchemaAtDataPointer(presentationSchema, binding.source.path);
|
|
21187
21187
|
if (!source || !areJsonSchemaTypesCompatible(source.type, input.schema.type)) {
|
|
21188
|
-
issues.push(issue2(
|
|
21188
|
+
issues.push(issue2(path23, "CARD_BINDING_INVALID", `invocation source ${binding.source.path} is incompatible with ${input.path}`));
|
|
21189
21189
|
}
|
|
21190
21190
|
}
|
|
21191
21191
|
}
|
|
@@ -21197,11 +21197,11 @@ function requiredLeafInputs(schema, basePath = "", parentRequired = true) {
|
|
|
21197
21197
|
return Object.entries(schema.properties).flatMap(([name, child]) => {
|
|
21198
21198
|
if (!isPlainRecord(child))
|
|
21199
21199
|
return [];
|
|
21200
|
-
const
|
|
21200
|
+
const path23 = `${basePath}/${name.replace(/~/gu, "~0").replace(/\//gu, "~1")}`;
|
|
21201
21201
|
const isRequired = parentRequired && required2.has(name);
|
|
21202
21202
|
if (child.type === "object")
|
|
21203
|
-
return requiredLeafInputs(child,
|
|
21204
|
-
return isRequired ? [{ path:
|
|
21203
|
+
return requiredLeafInputs(child, path23, isRequired);
|
|
21204
|
+
return isRequired ? [{ path: path23, schema: child }] : [];
|
|
21205
21205
|
});
|
|
21206
21206
|
}
|
|
21207
21207
|
function validateConsistencyGroups(fields, bindings, issues, selectedFields) {
|
|
@@ -21545,16 +21545,16 @@ var A2UI_V4_COMPONENT_CATALOG = Object.freeze({
|
|
|
21545
21545
|
}
|
|
21546
21546
|
}
|
|
21547
21547
|
});
|
|
21548
|
-
function getA2UIV4ProtocolIssues(value,
|
|
21548
|
+
function getA2UIV4ProtocolIssues(value, path23 = "card") {
|
|
21549
21549
|
const issues = [];
|
|
21550
21550
|
if (!Array.isArray(value) || value.length === 0)
|
|
21551
21551
|
return [
|
|
21552
|
-
issue2(
|
|
21552
|
+
issue2(path23, "INVALID_A2UI_PROTOCOL", "card must be a non-empty array")
|
|
21553
21553
|
];
|
|
21554
21554
|
const surfaces = /* @__PURE__ */ new Map();
|
|
21555
21555
|
const createdSurfaces = /* @__PURE__ */ new Set();
|
|
21556
21556
|
for (const [messageIndex, message] of value.entries()) {
|
|
21557
|
-
const messagePath = `${
|
|
21557
|
+
const messagePath = `${path23}[${messageIndex}]`;
|
|
21558
21558
|
if (!isPlainRecord(message) || message.version !== "0.9" || !Array.isArray(message.datas)) {
|
|
21559
21559
|
issues.push(issue2(messagePath, "INVALID_A2UI_MESSAGE", "V4 messages require version 0.9 and a datas array"));
|
|
21560
21560
|
continue;
|
|
@@ -21608,9 +21608,9 @@ function getA2UIV4ProtocolIssues(value, path26 = "card") {
|
|
|
21608
21608
|
}
|
|
21609
21609
|
surfaces.forEach((_components, surfaceId) => {
|
|
21610
21610
|
if (!createdSurfaces.has(surfaceId))
|
|
21611
|
-
issues.push(issue2(`${
|
|
21611
|
+
issues.push(issue2(`${path23}.surfaces.${surfaceId}`, "MISSING_CREATE_SURFACE", "every V4 surface must declare createSurface with the V4 catalog"));
|
|
21612
21612
|
});
|
|
21613
|
-
validateReferences(surfaces,
|
|
21613
|
+
validateReferences(surfaces, path23, issues);
|
|
21614
21614
|
return issues;
|
|
21615
21615
|
}
|
|
21616
21616
|
function validateV4Component(component, componentPath, issues) {
|
|
@@ -21661,15 +21661,15 @@ function validateV4Component(component, componentPath, issues) {
|
|
|
21661
21661
|
if (component.action !== void 0)
|
|
21662
21662
|
validateAction(component.action, `${componentPath}.action`, issues, 0);
|
|
21663
21663
|
}
|
|
21664
|
-
function validateComponents(payload,
|
|
21664
|
+
function validateComponents(payload, path23, surfaces, issues) {
|
|
21665
21665
|
if (!Array.isArray(payload.components)) {
|
|
21666
|
-
issues.push(issue2(`${
|
|
21666
|
+
issues.push(issue2(`${path23}.updateComponents.components`, "INVALID_A2UI_COMPONENTS", "components must be an array"));
|
|
21667
21667
|
return;
|
|
21668
21668
|
}
|
|
21669
21669
|
const surface = surfaces.get(payload.surfaceId) ?? /* @__PURE__ */ new Map();
|
|
21670
21670
|
surfaces.set(payload.surfaceId, surface);
|
|
21671
21671
|
payload.components.forEach((component, index) => {
|
|
21672
|
-
const componentPath = `${
|
|
21672
|
+
const componentPath = `${path23}.updateComponents.components[${index}]`;
|
|
21673
21673
|
if (!isPlainRecord(component) || !isSafeIdentifier(component.id) || typeof component.component !== "string") {
|
|
21674
21674
|
issues.push(issue2(componentPath, "INVALID_A2UI_COMPONENT", "component requires a safe id and component name"));
|
|
21675
21675
|
return;
|
|
@@ -21680,23 +21680,23 @@ function validateComponents(payload, path26, surfaces, issues) {
|
|
|
21680
21680
|
validateV4Component(component, componentPath, issues);
|
|
21681
21681
|
});
|
|
21682
21682
|
}
|
|
21683
|
-
function validateProperty(value, schema,
|
|
21683
|
+
function validateProperty(value, schema, path23, issues, propertyName) {
|
|
21684
21684
|
if (schema.kind === "binding") {
|
|
21685
21685
|
const stringOnly = propertyName === "label" || propertyName === "src" || propertyName === "alt";
|
|
21686
21686
|
const literalValid = typeof value === "string" || !stringOnly && typeof value === "number" && Number.isFinite(value);
|
|
21687
21687
|
if (!literalValid && !isDisplayBinding(value, stringOnly))
|
|
21688
|
-
issues.push(issue2(
|
|
21688
|
+
issues.push(issue2(path23, "INVALID_DISPLAY_VALUE", `display value must be ${stringOnly ? "a string" : "a string or finite number"}, or a compatible display binding`));
|
|
21689
21689
|
return;
|
|
21690
21690
|
}
|
|
21691
21691
|
if (schema.kind === "child") {
|
|
21692
21692
|
if (!isSafeIdentifier(value))
|
|
21693
|
-
issues.push(issue2(
|
|
21693
|
+
issues.push(issue2(path23, "INVALID_CHILD", "child must be a safe component id"));
|
|
21694
21694
|
return;
|
|
21695
21695
|
}
|
|
21696
21696
|
if (schema.kind === "children") {
|
|
21697
21697
|
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);
|
|
21698
21698
|
if (!valid)
|
|
21699
|
-
issues.push(issue2(
|
|
21699
|
+
issues.push(issue2(path23, "INVALID_CHILDREN", "children must be component ids or one dynamic children binding"));
|
|
21700
21700
|
return;
|
|
21701
21701
|
}
|
|
21702
21702
|
if (schema.kind === "action")
|
|
@@ -21704,11 +21704,11 @@ function validateProperty(value, schema, path26, issues, propertyName) {
|
|
|
21704
21704
|
if (schema.kind === "options" || schema.kind === "format")
|
|
21705
21705
|
return;
|
|
21706
21706
|
if (schema.kind === "boolean" && typeof value !== "boolean")
|
|
21707
|
-
issues.push(issue2(
|
|
21707
|
+
issues.push(issue2(path23, "INVALID_COMPONENT_PROP_TYPE", "value must be boolean"));
|
|
21708
21708
|
if (schema.kind === "number" && (!Number.isFinite(value) || schema.values && !schema.values.includes(value)))
|
|
21709
|
-
issues.push(issue2(
|
|
21709
|
+
issues.push(issue2(path23, "INVALID_COMPONENT_PROP_VALUE", "value is not an allowed finite number"));
|
|
21710
21710
|
if (schema.kind === "string" && (typeof value !== "string" || schema.values && !schema.values.includes(value)))
|
|
21711
|
-
issues.push(issue2(
|
|
21711
|
+
issues.push(issue2(path23, "INVALID_COMPONENT_PROP_VALUE", "value is not an allowed string"));
|
|
21712
21712
|
}
|
|
21713
21713
|
function isDisplayBinding(value, stringOnly = false) {
|
|
21714
21714
|
if (!isPlainRecord(value) || typeof value.path !== "string" || !isSafePath(value.path))
|
|
@@ -21722,132 +21722,132 @@ function isStrictBinding(value) {
|
|
|
21722
21722
|
function isSafePath(value) {
|
|
21723
21723
|
return (value === "/" || value.startsWith("/") || value.startsWith("./")) && !value.split("/").some((part) => ["__proto__", "constructor", "prototype"].includes(part));
|
|
21724
21724
|
}
|
|
21725
|
-
function validateAction(value,
|
|
21725
|
+
function validateAction(value, path23, issues, depth) {
|
|
21726
21726
|
if (!isPlainRecord(value) || depth > 4) {
|
|
21727
|
-
issues.push(issue2(
|
|
21727
|
+
issues.push(issue2(path23, "INVALID_ACTION", "action must be an object with at most four nested selects"));
|
|
21728
21728
|
return;
|
|
21729
21729
|
}
|
|
21730
21730
|
const branches = ["event", "function", "local", "client", "select"].filter((key) => key in value);
|
|
21731
21731
|
if (branches.length !== 1 || Object.keys(value).length !== 1) {
|
|
21732
|
-
issues.push(issue2(
|
|
21732
|
+
issues.push(issue2(path23, "INVALID_ACTION", "action must contain exactly one branch"));
|
|
21733
21733
|
return;
|
|
21734
21734
|
}
|
|
21735
21735
|
const branch = branches[0];
|
|
21736
21736
|
const body = value[branch];
|
|
21737
21737
|
if (!isPlainRecord(body))
|
|
21738
|
-
return void issues.push(issue2(`${
|
|
21738
|
+
return void issues.push(issue2(`${path23}.${branch}`, "INVALID_ACTION", `${branch} must be an object`));
|
|
21739
21739
|
if (branch === "event") {
|
|
21740
|
-
rejectUnknownKeys(body, ["name", "context", "x2-user-message", "target"], `${
|
|
21740
|
+
rejectUnknownKeys(body, ["name", "context", "x2-user-message", "target"], `${path23}.event`, issues);
|
|
21741
21741
|
if (typeof body.name !== "string" || !/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/.test(body.name) || body.name.length > 96)
|
|
21742
|
-
issues.push(issue2(`${
|
|
21742
|
+
issues.push(issue2(`${path23}.event.name`, "INVALID_ACTION_NAME", "event name is invalid"));
|
|
21743
21743
|
if (body.context !== void 0 && !isPlainRecord(body.context))
|
|
21744
|
-
issues.push(issue2(`${
|
|
21744
|
+
issues.push(issue2(`${path23}.event.context`, "INVALID_ACTION_CONTEXT", "event context must be an object"));
|
|
21745
21745
|
else if (body.context !== void 0)
|
|
21746
|
-
validateActionDynamicValue(body.context, `${
|
|
21746
|
+
validateActionDynamicValue(body.context, `${path23}.event.context`, issues);
|
|
21747
21747
|
if (body["x2-user-message"] !== void 0 && typeof body["x2-user-message"] !== "string" && !isStrictBinding(body["x2-user-message"]))
|
|
21748
|
-
issues.push(issue2(`${
|
|
21748
|
+
issues.push(issue2(`${path23}.event.x2-user-message`, "INVALID_ACTION_CONTEXT", "x2-user-message must be a string or strict binding"));
|
|
21749
21749
|
if (body.target !== void 0)
|
|
21750
|
-
validateOverlayTarget(body.target, `${
|
|
21750
|
+
validateOverlayTarget(body.target, `${path23}.event.target`, issues);
|
|
21751
21751
|
} else if (branch === "function") {
|
|
21752
|
-
rejectUnknownKeys(body, ["ref"], `${
|
|
21752
|
+
rejectUnknownKeys(body, ["ref"], `${path23}.function`, issues);
|
|
21753
21753
|
if (!isFunctionActionRef(body.ref))
|
|
21754
|
-
issues.push(issue2(`${
|
|
21754
|
+
issues.push(issue2(`${path23}.function.ref`, "INVALID_FUNCTION_ACTION_REF", "function ref must be a dot-separated identifier up to 128 characters"));
|
|
21755
21755
|
} else if (branch === "local") {
|
|
21756
|
-
rejectUnknownKeys(body, ["name", "path", "value"], `${
|
|
21756
|
+
rejectUnknownKeys(body, ["name", "path", "value"], `${path23}.local`, issues);
|
|
21757
21757
|
if (body.name !== "data.set" || typeof body.path !== "string" || !isSafePath(body.path) || !Object.prototype.hasOwnProperty.call(body, "value"))
|
|
21758
|
-
issues.push(issue2(`${
|
|
21758
|
+
issues.push(issue2(`${path23}.local`, "INVALID_LOCAL_ACTION", "local action must be data.set with a safe path and value"));
|
|
21759
21759
|
else
|
|
21760
|
-
validateActionDynamicValue(body.value, `${
|
|
21760
|
+
validateActionDynamicValue(body.value, `${path23}.local.value`, issues);
|
|
21761
21761
|
} else if (branch === "client") {
|
|
21762
|
-
validateClientAction(body, `${
|
|
21762
|
+
validateClientAction(body, `${path23}.client`, issues);
|
|
21763
21763
|
} else {
|
|
21764
|
-
rejectUnknownKeys(body, ["value", "cases", "default"], `${
|
|
21764
|
+
rejectUnknownKeys(body, ["value", "cases", "default"], `${path23}.select`, issues);
|
|
21765
21765
|
if (!isStrictBinding(body.value) || !Array.isArray(body.cases) || body.cases.length < 1 || body.cases.length > 16)
|
|
21766
|
-
return void issues.push(issue2(`${
|
|
21766
|
+
return void issues.push(issue2(`${path23}.select`, "INVALID_SELECT_ACTION", "select requires a strict binding and 1-16 cases"));
|
|
21767
21767
|
const seen = /* @__PURE__ */ new Set();
|
|
21768
21768
|
body.cases.forEach((entry, index) => {
|
|
21769
21769
|
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"))
|
|
21770
|
-
return void issues.push(issue2(`${
|
|
21770
|
+
return void issues.push(issue2(`${path23}.select.cases[${index}]`, "INVALID_SELECT_CASE", "case requires only a primitive equals and action"));
|
|
21771
21771
|
const key = JSON.stringify([typeof entry.equals, entry.equals]);
|
|
21772
21772
|
if (seen.has(key))
|
|
21773
|
-
issues.push(issue2(`${
|
|
21773
|
+
issues.push(issue2(`${path23}.select.cases[${index}].equals`, "DUPLICATE_SELECT_CASE", "select case values must be unique"));
|
|
21774
21774
|
seen.add(key);
|
|
21775
|
-
validateAction(entry.action, `${
|
|
21775
|
+
validateAction(entry.action, `${path23}.select.cases[${index}].action`, issues, depth + 1);
|
|
21776
21776
|
});
|
|
21777
21777
|
if (body.default !== void 0)
|
|
21778
|
-
validateAction(body.default, `${
|
|
21778
|
+
validateAction(body.default, `${path23}.select.default`, issues, depth + 1);
|
|
21779
21779
|
}
|
|
21780
21780
|
}
|
|
21781
21781
|
function isFunctionActionRef(value) {
|
|
21782
21782
|
return typeof value === "string" && value.length <= 128 && /^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u.test(value);
|
|
21783
21783
|
}
|
|
21784
|
-
function validateClientAction(body,
|
|
21785
|
-
rejectUnknownKeys(body, ["name", "context"],
|
|
21784
|
+
function validateClientAction(body, path23, issues) {
|
|
21785
|
+
rejectUnknownKeys(body, ["name", "context"], path23, issues);
|
|
21786
21786
|
if (body.name === "ui.overlay.close") {
|
|
21787
21787
|
if (body.context !== void 0)
|
|
21788
|
-
issues.push(issue2(`${
|
|
21788
|
+
issues.push(issue2(`${path23}.context`, "INVALID_CLIENT_ACTION_CONTEXT", "ui.overlay.close does not accept context"));
|
|
21789
21789
|
return;
|
|
21790
21790
|
}
|
|
21791
21791
|
if (body.name === "ui.surface.open") {
|
|
21792
21792
|
if (!isPlainRecord(body.context) || Object.keys(body.context).length !== 1 || typeof body.context.surfaceId !== "string")
|
|
21793
|
-
issues.push(issue2(`${
|
|
21793
|
+
issues.push(issue2(`${path23}.context`, "INVALID_CLIENT_ACTION_CONTEXT", "ui.surface.open requires context.surfaceId"));
|
|
21794
21794
|
return;
|
|
21795
21795
|
}
|
|
21796
21796
|
if (body.name === "ui.page.open") {
|
|
21797
21797
|
if (!isPlainRecord(body.context) || Object.keys(body.context).length !== 1 || typeof body.context.url !== "string" && !isStrictBinding(body.context.url))
|
|
21798
|
-
issues.push(issue2(`${
|
|
21798
|
+
issues.push(issue2(`${path23}.context`, "INVALID_CLIENT_ACTION_CONTEXT", "ui.page.open requires one literal or bound URL"));
|
|
21799
21799
|
else if (typeof body.context.url === "string" && !isSafePageUrl(body.context.url))
|
|
21800
|
-
issues.push(issue2(`${
|
|
21800
|
+
issues.push(issue2(`${path23}.context.url`, "INVALID_PAGE_URL", "ui.page.open URL must use https or the approved Alipay scheme"));
|
|
21801
21801
|
return;
|
|
21802
21802
|
}
|
|
21803
21803
|
if (body.name === "payment.trade-pay") {
|
|
21804
|
-
validatePaymentActionContext(body.context, `${
|
|
21804
|
+
validatePaymentActionContext(body.context, `${path23}.context`, issues);
|
|
21805
21805
|
return;
|
|
21806
21806
|
}
|
|
21807
|
-
issues.push(issue2(`${
|
|
21807
|
+
issues.push(issue2(`${path23}.name`, "UNSUPPORTED_CLIENT_ACTION", `unsupported client action ${String(body.name)}`));
|
|
21808
21808
|
}
|
|
21809
|
-
function validatePaymentActionContext(value,
|
|
21809
|
+
function validatePaymentActionContext(value, path23, issues) {
|
|
21810
21810
|
if (!isPlainRecord(value)) {
|
|
21811
|
-
issues.push(issue2(
|
|
21811
|
+
issues.push(issue2(path23, "INVALID_CLIENT_ACTION_CONTEXT", "payment.trade-pay requires createTrade and onSuccess"));
|
|
21812
21812
|
return;
|
|
21813
21813
|
}
|
|
21814
|
-
rejectUnknownKeys(value, ["createTrade", "onSuccess"],
|
|
21814
|
+
rejectUnknownKeys(value, ["createTrade", "onSuccess"], path23, issues);
|
|
21815
21815
|
const createTrade = isPlainRecord(value.createTrade) ? value.createTrade : void 0;
|
|
21816
21816
|
if (!createTrade) {
|
|
21817
|
-
issues.push(issue2(`${
|
|
21817
|
+
issues.push(issue2(`${path23}.createTrade`, "INVALID_PAYMENT_CREATE_TRADE", "createTrade must be an object"));
|
|
21818
21818
|
} else {
|
|
21819
|
-
rejectUnknownKeys(createTrade, ["mcpResourceId", "toolName", "input", "tradeNoPath"], `${
|
|
21819
|
+
rejectUnknownKeys(createTrade, ["mcpResourceId", "toolName", "input", "tradeNoPath"], `${path23}.createTrade`, issues);
|
|
21820
21820
|
if (!isSafeIdentifier(createTrade.mcpResourceId))
|
|
21821
|
-
issues.push(issue2(`${
|
|
21821
|
+
issues.push(issue2(`${path23}.createTrade.mcpResourceId`, "INVALID_MCP_RESOURCE_ID", "mcpResourceId is invalid"));
|
|
21822
21822
|
if (typeof createTrade.toolName !== "string" || !createTrade.toolName.trim())
|
|
21823
|
-
issues.push(issue2(`${
|
|
21823
|
+
issues.push(issue2(`${path23}.createTrade.toolName`, "INVALID_TOOL_NAME", "toolName is required"));
|
|
21824
21824
|
if (!isPlainRecord(createTrade.input))
|
|
21825
|
-
issues.push(issue2(`${
|
|
21825
|
+
issues.push(issue2(`${path23}.createTrade.input`, "INVALID_PAYMENT_INPUT", "input must be an object"));
|
|
21826
21826
|
else
|
|
21827
|
-
validateActionDynamicValue(createTrade.input, `${
|
|
21827
|
+
validateActionDynamicValue(createTrade.input, `${path23}.createTrade.input`, issues);
|
|
21828
21828
|
if (!isSafeJsonPointer(createTrade.tradeNoPath))
|
|
21829
|
-
issues.push(issue2(`${
|
|
21829
|
+
issues.push(issue2(`${path23}.createTrade.tradeNoPath`, "INVALID_TRADE_NO_PATH", "tradeNoPath must be an absolute JSON Pointer"));
|
|
21830
21830
|
}
|
|
21831
21831
|
const onSuccess = isPlainRecord(value.onSuccess) ? value.onSuccess : void 0;
|
|
21832
21832
|
const event = onSuccess && isPlainRecord(onSuccess.event) ? onSuccess.event : void 0;
|
|
21833
21833
|
if (!onSuccess || !event) {
|
|
21834
|
-
issues.push(issue2(`${
|
|
21834
|
+
issues.push(issue2(`${path23}.onSuccess`, "INVALID_PAYMENT_SUCCESS_EVENT", "onSuccess.event is required"));
|
|
21835
21835
|
return;
|
|
21836
21836
|
}
|
|
21837
|
-
rejectUnknownKeys(onSuccess, ["event"], `${
|
|
21838
|
-
rejectUnknownKeys(event, ["name", "context", "x2-user-message"], `${
|
|
21837
|
+
rejectUnknownKeys(onSuccess, ["event"], `${path23}.onSuccess`, issues);
|
|
21838
|
+
rejectUnknownKeys(event, ["name", "context", "x2-user-message"], `${path23}.onSuccess.event`, issues);
|
|
21839
21839
|
if (typeof event.name !== "string" || !/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/.test(event.name) || event.name.length > 96)
|
|
21840
|
-
issues.push(issue2(`${
|
|
21840
|
+
issues.push(issue2(`${path23}.onSuccess.event.name`, "INVALID_ACTION_NAME", "event name is invalid"));
|
|
21841
21841
|
if (event.context !== void 0 && !isPlainRecord(event.context))
|
|
21842
|
-
issues.push(issue2(`${
|
|
21842
|
+
issues.push(issue2(`${path23}.onSuccess.event.context`, "INVALID_ACTION_CONTEXT", "event context must be an object"));
|
|
21843
21843
|
else if (event.context !== void 0)
|
|
21844
|
-
validateActionDynamicValue(event.context, `${
|
|
21844
|
+
validateActionDynamicValue(event.context, `${path23}.onSuccess.event.context`, issues);
|
|
21845
21845
|
if (typeof event["x2-user-message"] !== "string" || !event["x2-user-message"].trim())
|
|
21846
|
-
issues.push(issue2(`${
|
|
21846
|
+
issues.push(issue2(`${path23}.onSuccess.event.x2-user-message`, "INVALID_ACTION_CONTEXT", "x2-user-message must be a non-empty string"));
|
|
21847
21847
|
}
|
|
21848
|
-
function validateActionDynamicValue(value,
|
|
21848
|
+
function validateActionDynamicValue(value, path23, issues) {
|
|
21849
21849
|
if (Array.isArray(value)) {
|
|
21850
|
-
value.forEach((entry, index) => validateActionDynamicValue(entry, `${
|
|
21850
|
+
value.forEach((entry, index) => validateActionDynamicValue(entry, `${path23}[${index}]`, issues));
|
|
21851
21851
|
return;
|
|
21852
21852
|
}
|
|
21853
21853
|
if (!isPlainRecord(value))
|
|
@@ -21855,94 +21855,94 @@ function validateActionDynamicValue(value, path26, issues) {
|
|
|
21855
21855
|
const keys = Object.keys(value);
|
|
21856
21856
|
if (keys.includes("path") && keys.every((key) => key === "path" || key === "fallback")) {
|
|
21857
21857
|
if (!isStrictBinding(value))
|
|
21858
|
-
issues.push(issue2(
|
|
21858
|
+
issues.push(issue2(path23, "INVALID_ACTION_BINDING", "action values require a strict binding without fallback"));
|
|
21859
21859
|
return;
|
|
21860
21860
|
}
|
|
21861
|
-
Object.entries(value).forEach(([key, entry]) => validateActionDynamicValue(entry, `${
|
|
21861
|
+
Object.entries(value).forEach(([key, entry]) => validateActionDynamicValue(entry, `${path23}.${key}`, issues));
|
|
21862
21862
|
}
|
|
21863
|
-
function validateOverlayTarget(value,
|
|
21863
|
+
function validateOverlayTarget(value, path23, issues) {
|
|
21864
21864
|
if (!isPlainRecord(value) || value.type !== "overlay" || !isPlainRecord(value.presentation) || value.presentation.kind !== "bottom-sheet")
|
|
21865
|
-
issues.push(issue2(
|
|
21865
|
+
issues.push(issue2(path23, "INVALID_EVENT_TARGET", "event target must be an overlay bottom-sheet presentation"));
|
|
21866
21866
|
}
|
|
21867
|
-
function validateOptions(value,
|
|
21867
|
+
function validateOptions(value, path23, issues) {
|
|
21868
21868
|
if (isStrictBinding(value))
|
|
21869
21869
|
return;
|
|
21870
21870
|
if (!Array.isArray(value) || value.length === 0)
|
|
21871
|
-
return void issues.push(issue2(
|
|
21871
|
+
return void issues.push(issue2(path23, "INVALID_OPTIONS", "options must be a non-empty array"));
|
|
21872
21872
|
const seen = /* @__PURE__ */ new Set();
|
|
21873
21873
|
value.forEach((entry, index) => {
|
|
21874
21874
|
if (!isPlainRecord(entry) || Object.keys(entry).some((key) => key !== "label" && key !== "value") || typeof entry.label !== "string" || !entry.label || typeof entry.value !== "string" || !entry.value)
|
|
21875
|
-
issues.push(issue2(`${
|
|
21875
|
+
issues.push(issue2(`${path23}[${index}]`, "INVALID_OPTION", "option requires only non-empty label and value"));
|
|
21876
21876
|
else if (seen.has(entry.value))
|
|
21877
|
-
issues.push(issue2(`${
|
|
21877
|
+
issues.push(issue2(`${path23}[${index}].value`, "DUPLICATE_OPTION_VALUE", "option values must be unique"));
|
|
21878
21878
|
else
|
|
21879
21879
|
seen.add(entry.value);
|
|
21880
21880
|
});
|
|
21881
21881
|
}
|
|
21882
|
-
function validateTextField(component,
|
|
21882
|
+
function validateTextField(component, path23, issues) {
|
|
21883
21883
|
if (!isStrictBinding(component.value))
|
|
21884
|
-
issues.push(issue2(`${
|
|
21884
|
+
issues.push(issue2(`${path23}.value`, "INPUT_REQUIRES_BINDING", "TextField.value must be a strict writable binding"));
|
|
21885
21885
|
if (component["x2-limit"] !== void 0 && (!Number.isInteger(component["x2-limit"]) || Number(component["x2-limit"]) < 1 || Number(component["x2-limit"]) > 1e4))
|
|
21886
|
-
issues.push(issue2(`${
|
|
21886
|
+
issues.push(issue2(`${path23}.x2-limit`, "INVALID_TEXT_LIMIT", "x2-limit must be an integer from 1 to 10000"));
|
|
21887
21887
|
if (typeof component.validationRegexp === "string") {
|
|
21888
21888
|
if (component.validationRegexp.length > 512)
|
|
21889
|
-
issues.push(issue2(`${
|
|
21889
|
+
issues.push(issue2(`${path23}.validationRegexp`, "INVALID_VALIDATION_REGEXP", "validationRegexp is too long"));
|
|
21890
21890
|
else
|
|
21891
21891
|
try {
|
|
21892
21892
|
new RegExp(component.validationRegexp);
|
|
21893
21893
|
} catch {
|
|
21894
|
-
issues.push(issue2(`${
|
|
21894
|
+
issues.push(issue2(`${path23}.validationRegexp`, "INVALID_VALIDATION_REGEXP", "validationRegexp is invalid"));
|
|
21895
21895
|
}
|
|
21896
21896
|
}
|
|
21897
21897
|
}
|
|
21898
|
-
function validateStepper(component,
|
|
21898
|
+
function validateStepper(component, path23, issues) {
|
|
21899
21899
|
if (!isStrictBinding(component.value))
|
|
21900
|
-
issues.push(issue2(`${
|
|
21900
|
+
issues.push(issue2(`${path23}.value`, "INPUT_REQUIRES_BINDING", "Stepper.value must be a strict writable binding"));
|
|
21901
21901
|
if (component.step !== void 0 && (!Number.isFinite(component.step) || Number(component.step) <= 0))
|
|
21902
|
-
issues.push(issue2(`${
|
|
21902
|
+
issues.push(issue2(`${path23}.step`, "INVALID_STEPPER_RANGE", "step must be greater than zero"));
|
|
21903
21903
|
if (Number.isFinite(component.min) && Number.isFinite(component.max) && Number(component.min) > Number(component.max))
|
|
21904
|
-
issues.push(issue2(`${
|
|
21904
|
+
issues.push(issue2(`${path23}`, "INVALID_STEPPER_RANGE", "min must not exceed max"));
|
|
21905
21905
|
}
|
|
21906
|
-
function validateChecks(value,
|
|
21906
|
+
function validateChecks(value, path23, issues) {
|
|
21907
21907
|
if (!Array.isArray(value))
|
|
21908
|
-
return void issues.push(issue2(
|
|
21908
|
+
return void issues.push(issue2(path23, "INVALID_CHECKS", "checks must be an array"));
|
|
21909
21909
|
value.forEach((entry, index) => {
|
|
21910
21910
|
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") {
|
|
21911
|
-
issues.push(issue2(`${
|
|
21911
|
+
issues.push(issue2(`${path23}[${index}]`, "INVALID_CHECK", "check must be an implemented required check with a strict binding"));
|
|
21912
21912
|
}
|
|
21913
21913
|
});
|
|
21914
21914
|
}
|
|
21915
|
-
function validateOverflow(component,
|
|
21915
|
+
function validateOverflow(component, path23, issues) {
|
|
21916
21916
|
const value = component["x2-overflow"];
|
|
21917
21917
|
const children = component.children;
|
|
21918
21918
|
if (!isPlainRecord(children) || !isPlainRecord(value)) {
|
|
21919
|
-
issues.push(issue2(`${
|
|
21919
|
+
issues.push(issue2(`${path23}.x2-overflow`, "INVALID_OVERFLOW", "x2-overflow requires dynamic children and an object value"));
|
|
21920
21920
|
return;
|
|
21921
21921
|
}
|
|
21922
|
-
rejectUnknownKeys(value, ["mode", "previewCount", "trigger", "overlay"], `${
|
|
21922
|
+
rejectUnknownKeys(value, ["mode", "previewCount", "trigger", "overlay"], `${path23}.x2-overflow`, issues);
|
|
21923
21923
|
if (value.mode !== "overlay-all" || !Number.isInteger(value.previewCount) || Number(value.previewCount) < 0 || Number(value.previewCount) > 100) {
|
|
21924
|
-
issues.push(issue2(`${
|
|
21924
|
+
issues.push(issue2(`${path23}.x2-overflow`, "INVALID_OVERFLOW", "overlay-all requires an integer previewCount from 0 to 100"));
|
|
21925
21925
|
}
|
|
21926
21926
|
if (!isPlainRecord(value.trigger)) {
|
|
21927
|
-
issues.push(issue2(`${
|
|
21927
|
+
issues.push(issue2(`${path23}.x2-overflow.trigger`, "INVALID_OVERFLOW_TRIGGER", "trigger must contain display text"));
|
|
21928
21928
|
} else {
|
|
21929
|
-
rejectUnknownKeys(value.trigger, ["text"], `${
|
|
21929
|
+
rejectUnknownKeys(value.trigger, ["text"], `${path23}.x2-overflow.trigger`, issues);
|
|
21930
21930
|
if (!isDisplayBinding(value.trigger.text, true) && typeof value.trigger.text !== "string") {
|
|
21931
|
-
issues.push(issue2(`${
|
|
21931
|
+
issues.push(issue2(`${path23}.x2-overflow.trigger.text`, "INVALID_OVERFLOW_TRIGGER", "trigger.text must be a string or display binding"));
|
|
21932
21932
|
}
|
|
21933
21933
|
}
|
|
21934
21934
|
if (!isPlainRecord(value.overlay)) {
|
|
21935
|
-
issues.push(issue2(`${
|
|
21935
|
+
issues.push(issue2(`${path23}.x2-overflow.overlay`, "INVALID_OVERFLOW_PRESENTATION", "overlay must be a bottom-sheet presentation"));
|
|
21936
21936
|
} else {
|
|
21937
|
-
rejectUnknownKeys(value.overlay, ["kind", "title", "size"], `${
|
|
21937
|
+
rejectUnknownKeys(value.overlay, ["kind", "title", "size"], `${path23}.x2-overflow.overlay`, issues);
|
|
21938
21938
|
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))) {
|
|
21939
|
-
issues.push(issue2(`${
|
|
21939
|
+
issues.push(issue2(`${path23}.x2-overflow.overlay`, "INVALID_OVERFLOW_PRESENTATION", "overlay must be a bottom-sheet with an optional string title and supported size"));
|
|
21940
21940
|
}
|
|
21941
21941
|
}
|
|
21942
21942
|
}
|
|
21943
|
-
function validateNumberFormat(value,
|
|
21943
|
+
function validateNumberFormat(value, path23, issues) {
|
|
21944
21944
|
if (!isPlainRecord(value))
|
|
21945
|
-
return void issues.push(issue2(
|
|
21945
|
+
return void issues.push(issue2(path23, "INVALID_NUMBER_FORMAT", "format must be an object"));
|
|
21946
21946
|
rejectUnknownKeys(value, [
|
|
21947
21947
|
"type",
|
|
21948
21948
|
"style",
|
|
@@ -21953,40 +21953,40 @@ function validateNumberFormat(value, path26, issues) {
|
|
|
21953
21953
|
"useGrouping",
|
|
21954
21954
|
"prefix",
|
|
21955
21955
|
"suffix"
|
|
21956
|
-
],
|
|
21956
|
+
], path23, issues);
|
|
21957
21957
|
const style = value.style ?? "decimal";
|
|
21958
21958
|
const digit = (entry) => entry === void 0 || Number.isInteger(entry) && Number(entry) >= 0 && Number(entry) <= 20;
|
|
21959
21959
|
if (value.type !== "number" || !["decimal", "currency", "percent"].includes(String(style)) || style === "currency" && (typeof value.currency !== "string" || !/^[A-Z]{3}$/u.test(value.currency)) || value.locale !== void 0 && typeof value.locale !== "string" || !digit(value.minimumFractionDigits) || !digit(value.maximumFractionDigits) || Number.isInteger(value.minimumFractionDigits) && Number.isInteger(value.maximumFractionDigits) && Number(value.minimumFractionDigits) > Number(value.maximumFractionDigits) || value.useGrouping !== void 0 && typeof value.useGrouping !== "boolean" || value.prefix !== void 0 && (typeof value.prefix !== "string" || value.prefix.length > 32) || value.suffix !== void 0 && (typeof value.suffix !== "string" || value.suffix.length > 32)) {
|
|
21960
|
-
issues.push(issue2(
|
|
21960
|
+
issues.push(issue2(path23, "INVALID_NUMBER_FORMAT", "number format options are invalid"));
|
|
21961
21961
|
}
|
|
21962
21962
|
}
|
|
21963
|
-
function rejectUnknownKeys(value, allowed,
|
|
21963
|
+
function rejectUnknownKeys(value, allowed, path23, issues) {
|
|
21964
21964
|
const allowedKeys = new Set(allowed);
|
|
21965
21965
|
Object.keys(value).forEach((key) => {
|
|
21966
21966
|
if (!allowedKeys.has(key))
|
|
21967
|
-
issues.push(issue2(`${
|
|
21967
|
+
issues.push(issue2(`${path23}.${key}`, "UNKNOWN_PROTOCOL_FIELD", `unknown field ${key}`));
|
|
21968
21968
|
});
|
|
21969
21969
|
}
|
|
21970
21970
|
function isSafePageUrl(value) {
|
|
21971
21971
|
return value.length <= 2e3 && (value.startsWith("https://") || value.startsWith("alipays://"));
|
|
21972
21972
|
}
|
|
21973
|
-
function validateReferences(surfaces,
|
|
21973
|
+
function validateReferences(surfaces, path23, issues) {
|
|
21974
21974
|
for (const [surfaceId, components] of surfaces) {
|
|
21975
21975
|
if (!components.has("root"))
|
|
21976
|
-
issues.push(issue2(`${
|
|
21976
|
+
issues.push(issue2(`${path23}.surfaces.${surfaceId}`, "MISSING_ROOT_COMPONENT", "surface must define root"));
|
|
21977
21977
|
const edges = /* @__PURE__ */ new Map();
|
|
21978
21978
|
for (const [id, component] of components) {
|
|
21979
21979
|
const refs = getComponentReferences(component);
|
|
21980
21980
|
edges.set(id, refs);
|
|
21981
21981
|
refs.forEach((ref) => {
|
|
21982
21982
|
if (!components.has(ref))
|
|
21983
|
-
issues.push(issue2(`${
|
|
21983
|
+
issues.push(issue2(`${path23}.surfaces.${surfaceId}.components.${id}.${component.child !== void 0 ? "child" : "children"}`, "MISSING_COMPONENT_REFERENCE", `component ${ref} does not exist`));
|
|
21984
21984
|
});
|
|
21985
21985
|
if ((component.component === "Button" || component.component === "Card" && component.action !== void 0) && refs.some((ref) => hasInteractiveDescendant(ref, components, /* @__PURE__ */ new Set())))
|
|
21986
|
-
issues.push(issue2(`${
|
|
21986
|
+
issues.push(issue2(`${path23}.surfaces.${surfaceId}.components.${id}.${component.child !== void 0 ? "child" : "children"}`, "NESTED_INTERACTION", "action components cannot contain interactive descendants"));
|
|
21987
21987
|
collectSurfaceOpenReferences(component.action).forEach((targetSurfaceId) => {
|
|
21988
21988
|
if (!surfaces.has(targetSurfaceId))
|
|
21989
|
-
issues.push(issue2(`${
|
|
21989
|
+
issues.push(issue2(`${path23}.surfaces.${surfaceId}.components.${id}.action`, "MISSING_SURFACE_REFERENCE", `surface ${targetSurfaceId} does not exist`));
|
|
21990
21990
|
});
|
|
21991
21991
|
}
|
|
21992
21992
|
components.forEach((component, id) => {
|
|
@@ -21994,14 +21994,14 @@ function validateReferences(surfaces, path26, issues) {
|
|
|
21994
21994
|
return;
|
|
21995
21995
|
const parents = [...components.values()].filter((parent) => getComponentReferences(parent).includes(id));
|
|
21996
21996
|
if (id === "root" || parents.length === 0 || parents.some((parent) => parent.component !== "Row" && parent.component !== "Column")) {
|
|
21997
|
-
issues.push(issue2(`${
|
|
21997
|
+
issues.push(issue2(`${path23}.surfaces.${surfaceId}.components.${id}.grow`, "INVALID_LAYOUT_PARENT", "grow requires a direct Row or Column parent in every occurrence"));
|
|
21998
21998
|
}
|
|
21999
21999
|
});
|
|
22000
22000
|
const visiting = /* @__PURE__ */ new Set();
|
|
22001
22001
|
const visited = /* @__PURE__ */ new Set();
|
|
22002
22002
|
const walk = (id) => {
|
|
22003
22003
|
if (visiting.has(id))
|
|
22004
|
-
return void issues.push(issue2(`${
|
|
22004
|
+
return void issues.push(issue2(`${path23}.surfaces.${surfaceId}.components.${id}`, "CIRCULAR_COMPONENT_REFERENCE", "component references must not contain a cycle"));
|
|
22005
22005
|
if (visited.has(id))
|
|
22006
22006
|
return;
|
|
22007
22007
|
visiting.add(id);
|
|
@@ -22102,29 +22102,29 @@ function getA2UICardDraftBundleIssues(value) {
|
|
|
22102
22102
|
}
|
|
22103
22103
|
return issues;
|
|
22104
22104
|
}
|
|
22105
|
-
function getPersistedV4ProtocolIssues(card,
|
|
22105
|
+
function getPersistedV4ProtocolIssues(card, path23) {
|
|
22106
22106
|
const issues = [];
|
|
22107
22107
|
if (card.length !== 1) {
|
|
22108
|
-
issues.push(issue2(
|
|
22108
|
+
issues.push(issue2(path23, "INVALID_PERSISTED_V4_MESSAGES", "V4 persisted cards must use exactly one message"));
|
|
22109
22109
|
}
|
|
22110
22110
|
const instructions = card.flatMap((message) => message.datas);
|
|
22111
22111
|
const creates = instructions.filter((instruction) => "createSurface" in instruction);
|
|
22112
22112
|
const updates = instructions.filter((instruction) => "updateComponents" in instruction);
|
|
22113
22113
|
if (creates.length < 1 || creates.length !== updates.length || instructions.length !== creates.length + updates.length) {
|
|
22114
|
-
issues.push(issue2(
|
|
22114
|
+
issues.push(issue2(path23, "INVALID_PERSISTED_V4_INSTRUCTIONS", "V4 persisted cards require one createSurface and one complete updateComponents per Surface"));
|
|
22115
22115
|
}
|
|
22116
22116
|
const createIds = creates.flatMap((instruction) => "createSurface" in instruction ? [instruction.createSurface.surfaceId] : []);
|
|
22117
22117
|
const updateIds = updates.flatMap((instruction) => "updateComponents" in instruction ? [instruction.updateComponents.surfaceId] : []);
|
|
22118
22118
|
for (const surfaceId of /* @__PURE__ */ new Set([...createIds, ...updateIds])) {
|
|
22119
22119
|
if (createIds.filter((id) => id === surfaceId).length !== 1 || updateIds.filter((id) => id === surfaceId).length !== 1) {
|
|
22120
|
-
issues.push(issue2(`${
|
|
22120
|
+
issues.push(issue2(`${path23}.surfaces.${surfaceId}`, "SURFACE_INSTRUCTION_MISMATCH", "each persisted Surface requires exactly one create and one component update"));
|
|
22121
22121
|
}
|
|
22122
22122
|
}
|
|
22123
22123
|
return issues;
|
|
22124
22124
|
}
|
|
22125
|
-
function validateV4Fixture(value, fields,
|
|
22125
|
+
function validateV4Fixture(value, fields, path23, issues) {
|
|
22126
22126
|
if (!isPlainRecord(value)) {
|
|
22127
|
-
issues.push(issue2(
|
|
22127
|
+
issues.push(issue2(path23, "INVALID_FIXTURE", "fixture must be a JSON object"));
|
|
22128
22128
|
return;
|
|
22129
22129
|
}
|
|
22130
22130
|
for (const field of fields) {
|
|
@@ -22133,17 +22133,17 @@ function validateV4Fixture(value, fields, path26, issues) {
|
|
|
22133
22133
|
const resolved = getFixtureValue(value, field.path);
|
|
22134
22134
|
if (!resolved.found) {
|
|
22135
22135
|
if (field.required)
|
|
22136
|
-
issues.push(issue2(`${
|
|
22136
|
+
issues.push(issue2(`${path23}${field.path}`, "REQUIRED_FIXTURE_FIELD_MISSING", `fixture is missing required field ${field.fieldId}`));
|
|
22137
22137
|
continue;
|
|
22138
22138
|
}
|
|
22139
|
-
issues.push(...validateJsonSchemaValue2(field.valueSchema, resolved.value, `${
|
|
22139
|
+
issues.push(...validateJsonSchemaValue2(field.valueSchema, resolved.value, `${path23}${field.path}`));
|
|
22140
22140
|
}
|
|
22141
22141
|
}
|
|
22142
|
-
function validateV4BindingContracts(card, occurrences, fields,
|
|
22142
|
+
function validateV4BindingContracts(card, occurrences, fields, path23, issues) {
|
|
22143
22143
|
const ordered = fields.slice().sort((left, right) => right.path.length - left.path.length);
|
|
22144
22144
|
for (const occurrence of occurrences) {
|
|
22145
22145
|
const field = ordered.find((candidate) => occurrence.canonicalPath === candidate.path || occurrence.canonicalPath.startsWith(`${candidate.path}/*/`) || occurrence.canonicalPath.startsWith(`${candidate.path}/`));
|
|
22146
|
-
const issuePath = `${
|
|
22146
|
+
const issuePath = `${path23}.surfaces.${occurrence.surfaceId ?? "unknown"}.components.${occurrence.componentId}.${occurrence.propertyPath}`;
|
|
22147
22147
|
if (!field) {
|
|
22148
22148
|
issues.push(issue2(issuePath, "UNDECLARED_BINDING_PATH", `binding path ${occurrence.rawPath} is not declared by a manifest field`));
|
|
22149
22149
|
continue;
|
|
@@ -22297,14 +22297,14 @@ function getA2UICardResourceConfigV3Issues(value) {
|
|
|
22297
22297
|
}
|
|
22298
22298
|
return issues;
|
|
22299
22299
|
}
|
|
22300
|
-
function validateDataSources(value,
|
|
22300
|
+
function validateDataSources(value, path23, issues, options = {}) {
|
|
22301
22301
|
if (!Array.isArray(value)) {
|
|
22302
|
-
issues.push(issue2(
|
|
22302
|
+
issues.push(issue2(path23, "INVALID_DATA_SOURCES", "dataSources must be a non-empty array"));
|
|
22303
22303
|
return void 0;
|
|
22304
22304
|
}
|
|
22305
22305
|
const ids = /* @__PURE__ */ new Set();
|
|
22306
22306
|
value.forEach((candidate, index) => {
|
|
22307
|
-
const itemPath = `${
|
|
22307
|
+
const itemPath = `${path23}[${index}]`;
|
|
22308
22308
|
if (!isPlainRecord(candidate)) {
|
|
22309
22309
|
issues.push(issue2(itemPath, "INVALID_DATA_SOURCE", "data source must be an object"));
|
|
22310
22310
|
return;
|
|
@@ -22342,7 +22342,7 @@ function validateDataSources(value, path26, issues, options = {}) {
|
|
|
22342
22342
|
for (const [index, source] of value.entries()) {
|
|
22343
22343
|
for (const dependency of source.dependsOn ?? []) {
|
|
22344
22344
|
if (!ids.has(dependency) || dependency === source.sourceId) {
|
|
22345
|
-
issues.push(issue2(`${
|
|
22345
|
+
issues.push(issue2(`${path23}[${index}].dependsOn`, "UNKNOWN_SOURCE_DEPENDENCY", `Unknown dependency ${dependency}`));
|
|
22346
22346
|
}
|
|
22347
22347
|
}
|
|
22348
22348
|
}
|
|
@@ -22361,18 +22361,18 @@ function validateDataSources(value, path26, issues, options = {}) {
|
|
|
22361
22361
|
return cyclic;
|
|
22362
22362
|
};
|
|
22363
22363
|
if ([...byId.keys()].some(visit)) {
|
|
22364
|
-
issues.push(issue2(
|
|
22364
|
+
issues.push(issue2(path23, "CYCLIC_SOURCE_DEPENDENCY", "data source dependencies must be acyclic"));
|
|
22365
22365
|
}
|
|
22366
22366
|
return value;
|
|
22367
22367
|
}
|
|
22368
|
-
function validateV3OutputBindings(value,
|
|
22368
|
+
function validateV3OutputBindings(value, path23, issues) {
|
|
22369
22369
|
if (!Array.isArray(value)) {
|
|
22370
|
-
issues.push(issue2(
|
|
22370
|
+
issues.push(issue2(path23, "INVALID_OUTPUT_BINDINGS", "bindings must be an array"));
|
|
22371
22371
|
return void 0;
|
|
22372
22372
|
}
|
|
22373
22373
|
const fields = /* @__PURE__ */ new Set();
|
|
22374
22374
|
value.forEach((candidate, index) => {
|
|
22375
|
-
const itemPath = `${
|
|
22375
|
+
const itemPath = `${path23}[${index}]`;
|
|
22376
22376
|
if (!isPlainRecord(candidate)) {
|
|
22377
22377
|
issues.push(issue2(itemPath, "INVALID_OUTPUT_BINDING", "binding must be an object"));
|
|
22378
22378
|
return;
|
|
@@ -22415,9 +22415,9 @@ function validateV3Coverage(fields, dataSources, bindings, issues, options = {})
|
|
|
22415
22415
|
}
|
|
22416
22416
|
}
|
|
22417
22417
|
}
|
|
22418
|
-
function validateV3BindingSelections(value,
|
|
22418
|
+
function validateV3BindingSelections(value, path23, fields, issues) {
|
|
22419
22419
|
if (!Array.isArray(value)) {
|
|
22420
|
-
issues.push(issue2(
|
|
22420
|
+
issues.push(issue2(path23, "INVALID_BINDINGS", "bindings must be an array"));
|
|
22421
22421
|
return;
|
|
22422
22422
|
}
|
|
22423
22423
|
if (value.length === 0)
|
|
@@ -22426,7 +22426,7 @@ function validateV3BindingSelections(value, path26, fields, issues) {
|
|
|
22426
22426
|
const outputBindings = [];
|
|
22427
22427
|
const dataSources = [];
|
|
22428
22428
|
value.forEach((candidate, index) => {
|
|
22429
|
-
const itemPath = `${
|
|
22429
|
+
const itemPath = `${path23}[${index}]`;
|
|
22430
22430
|
if (!isPlainRecord(candidate)) {
|
|
22431
22431
|
issues.push(issue2(itemPath, "INVALID_BINDING", "binding must be an object"));
|
|
22432
22432
|
return;
|
|
@@ -22471,24 +22471,24 @@ function validateV3BindingSelections(value, path26, fields, issues) {
|
|
|
22471
22471
|
});
|
|
22472
22472
|
}
|
|
22473
22473
|
});
|
|
22474
|
-
validateDataSources(dataSources, `${
|
|
22474
|
+
validateDataSources(dataSources, `${path23}.dataSources`, issues, {
|
|
22475
22475
|
validateOutputSchema: false
|
|
22476
22476
|
});
|
|
22477
|
-
validateV3OutputBindings(outputBindings, `${
|
|
22477
|
+
validateV3OutputBindings(outputBindings, `${path23}.outputs`, issues);
|
|
22478
22478
|
if (fields) {
|
|
22479
22479
|
validateV3Coverage(fields, dataSources, outputBindings, issues, {
|
|
22480
22480
|
requireComplete: false
|
|
22481
22481
|
});
|
|
22482
22482
|
}
|
|
22483
22483
|
}
|
|
22484
|
-
function validateManifest(value,
|
|
22484
|
+
function validateManifest(value, path23, issues) {
|
|
22485
22485
|
if (!isPlainRecord(value)) {
|
|
22486
|
-
issues.push(issue2(
|
|
22486
|
+
issues.push(issue2(path23, "INVALID_MANIFEST", `${path23} must be an object`));
|
|
22487
22487
|
return void 0;
|
|
22488
22488
|
}
|
|
22489
22489
|
if (value.schemaVersion === "3" || value.schemaVersion === "4") {
|
|
22490
22490
|
if (value.actionBindings !== void 0) {
|
|
22491
|
-
issues.push(issue2(`${
|
|
22491
|
+
issues.push(issue2(`${path23}.actionBindings`, "LEGACY_PAYMENT_ACTION_BINDINGS_UNSUPPORTED", "payment actions must be defined inline in card JSON"));
|
|
22492
22492
|
}
|
|
22493
22493
|
exactKeys(value, [
|
|
22494
22494
|
"schemaVersion",
|
|
@@ -22501,24 +22501,24 @@ function validateManifest(value, path26, issues) {
|
|
|
22501
22501
|
"whenNotToUse",
|
|
22502
22502
|
"fields",
|
|
22503
22503
|
"bindings"
|
|
22504
|
-
],
|
|
22504
|
+
], path23, issues);
|
|
22505
22505
|
if (!isSafeIdentifier(value.draftId)) {
|
|
22506
|
-
issues.push(issue2(`${
|
|
22506
|
+
issues.push(issue2(`${path23}.draftId`, "INVALID_DRAFT_ID", "draftId is invalid"));
|
|
22507
22507
|
}
|
|
22508
22508
|
if (!isSafeIdentifier(value.resourceId)) {
|
|
22509
|
-
issues.push(issue2(`${
|
|
22510
|
-
}
|
|
22511
|
-
optionalString(value.baseRevision, `${
|
|
22512
|
-
requiredString(value.displayName, `${
|
|
22513
|
-
requiredString(value.description, `${
|
|
22514
|
-
requiredString(value.whenToUse, `${
|
|
22515
|
-
optionalString(value.whenNotToUse, `${
|
|
22516
|
-
const fields2 = validateFields(value.fields, `${
|
|
22509
|
+
issues.push(issue2(`${path23}.resourceId`, "INVALID_RESOURCE_ID", "resourceId is invalid"));
|
|
22510
|
+
}
|
|
22511
|
+
optionalString(value.baseRevision, `${path23}.baseRevision`, issues);
|
|
22512
|
+
requiredString(value.displayName, `${path23}.displayName`, issues);
|
|
22513
|
+
requiredString(value.description, `${path23}.description`, issues);
|
|
22514
|
+
requiredString(value.whenToUse, `${path23}.whenToUse`, issues);
|
|
22515
|
+
optionalString(value.whenNotToUse, `${path23}.whenNotToUse`, issues);
|
|
22516
|
+
const fields2 = validateFields(value.fields, `${path23}.fields`, issues);
|
|
22517
22517
|
if (fields2?.some((field) => field.source === "invocation")) {
|
|
22518
|
-
issues.push(issue2(`${
|
|
22518
|
+
issues.push(issue2(`${path23}.fields`, "INVOCATION_FIELD_UNSUPPORTED", `schema v${value.schemaVersion} does not support invocation fields`));
|
|
22519
22519
|
}
|
|
22520
22520
|
if (value.bindings !== void 0) {
|
|
22521
|
-
validateV3BindingSelections(value.bindings, `${
|
|
22521
|
+
validateV3BindingSelections(value.bindings, `${path23}.bindings`, fields2, issues);
|
|
22522
22522
|
}
|
|
22523
22523
|
return fields2 ? value : void 0;
|
|
22524
22524
|
}
|
|
@@ -22534,37 +22534,37 @@ function validateManifest(value, path26, issues) {
|
|
|
22534
22534
|
"presentationInputSchema",
|
|
22535
22535
|
"fields",
|
|
22536
22536
|
"bindings"
|
|
22537
|
-
],
|
|
22537
|
+
], path23, issues);
|
|
22538
22538
|
if (value.schemaVersion !== "2") {
|
|
22539
|
-
issues.push(issue2(`${
|
|
22539
|
+
issues.push(issue2(`${path23}.schemaVersion`, "UNSUPPORTED_DRAFT_VERSION", "schemaVersion must be 2, 3 or 4"));
|
|
22540
22540
|
}
|
|
22541
22541
|
if (!isSafeIdentifier(value.draftId)) {
|
|
22542
|
-
issues.push(issue2(`${
|
|
22542
|
+
issues.push(issue2(`${path23}.draftId`, "INVALID_DRAFT_ID", "draftId is invalid"));
|
|
22543
22543
|
}
|
|
22544
22544
|
if (!isSafeIdentifier(value.resourceId)) {
|
|
22545
|
-
issues.push(issue2(`${
|
|
22546
|
-
}
|
|
22547
|
-
optionalString(value.baseRevision, `${
|
|
22548
|
-
requiredString(value.displayName, `${
|
|
22549
|
-
requiredString(value.description, `${
|
|
22550
|
-
requiredString(value.whenToUse, `${
|
|
22551
|
-
optionalString(value.whenNotToUse, `${
|
|
22552
|
-
const schema = validateLooseJsonSchema(value.presentationInputSchema, `${
|
|
22553
|
-
const fields = validateFields(value.fields, `${
|
|
22545
|
+
issues.push(issue2(`${path23}.resourceId`, "INVALID_RESOURCE_ID", "resourceId is invalid"));
|
|
22546
|
+
}
|
|
22547
|
+
optionalString(value.baseRevision, `${path23}.baseRevision`, issues);
|
|
22548
|
+
requiredString(value.displayName, `${path23}.displayName`, issues);
|
|
22549
|
+
requiredString(value.description, `${path23}.description`, issues);
|
|
22550
|
+
requiredString(value.whenToUse, `${path23}.whenToUse`, issues);
|
|
22551
|
+
optionalString(value.whenNotToUse, `${path23}.whenNotToUse`, issues);
|
|
22552
|
+
const schema = validateLooseJsonSchema(value.presentationInputSchema, `${path23}.presentationInputSchema`, issues);
|
|
22553
|
+
const fields = validateFields(value.fields, `${path23}.fields`, issues);
|
|
22554
22554
|
if (value.bindings !== void 0) {
|
|
22555
|
-
issues.push(...getA2UICardBindingSelectionIssues(value.bindings, `${
|
|
22555
|
+
issues.push(...getA2UICardBindingSelectionIssues(value.bindings, `${path23}.bindings`, fields));
|
|
22556
22556
|
}
|
|
22557
22557
|
return schema && fields ? value : void 0;
|
|
22558
22558
|
}
|
|
22559
|
-
function validateFields(value,
|
|
22559
|
+
function validateFields(value, path23, issues) {
|
|
22560
22560
|
if (!Array.isArray(value)) {
|
|
22561
|
-
issues.push(issue2(
|
|
22561
|
+
issues.push(issue2(path23, "INVALID_FIELDS", `${path23} must be an array`));
|
|
22562
22562
|
return void 0;
|
|
22563
22563
|
}
|
|
22564
22564
|
const ids = /* @__PURE__ */ new Set();
|
|
22565
22565
|
const paths = /* @__PURE__ */ new Set();
|
|
22566
22566
|
value.forEach((candidate, index) => {
|
|
22567
|
-
const itemPath = `${
|
|
22567
|
+
const itemPath = `${path23}[${index}]`;
|
|
22568
22568
|
if (!isPlainRecord(candidate)) {
|
|
22569
22569
|
issues.push(issue2(itemPath, "INVALID_FIELD", `${itemPath} must be an object`));
|
|
22570
22570
|
return;
|
|
@@ -22623,24 +22623,24 @@ function validateFields(value, path26, issues) {
|
|
|
22623
22623
|
function validateFieldPresentation(value, itemPath, issues) {
|
|
22624
22624
|
if (value === void 0)
|
|
22625
22625
|
return;
|
|
22626
|
-
const
|
|
22626
|
+
const path23 = `${itemPath}.presentation`;
|
|
22627
22627
|
if (!isPlainRecord(value)) {
|
|
22628
|
-
issues.push(issue2(
|
|
22628
|
+
issues.push(issue2(path23, "INVALID_FIELD_PRESENTATION", `${path23} must be an object`));
|
|
22629
22629
|
return;
|
|
22630
22630
|
}
|
|
22631
22631
|
if (!["echo", "reference-only", "never"].includes(String(value.visibility))) {
|
|
22632
|
-
issues.push(issue2(`${
|
|
22632
|
+
issues.push(issue2(`${path23}.visibility`, "INVALID_PRESENTATION_VISIBILITY", "presentation visibility must be echo, reference-only or never"));
|
|
22633
22633
|
}
|
|
22634
22634
|
if (value.labelPath !== void 0 && !isSafeJsonPointer(value.labelPath)) {
|
|
22635
|
-
issues.push(issue2(`${
|
|
22635
|
+
issues.push(issue2(`${path23}.labelPath`, "INVALID_PRESENTATION_PATH", "labelPath must be a safe JSON pointer"));
|
|
22636
22636
|
}
|
|
22637
22637
|
if (value.attributePaths !== void 0) {
|
|
22638
22638
|
if (!Array.isArray(value.attributePaths) || value.attributePaths.length > 3 || value.attributePaths.some((candidate) => !isSafeJsonPointer(candidate))) {
|
|
22639
|
-
issues.push(issue2(`${
|
|
22639
|
+
issues.push(issue2(`${path23}.attributePaths`, "INVALID_PRESENTATION_PATHS", "attributePaths must contain at most 3 safe JSON pointers"));
|
|
22640
22640
|
}
|
|
22641
22641
|
}
|
|
22642
22642
|
if (value.maxItems !== void 0 && (!Number.isInteger(value.maxItems) || Number(value.maxItems) < 1 || Number(value.maxItems) > 10)) {
|
|
22643
|
-
issues.push(issue2(`${
|
|
22643
|
+
issues.push(issue2(`${path23}.maxItems`, "INVALID_PRESENTATION_MAX_ITEMS", "maxItems must be an integer between 1 and 10"));
|
|
22644
22644
|
}
|
|
22645
22645
|
}
|
|
22646
22646
|
function validateFieldSource(candidate, itemPath, issues) {
|
|
@@ -22659,35 +22659,35 @@ function validateFieldSource(candidate, itemPath, issues) {
|
|
|
22659
22659
|
issues.push(issue2(`${itemPath}.runtimeContextKey`, "UNEXPECTED_RUNTIME_CONTEXT", "runtimeContextKey is only allowed for runtime-context fields"));
|
|
22660
22660
|
}
|
|
22661
22661
|
}
|
|
22662
|
-
function validateResolver(value,
|
|
22662
|
+
function validateResolver(value, path23, issues) {
|
|
22663
22663
|
if (!isPlainRecord(value)) {
|
|
22664
|
-
issues.push(issue2(
|
|
22664
|
+
issues.push(issue2(path23, "INVALID_RESOLVER", "resolver must be an object"));
|
|
22665
22665
|
return void 0;
|
|
22666
22666
|
}
|
|
22667
|
-
exactKeys(value, ["version", "calls", "outputBindings"],
|
|
22667
|
+
exactKeys(value, ["version", "calls", "outputBindings"], path23, issues);
|
|
22668
22668
|
if (value.version !== 2) {
|
|
22669
|
-
issues.push(issue2(`${
|
|
22669
|
+
issues.push(issue2(`${path23}.version`, "UNSUPPORTED_RESOLVER_VERSION", "resolver version must be 2"));
|
|
22670
22670
|
}
|
|
22671
|
-
const calls = validateResolverCalls(value.calls, `${
|
|
22672
|
-
const outputs = validateOutputBindings(value.outputBindings, `${
|
|
22671
|
+
const calls = validateResolverCalls(value.calls, `${path23}.calls`, issues);
|
|
22672
|
+
const outputs = validateOutputBindings(value.outputBindings, `${path23}.outputBindings`, issues);
|
|
22673
22673
|
if (!calls || !outputs)
|
|
22674
22674
|
return void 0;
|
|
22675
22675
|
const callIds = new Set(calls.map((call) => call.callId));
|
|
22676
22676
|
outputs.forEach((binding, index) => {
|
|
22677
22677
|
if (!callIds.has(binding.callId)) {
|
|
22678
|
-
issues.push(issue2(`${
|
|
22678
|
+
issues.push(issue2(`${path23}.outputBindings[${index}].callId`, "UNKNOWN_RESOLVER_CALL", `Unknown resolver call ${binding.callId}`));
|
|
22679
22679
|
}
|
|
22680
22680
|
});
|
|
22681
22681
|
return value;
|
|
22682
22682
|
}
|
|
22683
|
-
function validateResolverCalls(value,
|
|
22683
|
+
function validateResolverCalls(value, path23, issues) {
|
|
22684
22684
|
if (!Array.isArray(value)) {
|
|
22685
|
-
issues.push(issue2(
|
|
22685
|
+
issues.push(issue2(path23, "INVALID_RESOLVER_CALLS", "calls must be an array"));
|
|
22686
22686
|
return void 0;
|
|
22687
22687
|
}
|
|
22688
22688
|
const callIds = /* @__PURE__ */ new Set();
|
|
22689
22689
|
value.forEach((candidate, index) => {
|
|
22690
|
-
const itemPath = `${
|
|
22690
|
+
const itemPath = `${path23}[${index}]`;
|
|
22691
22691
|
if (!isPlainRecord(candidate)) {
|
|
22692
22692
|
issues.push(issue2(itemPath, "INVALID_RESOLVER_CALL", "call must be an object"));
|
|
22693
22693
|
return;
|
|
@@ -22708,14 +22708,14 @@ function validateResolverCalls(value, path26, issues) {
|
|
|
22708
22708
|
});
|
|
22709
22709
|
return value;
|
|
22710
22710
|
}
|
|
22711
|
-
function validateInputBindings2(value,
|
|
22711
|
+
function validateInputBindings2(value, path23, issues) {
|
|
22712
22712
|
if (!Array.isArray(value)) {
|
|
22713
|
-
issues.push(issue2(
|
|
22713
|
+
issues.push(issue2(path23, "INVALID_INPUT_BINDINGS", "inputBindings must be an array"));
|
|
22714
22714
|
return void 0;
|
|
22715
22715
|
}
|
|
22716
22716
|
const paths = /* @__PURE__ */ new Set();
|
|
22717
22717
|
value.forEach((candidate, index) => {
|
|
22718
|
-
const itemPath = `${
|
|
22718
|
+
const itemPath = `${path23}[${index}]`;
|
|
22719
22719
|
if (!isPlainRecord(candidate)) {
|
|
22720
22720
|
issues.push(issue2(itemPath, "INVALID_INPUT_BINDING", "binding must be an object"));
|
|
22721
22721
|
return;
|
|
@@ -22732,35 +22732,35 @@ function validateInputBindings2(value, path26, issues) {
|
|
|
22732
22732
|
});
|
|
22733
22733
|
return value;
|
|
22734
22734
|
}
|
|
22735
|
-
function validateInputSource(value,
|
|
22735
|
+
function validateInputSource(value, path23, issues) {
|
|
22736
22736
|
if (!isPlainRecord(value)) {
|
|
22737
|
-
issues.push(issue2(
|
|
22737
|
+
issues.push(issue2(path23, "INVALID_INPUT_SOURCE", "source must be an object"));
|
|
22738
22738
|
return;
|
|
22739
22739
|
}
|
|
22740
22740
|
if (value.kind === "invocation") {
|
|
22741
|
-
exactKeys(value, ["kind", "path"],
|
|
22741
|
+
exactKeys(value, ["kind", "path"], path23, issues);
|
|
22742
22742
|
if (!isSafeJsonPointer(value.path)) {
|
|
22743
|
-
issues.push(issue2(`${
|
|
22743
|
+
issues.push(issue2(`${path23}.path`, "INVALID_INPUT_SOURCE_PATH", "invocation source path must be a safe JSON pointer"));
|
|
22744
22744
|
}
|
|
22745
22745
|
return;
|
|
22746
22746
|
}
|
|
22747
22747
|
if (value.kind === "runtime-context") {
|
|
22748
|
-
exactKeys(value, ["kind", "key"],
|
|
22748
|
+
exactKeys(value, ["kind", "key"], path23, issues);
|
|
22749
22749
|
if (!RUNTIME_CONTEXT_KEYS2.has(value.key)) {
|
|
22750
|
-
issues.push(issue2(`${
|
|
22750
|
+
issues.push(issue2(`${path23}.key`, "INVALID_RUNTIME_CONTEXT", "runtime context key is invalid"));
|
|
22751
22751
|
}
|
|
22752
22752
|
return;
|
|
22753
22753
|
}
|
|
22754
|
-
issues.push(issue2(`${
|
|
22754
|
+
issues.push(issue2(`${path23}.kind`, "INVALID_INPUT_SOURCE", "source.kind must be invocation or runtime-context"));
|
|
22755
22755
|
}
|
|
22756
|
-
function validateOutputBindings(value,
|
|
22756
|
+
function validateOutputBindings(value, path23, issues) {
|
|
22757
22757
|
if (!Array.isArray(value)) {
|
|
22758
|
-
issues.push(issue2(
|
|
22758
|
+
issues.push(issue2(path23, "INVALID_OUTPUT_BINDINGS", "outputBindings must be an array"));
|
|
22759
22759
|
return void 0;
|
|
22760
22760
|
}
|
|
22761
22761
|
const fields = /* @__PURE__ */ new Set();
|
|
22762
22762
|
value.forEach((candidate, index) => {
|
|
22763
|
-
const itemPath = `${
|
|
22763
|
+
const itemPath = `${path23}[${index}]`;
|
|
22764
22764
|
if (!isPlainRecord(candidate)) {
|
|
22765
22765
|
issues.push(issue2(itemPath, "INVALID_OUTPUT_BINDING", "binding must be an object"));
|
|
22766
22766
|
return;
|
|
@@ -22780,33 +22780,33 @@ function validateOutputBindings(value, path26, issues) {
|
|
|
22780
22780
|
});
|
|
22781
22781
|
return value;
|
|
22782
22782
|
}
|
|
22783
|
-
function validateTransformShape(value,
|
|
22783
|
+
function validateTransformShape(value, path23, issues) {
|
|
22784
22784
|
if (!isPlainRecord(value)) {
|
|
22785
|
-
issues.push(issue2(
|
|
22785
|
+
issues.push(issue2(path23, "INVALID_TRANSFORM", "transform must be an object"));
|
|
22786
22786
|
return false;
|
|
22787
22787
|
}
|
|
22788
|
-
exactKeys(value, ["language", "profile", "expression"],
|
|
22788
|
+
exactKeys(value, ["language", "profile", "expression"], path23, issues);
|
|
22789
22789
|
if (value.language !== A2UI_CARD_TRANSFORM_LANGUAGE) {
|
|
22790
|
-
issues.push(issue2(`${
|
|
22790
|
+
issues.push(issue2(`${path23}.language`, "INVALID_TRANSFORM_LANGUAGE", `language must be ${A2UI_CARD_TRANSFORM_LANGUAGE}`));
|
|
22791
22791
|
}
|
|
22792
22792
|
if (value.profile !== A2UI_CARD_TRANSFORM_PROFILE) {
|
|
22793
|
-
issues.push(issue2(`${
|
|
22793
|
+
issues.push(issue2(`${path23}.profile`, "INVALID_TRANSFORM_PROFILE", `profile must be ${A2UI_CARD_TRANSFORM_PROFILE}`));
|
|
22794
22794
|
}
|
|
22795
22795
|
if (typeof value.expression !== "string" || value.expression.trim().length === 0) {
|
|
22796
|
-
issues.push(issue2(`${
|
|
22796
|
+
issues.push(issue2(`${path23}.expression`, "INVALID_TRANSFORM_EXPRESSION", "expression must be a non-empty string"));
|
|
22797
22797
|
} else if (value.expression.length > A2UI_CARD_EXPRESSION_MAX_LENGTH) {
|
|
22798
|
-
issues.push(issue2(`${
|
|
22798
|
+
issues.push(issue2(`${path23}.expression`, "TRANSFORM_EXPRESSION_TOO_LONG", `expression exceeds ${A2UI_CARD_EXPRESSION_MAX_LENGTH} characters`));
|
|
22799
22799
|
}
|
|
22800
22800
|
return true;
|
|
22801
22801
|
}
|
|
22802
|
-
function validateProtocol(value,
|
|
22802
|
+
function validateProtocol(value, path23, issues) {
|
|
22803
22803
|
if (!Array.isArray(value) || value.length === 0) {
|
|
22804
|
-
issues.push(issue2(
|
|
22804
|
+
issues.push(issue2(path23, "INVALID_A2UI_PROTOCOL", "card must be a non-empty array"));
|
|
22805
22805
|
return void 0;
|
|
22806
22806
|
}
|
|
22807
22807
|
const issueCountBeforeValidation = issues.length;
|
|
22808
22808
|
value.forEach((message, messageIndex) => {
|
|
22809
|
-
const messagePath = `${
|
|
22809
|
+
const messagePath = `${path23}[${messageIndex}]`;
|
|
22810
22810
|
if (!isPlainRecord(message)) {
|
|
22811
22811
|
issues.push(issue2(messagePath, "INVALID_A2UI_MESSAGE", "A2UI message must be an object"));
|
|
22812
22812
|
return;
|
|
@@ -22835,7 +22835,7 @@ function validateProtocol(value, path26, issues) {
|
|
|
22835
22835
|
return void 0;
|
|
22836
22836
|
return value;
|
|
22837
22837
|
}
|
|
22838
|
-
function validateInstructionShape(instruction,
|
|
22838
|
+
function validateInstructionShape(instruction, path23, issues) {
|
|
22839
22839
|
const knownKeys = [
|
|
22840
22840
|
"createSurface",
|
|
22841
22841
|
"updateComponents",
|
|
@@ -22844,31 +22844,31 @@ function validateInstructionShape(instruction, path26, issues) {
|
|
|
22844
22844
|
"x2DeleteComponent"
|
|
22845
22845
|
].filter((key) => key in instruction);
|
|
22846
22846
|
if (knownKeys.length !== 1) {
|
|
22847
|
-
issues.push(issue2(
|
|
22847
|
+
issues.push(issue2(path23, "INVALID_A2UI_INSTRUCTION", "instruction must contain exactly one supported operation"));
|
|
22848
22848
|
return;
|
|
22849
22849
|
}
|
|
22850
22850
|
const operation = knownKeys[0];
|
|
22851
22851
|
const payload = instruction[operation];
|
|
22852
22852
|
if (!isPlainRecord(payload)) {
|
|
22853
|
-
issues.push(issue2(`${
|
|
22853
|
+
issues.push(issue2(`${path23}.${operation}`, "INVALID_A2UI_INSTRUCTION_PAYLOAD", `${operation} must be an object`));
|
|
22854
22854
|
return;
|
|
22855
22855
|
}
|
|
22856
22856
|
if (!isSafeIdentifier(payload.surfaceId)) {
|
|
22857
|
-
issues.push(issue2(`${
|
|
22857
|
+
issues.push(issue2(`${path23}.${operation}.surfaceId`, "INVALID_SURFACE_ID", "surfaceId must be a non-empty safe identifier"));
|
|
22858
22858
|
}
|
|
22859
22859
|
if (operation === "updateComponents") {
|
|
22860
22860
|
if (!Array.isArray(payload.components)) {
|
|
22861
|
-
issues.push(issue2(`${
|
|
22861
|
+
issues.push(issue2(`${path23}.${operation}.components`, "INVALID_A2UI_COMPONENTS", "components must be an array"));
|
|
22862
22862
|
return;
|
|
22863
22863
|
}
|
|
22864
22864
|
payload.components.forEach((component, componentIndex) => {
|
|
22865
22865
|
if (!isPlainRecord(component) || !isJsonValue(component)) {
|
|
22866
|
-
issues.push(issue2(`${
|
|
22866
|
+
issues.push(issue2(`${path23}.${operation}.components[${componentIndex}]`, "INVALID_A2UI_COMPONENT", "component must be a JSON object"));
|
|
22867
22867
|
}
|
|
22868
22868
|
});
|
|
22869
22869
|
}
|
|
22870
22870
|
if (operation === "x2DeleteComponent" && !isSafeIdentifier(payload.componentId)) {
|
|
22871
|
-
issues.push(issue2(`${
|
|
22871
|
+
issues.push(issue2(`${path23}.${operation}.componentId`, "INVALID_COMPONENT_ID", "componentId must be a non-empty safe identifier"));
|
|
22872
22872
|
}
|
|
22873
22873
|
}
|
|
22874
22874
|
function validateTemplate(value, fields, issues) {
|
|
@@ -22894,8 +22894,8 @@ function validateTemplate(value, fields, issues) {
|
|
|
22894
22894
|
}
|
|
22895
22895
|
return void 0;
|
|
22896
22896
|
}
|
|
22897
|
-
function validateLooseJsonSchema(value,
|
|
22898
|
-
const schemaIssues = getJsonSchemaIssues(value,
|
|
22897
|
+
function validateLooseJsonSchema(value, path23, issues) {
|
|
22898
|
+
const schemaIssues = getJsonSchemaIssues(value, path23, {
|
|
22899
22899
|
allowMissingType: true
|
|
22900
22900
|
});
|
|
22901
22901
|
issues.push(...schemaIssues);
|
|
@@ -22917,14 +22917,14 @@ function validateResolverCoverage(fields, resolver, issues, card) {
|
|
|
22917
22917
|
}
|
|
22918
22918
|
}
|
|
22919
22919
|
}
|
|
22920
|
-
function requiredString(value,
|
|
22920
|
+
function requiredString(value, path23, issues) {
|
|
22921
22921
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
22922
|
-
issues.push(issue2(
|
|
22922
|
+
issues.push(issue2(path23, "REQUIRED_STRING", `${path23} must be a non-empty string`));
|
|
22923
22923
|
}
|
|
22924
22924
|
}
|
|
22925
|
-
function optionalString(value,
|
|
22925
|
+
function optionalString(value, path23, issues) {
|
|
22926
22926
|
if (value !== void 0 && typeof value !== "string") {
|
|
22927
|
-
issues.push(issue2(
|
|
22927
|
+
issues.push(issue2(path23, "INVALID_STRING", `${path23} must be a string`));
|
|
22928
22928
|
}
|
|
22929
22929
|
}
|
|
22930
22930
|
|
|
@@ -23565,8 +23565,8 @@ function isSafePageUrl2(url2) {
|
|
|
23565
23565
|
tokenCount++;
|
|
23566
23566
|
if (tokenCount > 32)
|
|
23567
23567
|
return false;
|
|
23568
|
-
const
|
|
23569
|
-
if (!(
|
|
23568
|
+
const path23 = match[1]?.trim() ?? "";
|
|
23569
|
+
if (!(path23 === "/" || path23.startsWith("/") || path23.startsWith("./")) || path23.split("/").some((part) => ["..", "__proto__", "constructor", "prototype"].includes(part))) {
|
|
23570
23570
|
return false;
|
|
23571
23571
|
}
|
|
23572
23572
|
}
|
|
@@ -23974,21 +23974,7 @@ var ETelemetryEventName;
|
|
|
23974
23974
|
ETelemetryEventName2["HISTORY_APPEND_FINISHED"] = "linkque.history.append.finished";
|
|
23975
23975
|
ETelemetryEventName2["HOOK_DRAIN_STARTED"] = "linkque.hook.drain.started";
|
|
23976
23976
|
ETelemetryEventName2["HOOK_DRAIN_FINISHED"] = "linkque.hook.drain.finished";
|
|
23977
|
-
ETelemetryEventName2["DEBUG_CONTENT_RECORDED"] = "linkque.debug.content.recorded";
|
|
23978
23977
|
})(ETelemetryEventName || (ETelemetryEventName = {}));
|
|
23979
|
-
var ETelemetryContentSection;
|
|
23980
|
-
(function(ETelemetryContentSection2) {
|
|
23981
|
-
ETelemetryContentSection2["QUERY_INPUT"] = "query.input";
|
|
23982
|
-
ETelemetryContentSection2["TOOL_INPUT"] = "tool.input";
|
|
23983
|
-
ETelemetryContentSection2["TOOL_OUTPUT"] = "tool.output";
|
|
23984
|
-
ETelemetryContentSection2["MCP_REQUESTED_INPUT"] = "mcp.requested_input";
|
|
23985
|
-
ETelemetryContentSection2["MCP_INPUT"] = "mcp.input";
|
|
23986
|
-
ETelemetryContentSection2["MCP_OUTPUT"] = "mcp.output";
|
|
23987
|
-
ETelemetryContentSection2["SKILL_INPUT"] = "skill.input";
|
|
23988
|
-
ETelemetryContentSection2["SKILL_OUTPUT"] = "skill.output";
|
|
23989
|
-
ETelemetryContentSection2["KNOWLEDGE_INPUT"] = "knowledge.input";
|
|
23990
|
-
ETelemetryContentSection2["KNOWLEDGE_OUTPUT"] = "knowledge.output";
|
|
23991
|
-
})(ETelemetryContentSection || (ETelemetryContentSection = {}));
|
|
23992
23978
|
var ETelemetryOperationName;
|
|
23993
23979
|
(function(ETelemetryOperationName2) {
|
|
23994
23980
|
ETelemetryOperationName2["OPERATION"] = "linkque.operation";
|
|
@@ -24710,8 +24696,8 @@ function getErrorMap() {
|
|
|
24710
24696
|
|
|
24711
24697
|
// ../../node_modules/zod/v3/helpers/parseUtil.js
|
|
24712
24698
|
var makeIssue = (params) => {
|
|
24713
|
-
const { data, path:
|
|
24714
|
-
const fullPath = [...
|
|
24699
|
+
const { data, path: path23, errorMaps, issueData } = params;
|
|
24700
|
+
const fullPath = [...path23, ...issueData.path || []];
|
|
24715
24701
|
const fullIssue = {
|
|
24716
24702
|
...issueData,
|
|
24717
24703
|
path: fullPath
|
|
@@ -24827,11 +24813,11 @@ var errorUtil;
|
|
|
24827
24813
|
|
|
24828
24814
|
// ../../node_modules/zod/v3/types.js
|
|
24829
24815
|
var ParseInputLazyPath = class {
|
|
24830
|
-
constructor(parent, value,
|
|
24816
|
+
constructor(parent, value, path23, key) {
|
|
24831
24817
|
this._cachedPath = [];
|
|
24832
24818
|
this.parent = parent;
|
|
24833
24819
|
this.data = value;
|
|
24834
|
-
this._path =
|
|
24820
|
+
this._path = path23;
|
|
24835
24821
|
this._key = key;
|
|
24836
24822
|
}
|
|
24837
24823
|
get path() {
|
|
@@ -28469,10 +28455,10 @@ function assignProp(target, prop, value) {
|
|
|
28469
28455
|
configurable: true
|
|
28470
28456
|
});
|
|
28471
28457
|
}
|
|
28472
|
-
function getElementAtPath(obj,
|
|
28473
|
-
if (!
|
|
28458
|
+
function getElementAtPath(obj, path23) {
|
|
28459
|
+
if (!path23)
|
|
28474
28460
|
return obj;
|
|
28475
|
-
return
|
|
28461
|
+
return path23.reduce((acc, key) => acc?.[key], obj);
|
|
28476
28462
|
}
|
|
28477
28463
|
function promiseAllObject(promisesObj) {
|
|
28478
28464
|
const keys = Object.keys(promisesObj);
|
|
@@ -28792,11 +28778,11 @@ function aborted(x, startIndex = 0) {
|
|
|
28792
28778
|
}
|
|
28793
28779
|
return false;
|
|
28794
28780
|
}
|
|
28795
|
-
function prefixIssues(
|
|
28781
|
+
function prefixIssues(path23, issues) {
|
|
28796
28782
|
return issues.map((iss) => {
|
|
28797
28783
|
var _a;
|
|
28798
28784
|
(_a = iss).path ?? (_a.path = []);
|
|
28799
|
-
iss.path.unshift(
|
|
28785
|
+
iss.path.unshift(path23);
|
|
28800
28786
|
return iss;
|
|
28801
28787
|
});
|
|
28802
28788
|
}
|
|
@@ -36028,9 +36014,28 @@ var SANDBOX_RUNTIME_CONFIG_DEFAULTS = Object.freeze({
|
|
|
36028
36014
|
LINKQUEGW_TELEMETRY_LOGS_ENDPOINT: `${LINKQUE_ENDPOINT_PROD}/api/telemetry/v1/logs`,
|
|
36029
36015
|
LINKQUEGW_TELEMETRY_TRACES_ENDPOINT: `${LINKQUE_ENDPOINT_PROD}/api/telemetry/v1/traces`
|
|
36030
36016
|
});
|
|
36017
|
+
function resolveTokenVerifyDefault(env) {
|
|
36018
|
+
const signEndpoint = env.LINKQUE_MCP_SIGN_ENDPOINT?.trim() || SANDBOX_RUNTIME_CONFIG_DEFAULTS.LINKQUE_MCP_SIGN_ENDPOINT;
|
|
36019
|
+
switch (signEndpoint) {
|
|
36020
|
+
case "https://linkquegw.alipay.com/api/mcp/signature":
|
|
36021
|
+
return "https://linkquegw.alipay.com/api/auth/verify";
|
|
36022
|
+
case "https://linkquegw-pre.alipay.com/api/mcp/signature":
|
|
36023
|
+
return "https://linkquegw-pre.alipay.com/api/auth/verify";
|
|
36024
|
+
default:
|
|
36025
|
+
return "";
|
|
36026
|
+
}
|
|
36027
|
+
}
|
|
36031
36028
|
var SandboxRuntimeConfigProvider = class extends RuntimeConfigProvider {
|
|
36032
36029
|
constructor(env = process.env) {
|
|
36033
|
-
super(env,
|
|
36030
|
+
super(env, {
|
|
36031
|
+
...SANDBOX_RUNTIME_CONFIG_DEFAULTS,
|
|
36032
|
+
LINKQUEGW_TOKEN_VERIFY_ENDPOINT: resolveTokenVerifyDefault(env)
|
|
36033
|
+
});
|
|
36034
|
+
}
|
|
36035
|
+
getSource(name) {
|
|
36036
|
+
if (name === "LINKQUEGW_TOKEN_VERIFY_ENDPOINT" && !this.get(name))
|
|
36037
|
+
return "unset";
|
|
36038
|
+
return super.getSource(name);
|
|
36034
36039
|
}
|
|
36035
36040
|
};
|
|
36036
36041
|
|
|
@@ -42124,755 +42129,6 @@ var SourceArchiveExtractor = class {
|
|
|
42124
42129
|
};
|
|
42125
42130
|
var unzipArchive = (cwd, input, output) => new SourceArchiveExtractor(cwd, input, output).extract();
|
|
42126
42131
|
|
|
42127
|
-
// src/commands/runs/listScanner.ts
|
|
42128
|
-
var import_node_path12 = __toESM(require("node:path"));
|
|
42129
|
-
|
|
42130
|
-
// ../linkque-agent-runtime-trace/dist/esm/utils.js
|
|
42131
|
-
var decodeAnyValue = (value) => {
|
|
42132
|
-
if (!value)
|
|
42133
|
-
return void 0;
|
|
42134
|
-
if (value.stringValue !== void 0)
|
|
42135
|
-
return value.stringValue;
|
|
42136
|
-
if (value.intValue !== void 0)
|
|
42137
|
-
return Number(value.intValue);
|
|
42138
|
-
if (value.doubleValue !== void 0)
|
|
42139
|
-
return value.doubleValue;
|
|
42140
|
-
if (value.boolValue !== void 0)
|
|
42141
|
-
return value.boolValue;
|
|
42142
|
-
if (value.bytesValue !== void 0)
|
|
42143
|
-
return { __otlpBytes: true, base64: value.bytesValue };
|
|
42144
|
-
if (value.arrayValue)
|
|
42145
|
-
return value.arrayValue.values.map((child) => decodeAnyValue(child));
|
|
42146
|
-
if (value.kvlistValue) {
|
|
42147
|
-
const record2 = {};
|
|
42148
|
-
for (const { key, value: child } of value.kvlistValue.values)
|
|
42149
|
-
record2[key] = decodeAnyValue(child);
|
|
42150
|
-
return record2;
|
|
42151
|
-
}
|
|
42152
|
-
return void 0;
|
|
42153
|
-
};
|
|
42154
|
-
var decodeAttributes = (attrs) => {
|
|
42155
|
-
const out = {};
|
|
42156
|
-
if (!Array.isArray(attrs))
|
|
42157
|
-
return out;
|
|
42158
|
-
for (const { key, value } of attrs) {
|
|
42159
|
-
const decoded = decodeAnyValue(value);
|
|
42160
|
-
if (decoded !== void 0)
|
|
42161
|
-
out[key] = decoded;
|
|
42162
|
-
}
|
|
42163
|
-
return out;
|
|
42164
|
-
};
|
|
42165
|
-
var nanoToMs = (nano) => {
|
|
42166
|
-
if (!nano || !/^[0-9]+$/.test(nano))
|
|
42167
|
-
return void 0;
|
|
42168
|
-
try {
|
|
42169
|
-
return Number(BigInt(nano) / 1000000n);
|
|
42170
|
-
} catch {
|
|
42171
|
-
return void 0;
|
|
42172
|
-
}
|
|
42173
|
-
};
|
|
42174
|
-
|
|
42175
|
-
// ../linkque-agent-runtime-trace/dist/esm/decode.js
|
|
42176
|
-
var strAttr = (attrs, key) => {
|
|
42177
|
-
const value = attrs[key];
|
|
42178
|
-
return typeof value === "string" && value !== "" ? value : void 0;
|
|
42179
|
-
};
|
|
42180
|
-
var identityFromAttributes = (source, attrs, span) => {
|
|
42181
|
-
return Object.freeze({
|
|
42182
|
-
source,
|
|
42183
|
-
threadId: strAttr(attrs, ETelemetryAttribute.LINKQUE_CONVERSATION_ID),
|
|
42184
|
-
runId: strAttr(attrs, ETelemetryAttribute.LINKQUE_RUN_ID),
|
|
42185
|
-
advanceId: strAttr(attrs, ETelemetryAttribute.HARNESS_ADVANCE_ID),
|
|
42186
|
-
operationId: strAttr(attrs, ETelemetryAttribute.LINKQUE_OPERATION_ID),
|
|
42187
|
-
recordId: strAttr(attrs, ETelemetryAttribute.HARNESS_RECORD_ID),
|
|
42188
|
-
invocationId: strAttr(attrs, ETelemetryAttribute.HARNESS_INVOCATION_ID),
|
|
42189
|
-
traceId: span?.traceId,
|
|
42190
|
-
spanId: span?.spanId
|
|
42191
|
-
});
|
|
42192
|
-
};
|
|
42193
|
-
var decodeLogRecord = (source, record2, byteRange, push) => {
|
|
42194
|
-
const attributes = decodeAttributes(record2.attributes);
|
|
42195
|
-
const rawName = record2.eventName ?? record2.name;
|
|
42196
|
-
const name = typeof rawName === "string" && rawName ? rawName : void 0;
|
|
42197
|
-
const identity = identityFromAttributes(source, attributes);
|
|
42198
|
-
const startedAt = nanoToMs(record2.timeUnixNano);
|
|
42199
|
-
const outcome = strAttr(attributes, ETelemetryAttribute.HARNESS_OPERATION_OUTCOME);
|
|
42200
|
-
const body = record2.body !== void 0 ? decodeAnyValue(record2.body) : void 0;
|
|
42201
|
-
push({
|
|
42202
|
-
kind: "event",
|
|
42203
|
-
identity,
|
|
42204
|
-
name,
|
|
42205
|
-
body,
|
|
42206
|
-
attributes: Object.freeze(attributes),
|
|
42207
|
-
startedAt,
|
|
42208
|
-
outcome,
|
|
42209
|
-
byteRange
|
|
42210
|
-
});
|
|
42211
|
-
};
|
|
42212
|
-
var decodeSpan = (source, span, byteRange, push) => {
|
|
42213
|
-
const attributes = decodeAttributes(span.attributes);
|
|
42214
|
-
const spanId = {
|
|
42215
|
-
traceId: span.traceId,
|
|
42216
|
-
spanId: span.spanId
|
|
42217
|
-
};
|
|
42218
|
-
const identity = identityFromAttributes(source, attributes, spanId);
|
|
42219
|
-
const startedAt = nanoToMs(span.startTimeUnixNano);
|
|
42220
|
-
const finishedAt = nanoToMs(span.endTimeUnixNano);
|
|
42221
|
-
const outcome = typeof span.status === "object" && span.status !== null ? String(span.status.code ?? "") : strAttr(attributes, ETelemetryAttribute.HARNESS_OPERATION_OUTCOME);
|
|
42222
|
-
push({
|
|
42223
|
-
kind: "span",
|
|
42224
|
-
identity,
|
|
42225
|
-
name: typeof span.name === "string" ? span.name : void 0,
|
|
42226
|
-
attributes: Object.freeze(attributes),
|
|
42227
|
-
startedAt,
|
|
42228
|
-
finishedAt,
|
|
42229
|
-
outcome: outcome === "" ? void 0 : outcome,
|
|
42230
|
-
byteRange
|
|
42231
|
-
});
|
|
42232
|
-
const events = span.events;
|
|
42233
|
-
if (Array.isArray(events)) {
|
|
42234
|
-
for (const event of events) {
|
|
42235
|
-
const eventAttributes = decodeAttributes(event.attributes);
|
|
42236
|
-
push({
|
|
42237
|
-
kind: "span-event",
|
|
42238
|
-
identity: identityFromAttributes(source, eventAttributes, spanId),
|
|
42239
|
-
name: event.name,
|
|
42240
|
-
attributes: Object.freeze(eventAttributes),
|
|
42241
|
-
startedAt: nanoToMs(event.timeUnixNano),
|
|
42242
|
-
byteRange
|
|
42243
|
-
});
|
|
42244
|
-
}
|
|
42245
|
-
}
|
|
42246
|
-
};
|
|
42247
|
-
function decodeOtlpLine(line, source, byteRange) {
|
|
42248
|
-
const warnings = [];
|
|
42249
|
-
let json;
|
|
42250
|
-
try {
|
|
42251
|
-
json = JSON.parse(typeof line === "string" ? line : line.toString("utf8"));
|
|
42252
|
-
} catch {
|
|
42253
|
-
return { facts: [], warnings: ["json_parse_failed"] };
|
|
42254
|
-
}
|
|
42255
|
-
if (!json || typeof json !== "object") {
|
|
42256
|
-
return { facts: [], warnings: ["not_an_object"] };
|
|
42257
|
-
}
|
|
42258
|
-
const root = json;
|
|
42259
|
-
const facts = [];
|
|
42260
|
-
const push = (fact) => {
|
|
42261
|
-
facts.push(fact);
|
|
42262
|
-
};
|
|
42263
|
-
if (source === "logs") {
|
|
42264
|
-
const resourceLogs = root.resourceLogs;
|
|
42265
|
-
if (Array.isArray(resourceLogs)) {
|
|
42266
|
-
for (const entry of resourceLogs) {
|
|
42267
|
-
if (!entry || typeof entry !== "object")
|
|
42268
|
-
continue;
|
|
42269
|
-
for (const scope of entry.scopeLogs ?? []) {
|
|
42270
|
-
if (!scope || typeof scope !== "object")
|
|
42271
|
-
continue;
|
|
42272
|
-
for (const record2 of scope.logRecords ?? [])
|
|
42273
|
-
decodeLogRecord(source, record2, byteRange, push);
|
|
42274
|
-
}
|
|
42275
|
-
}
|
|
42276
|
-
} else {
|
|
42277
|
-
warnings.push("logs_without_resourceLogs");
|
|
42278
|
-
}
|
|
42279
|
-
return { facts, warnings };
|
|
42280
|
-
}
|
|
42281
|
-
const resourceSpans = root.resourceSpans;
|
|
42282
|
-
if (Array.isArray(resourceSpans)) {
|
|
42283
|
-
for (const entry of resourceSpans) {
|
|
42284
|
-
if (!entry || typeof entry !== "object")
|
|
42285
|
-
continue;
|
|
42286
|
-
for (const scope of entry.scopeSpans ?? []) {
|
|
42287
|
-
if (!scope || typeof scope !== "object")
|
|
42288
|
-
continue;
|
|
42289
|
-
for (const span of scope.spans ?? [])
|
|
42290
|
-
decodeSpan(source, span, byteRange, push);
|
|
42291
|
-
}
|
|
42292
|
-
}
|
|
42293
|
-
} else {
|
|
42294
|
-
warnings.push("traces_without_resourceSpans");
|
|
42295
|
-
}
|
|
42296
|
-
return { facts, warnings };
|
|
42297
|
-
}
|
|
42298
|
-
|
|
42299
|
-
// ../linkque-agent-runtime-trace/dist/esm/summarize.js
|
|
42300
|
-
var dedupKey = (advanceId, suffix) => `${advanceId ?? ""}
|
|
42301
|
-
${suffix ?? ""}`;
|
|
42302
|
-
var extractQueryInput = (facts) => {
|
|
42303
|
-
for (const fact of facts) {
|
|
42304
|
-
if (fact.name !== ETelemetryEventName.DEBUG_CONTENT_RECORDED)
|
|
42305
|
-
continue;
|
|
42306
|
-
const body = fact.body;
|
|
42307
|
-
if (!body || body.section !== ETelemetryContentSection.QUERY_INPUT)
|
|
42308
|
-
continue;
|
|
42309
|
-
const text = typeof body.value === "string" ? body.value : void 0;
|
|
42310
|
-
const availability = body.availability === "available" ? "available" : body.availability === "partial" ? "partial" : "not_recorded";
|
|
42311
|
-
return { text, availability };
|
|
42312
|
-
}
|
|
42313
|
-
return { availability: "not_recorded" };
|
|
42314
|
-
};
|
|
42315
|
-
var buildOperations = (facts) => {
|
|
42316
|
-
const byOp = /* @__PURE__ */ new Map();
|
|
42317
|
-
const relations = [];
|
|
42318
|
-
const seenRelations = /* @__PURE__ */ new Set();
|
|
42319
|
-
for (const fact of facts) {
|
|
42320
|
-
const { operationId } = fact.identity;
|
|
42321
|
-
if (!operationId)
|
|
42322
|
-
continue;
|
|
42323
|
-
const key = dedupKey(fact.identity.advanceId, operationId);
|
|
42324
|
-
const existing = byOp.get(key);
|
|
42325
|
-
const attrs = fact.attributes;
|
|
42326
|
-
const parentOpId = attrs[ETelemetryAttribute.LINKQUE_OPERATION_PARENT_ID];
|
|
42327
|
-
const logicalId = void 0;
|
|
42328
|
-
const kind = fact.kind;
|
|
42329
|
-
if (!existing) {
|
|
42330
|
-
byOp.set(key, {
|
|
42331
|
-
operationId,
|
|
42332
|
-
operationName: fact.name,
|
|
42333
|
-
...logicalId ? { logicalId } : {},
|
|
42334
|
-
kind,
|
|
42335
|
-
...parentOpId ? { parentOperationId: parentOpId } : {},
|
|
42336
|
-
startedAt: fact.startedAt,
|
|
42337
|
-
finishedAt: fact.finishedAt,
|
|
42338
|
-
...fact.startedAt && fact.finishedAt ? { durationMs: fact.finishedAt - fact.startedAt } : {},
|
|
42339
|
-
outcome: fact.outcome,
|
|
42340
|
-
attributes: fact.attributes
|
|
42341
|
-
});
|
|
42342
|
-
} else {
|
|
42343
|
-
const updated = { ...existing };
|
|
42344
|
-
if (!updated.operationName && fact.name)
|
|
42345
|
-
updated.operationName = fact.name;
|
|
42346
|
-
if (updated.startedAt === void 0 && fact.startedAt !== void 0)
|
|
42347
|
-
updated.startedAt = fact.startedAt;
|
|
42348
|
-
if (!updated.finishedAt && fact.finishedAt)
|
|
42349
|
-
updated.finishedAt = fact.finishedAt;
|
|
42350
|
-
if (updated.startedAt !== void 0 && updated.finishedAt !== void 0)
|
|
42351
|
-
updated.durationMs = updated.finishedAt - updated.startedAt;
|
|
42352
|
-
if (!updated.outcome && fact.outcome)
|
|
42353
|
-
updated.outcome = fact.outcome;
|
|
42354
|
-
byOp.set(key, updated);
|
|
42355
|
-
}
|
|
42356
|
-
if (parentOpId) {
|
|
42357
|
-
const relKey = `${parentOpId}
|
|
42358
|
-
${operationId}
|
|
42359
|
-
parent`;
|
|
42360
|
-
if (!seenRelations.has(relKey)) {
|
|
42361
|
-
seenRelations.add(relKey);
|
|
42362
|
-
relations.push({
|
|
42363
|
-
fromOperationId: parentOpId,
|
|
42364
|
-
toOperationId: operationId,
|
|
42365
|
-
relation: "parent"
|
|
42366
|
-
});
|
|
42367
|
-
}
|
|
42368
|
-
}
|
|
42369
|
-
}
|
|
42370
|
-
return { operations: [...byOp.values()], relations };
|
|
42371
|
-
};
|
|
42372
|
-
var buildUsage = (facts) => {
|
|
42373
|
-
const byInv = /* @__PURE__ */ new Map();
|
|
42374
|
-
for (const fact of facts) {
|
|
42375
|
-
const { invocationId } = fact.identity;
|
|
42376
|
-
if (!invocationId)
|
|
42377
|
-
continue;
|
|
42378
|
-
const key = dedupKey(fact.identity.advanceId, invocationId);
|
|
42379
|
-
const attrs = fact.attributes;
|
|
42380
|
-
const inputTokens = attrs["gen_ai.usage.input_tokens"];
|
|
42381
|
-
const outputTokens = attrs["gen_ai.usage.output_tokens"];
|
|
42382
|
-
const totalTokens = attrs["gen_ai.usage.total_tokens"];
|
|
42383
|
-
const model = attrs["gen_ai.request.model"];
|
|
42384
|
-
const finishReason = attrs[ETelemetryAttribute.GEN_AI_RESPONSE_FINISH_REASONS];
|
|
42385
|
-
const existing = byInv.get(key);
|
|
42386
|
-
if (!existing) {
|
|
42387
|
-
byInv.set(key, {
|
|
42388
|
-
invocationId,
|
|
42389
|
-
...model ? { model } : {},
|
|
42390
|
-
...inputTokens !== void 0 ? { inputTokens } : {},
|
|
42391
|
-
...outputTokens !== void 0 ? { outputTokens } : {},
|
|
42392
|
-
...totalTokens !== void 0 ? { totalTokens } : {},
|
|
42393
|
-
...finishReason ? { finishReason } : {},
|
|
42394
|
-
coverage: "available"
|
|
42395
|
-
});
|
|
42396
|
-
} else {
|
|
42397
|
-
byInv.set(key, {
|
|
42398
|
-
...existing,
|
|
42399
|
-
...existing.inputTokens === void 0 && inputTokens !== void 0 ? { inputTokens } : {},
|
|
42400
|
-
...existing.outputTokens === void 0 && outputTokens !== void 0 ? { outputTokens } : {},
|
|
42401
|
-
...existing.totalTokens === void 0 && totalTokens !== void 0 ? { totalTokens } : {},
|
|
42402
|
-
...existing.model === void 0 && model !== void 0 ? { model } : {},
|
|
42403
|
-
...existing.finishReason === void 0 && finishReason !== void 0 ? { finishReason } : {}
|
|
42404
|
-
});
|
|
42405
|
-
}
|
|
42406
|
-
}
|
|
42407
|
-
const reports = [...byInv.values()];
|
|
42408
|
-
const summary = {
|
|
42409
|
-
inputTokens: reports.reduce((sum, r2) => sum + (r2.inputTokens ?? 0), 0) || void 0,
|
|
42410
|
-
outputTokens: reports.reduce((sum, r2) => sum + (r2.outputTokens ?? 0), 0) || void 0,
|
|
42411
|
-
totalTokens: reports.reduce((sum, r2) => sum + (r2.totalTokens ?? 0), 0) || void 0,
|
|
42412
|
-
coverage: reports.length === 0 ? "not_recorded" : "available"
|
|
42413
|
-
};
|
|
42414
|
-
return { reports, summary };
|
|
42415
|
-
};
|
|
42416
|
-
var buildContentDescriptors = (facts) => {
|
|
42417
|
-
const byKey = /* @__PURE__ */ new Map();
|
|
42418
|
-
for (const fact of facts) {
|
|
42419
|
-
if (fact.name !== ETelemetryEventName.DEBUG_CONTENT_RECORDED)
|
|
42420
|
-
continue;
|
|
42421
|
-
const body = fact.body;
|
|
42422
|
-
if (!body?.section)
|
|
42423
|
-
continue;
|
|
42424
|
-
const { operationId, recordId, advanceId } = fact.identity;
|
|
42425
|
-
const dedup = `${advanceId ?? ""}
|
|
42426
|
-
${recordId ?? ""}
|
|
42427
|
-
${body.section}`;
|
|
42428
|
-
if (byKey.has(dedup))
|
|
42429
|
-
continue;
|
|
42430
|
-
const contentRef = {
|
|
42431
|
-
...advanceId ? { advanceId } : {},
|
|
42432
|
-
...operationId ? { operationId } : {},
|
|
42433
|
-
...recordId ? { recordId } : {},
|
|
42434
|
-
section: body.section
|
|
42435
|
-
};
|
|
42436
|
-
byKey.set(dedup, {
|
|
42437
|
-
...operationId ? { operationId } : {},
|
|
42438
|
-
section: body.section,
|
|
42439
|
-
contentRef,
|
|
42440
|
-
availability: body.availability === "available" ? "available" : body.availability === "partial" ? "partial" : "not_recorded"
|
|
42441
|
-
});
|
|
42442
|
-
}
|
|
42443
|
-
return [...byKey.values()];
|
|
42444
|
-
};
|
|
42445
|
-
var buildDetailRef = (identity) => Buffer.from(JSON.stringify({
|
|
42446
|
-
...identity.threadId ? { threadId: identity.threadId } : {},
|
|
42447
|
-
...identity.runId ? { runId: identity.runId } : {},
|
|
42448
|
-
...identity.advanceId ? { advanceId: identity.advanceId } : {}
|
|
42449
|
-
})).toString("base64");
|
|
42450
|
-
function summarize(input) {
|
|
42451
|
-
const { identity, facts } = input;
|
|
42452
|
-
const query = extractQueryInput(facts);
|
|
42453
|
-
const { operations, relations } = buildOperations(facts);
|
|
42454
|
-
const { reports: usageReports, summary: usageSummary } = buildUsage(facts);
|
|
42455
|
-
const contentDescriptors = buildContentDescriptors(facts);
|
|
42456
|
-
const observation = {
|
|
42457
|
-
terminalObserved: input.observation?.terminalObserved ?? true,
|
|
42458
|
-
sourceExhausted: input.observation?.sourceExhausted ?? true,
|
|
42459
|
-
coverage: facts.length === 0 ? "not_recorded" : "available",
|
|
42460
|
-
warnings: input.observation?.warnings ?? []
|
|
42461
|
-
};
|
|
42462
|
-
return {
|
|
42463
|
-
identity,
|
|
42464
|
-
detailRef: buildDetailRef(identity),
|
|
42465
|
-
query,
|
|
42466
|
-
operations,
|
|
42467
|
-
relations,
|
|
42468
|
-
usageReports,
|
|
42469
|
-
usageSummary,
|
|
42470
|
-
contentDescriptors,
|
|
42471
|
-
observation
|
|
42472
|
-
};
|
|
42473
|
-
}
|
|
42474
|
-
|
|
42475
|
-
// src/commands/runs/types.ts
|
|
42476
|
-
var OTLP_LOG_FILES = {
|
|
42477
|
-
logs: "agent-otlp-logs.log",
|
|
42478
|
-
traces: "agent-oltp-traces.log"
|
|
42479
|
-
};
|
|
42480
|
-
var LOGS_ROOT = ".linkque/logs";
|
|
42481
|
-
var parseDetailRef = (ref) => {
|
|
42482
|
-
try {
|
|
42483
|
-
const decoded = JSON.parse(
|
|
42484
|
-
Buffer.from(ref, "base64").toString("utf8")
|
|
42485
|
-
);
|
|
42486
|
-
if (decoded.advanceId) return decoded;
|
|
42487
|
-
return void 0;
|
|
42488
|
-
} catch {
|
|
42489
|
-
return void 0;
|
|
42490
|
-
}
|
|
42491
|
-
};
|
|
42492
|
-
|
|
42493
|
-
// src/utils/otlpScanner.ts
|
|
42494
|
-
var readLog = async (file) => {
|
|
42495
|
-
try {
|
|
42496
|
-
return await readUtf8IfExists(file) ?? "";
|
|
42497
|
-
} catch {
|
|
42498
|
-
return "";
|
|
42499
|
-
}
|
|
42500
|
-
};
|
|
42501
|
-
var scanFile = (content, source) => {
|
|
42502
|
-
if (!content) return { facts: [], warnings: [] };
|
|
42503
|
-
const facts = [];
|
|
42504
|
-
const warnings = [];
|
|
42505
|
-
for (const line of content.split("\n")) {
|
|
42506
|
-
if (!line) continue;
|
|
42507
|
-
const { facts: lineFacts, warnings: lineWarnings } = decodeOtlpLine(line, source);
|
|
42508
|
-
for (const fact of lineFacts) facts.push(fact);
|
|
42509
|
-
for (const w2 of lineWarnings) warnings.push(w2);
|
|
42510
|
-
}
|
|
42511
|
-
return { facts, warnings };
|
|
42512
|
-
};
|
|
42513
|
-
|
|
42514
|
-
// src/commands/runs/listScanner.ts
|
|
42515
|
-
var isContentRecord = (fact) => fact.name === ETelemetryEventName.DEBUG_CONTENT_RECORDED;
|
|
42516
|
-
var decodeContentBody = (fact) => {
|
|
42517
|
-
const body = fact.body;
|
|
42518
|
-
return body ?? {};
|
|
42519
|
-
};
|
|
42520
|
-
var aggregate = (facts) => {
|
|
42521
|
-
const byRun = /* @__PURE__ */ new Map();
|
|
42522
|
-
for (const fact of facts) {
|
|
42523
|
-
const { threadId, runId } = fact.identity;
|
|
42524
|
-
if (!runId) continue;
|
|
42525
|
-
const key = `${threadId ?? ""}
|
|
42526
|
-
${runId}`;
|
|
42527
|
-
let item = byRun.get(key);
|
|
42528
|
-
if (!item) {
|
|
42529
|
-
item = {
|
|
42530
|
-
runId,
|
|
42531
|
-
...threadId ? { threadId } : {},
|
|
42532
|
-
query: { availability: "not_recorded" }
|
|
42533
|
-
};
|
|
42534
|
-
byRun.set(key, item);
|
|
42535
|
-
}
|
|
42536
|
-
if (fact.startedAt !== void 0) {
|
|
42537
|
-
const cur = item.startedAt;
|
|
42538
|
-
if (cur === void 0 || fact.startedAt < cur) {
|
|
42539
|
-
item.startedAt = fact.startedAt;
|
|
42540
|
-
}
|
|
42541
|
-
}
|
|
42542
|
-
if (isContentRecord(fact)) {
|
|
42543
|
-
const body = decodeContentBody(fact);
|
|
42544
|
-
if (body.section === ETelemetryContentSection.QUERY_INPUT) {
|
|
42545
|
-
const text = typeof body.value === "string" ? body.value : void 0;
|
|
42546
|
-
item.query.text = text;
|
|
42547
|
-
item.query.availability = body.availability === "available" ? "available" : body.availability === "partial" ? "partial" : "not_recorded";
|
|
42548
|
-
}
|
|
42549
|
-
}
|
|
42550
|
-
}
|
|
42551
|
-
return [...byRun.values()];
|
|
42552
|
-
};
|
|
42553
|
-
var scanQueries = async (input) => {
|
|
42554
|
-
const logsPath = import_node_path12.default.join(input.cwd, LOGS_ROOT, OTLP_LOG_FILES.logs);
|
|
42555
|
-
const tracesPath = import_node_path12.default.join(input.cwd, LOGS_ROOT, OTLP_LOG_FILES.traces);
|
|
42556
|
-
const [logsText, tracesText] = await Promise.all([
|
|
42557
|
-
readLog(logsPath),
|
|
42558
|
-
readLog(tracesPath)
|
|
42559
|
-
]);
|
|
42560
|
-
const logsResult = scanFile(logsText, "logs");
|
|
42561
|
-
const tracesResult = scanFile(tracesText, "traces");
|
|
42562
|
-
const facts = [...logsResult.facts, ...tracesResult.facts];
|
|
42563
|
-
const warnings = [...logsResult.warnings, ...tracesResult.warnings];
|
|
42564
|
-
let items = aggregate(facts);
|
|
42565
|
-
if (input.threadId)
|
|
42566
|
-
items = items.filter((item) => item.threadId === input.threadId);
|
|
42567
|
-
items.sort((a, b3) => (b3.startedAt ?? 0) - (a.startedAt ?? 0));
|
|
42568
|
-
const limit = input.limit && input.limit > 0 ? input.limit : items.length;
|
|
42569
|
-
const startIdx = input.cursor ? Number(input.cursor) : 0;
|
|
42570
|
-
const safeStart = Number.isFinite(startIdx) && startIdx >= 0 ? startIdx : 0;
|
|
42571
|
-
const page = items.slice(safeStart, safeStart + limit);
|
|
42572
|
-
const observation = {
|
|
42573
|
-
terminalObserved: true,
|
|
42574
|
-
// 全量扫到底,无活跃态推断
|
|
42575
|
-
sourceExhausted: true,
|
|
42576
|
-
coverage: facts.length === 0 ? "not_recorded" : "available",
|
|
42577
|
-
warnings
|
|
42578
|
-
};
|
|
42579
|
-
const nextIndex = safeStart + page.length;
|
|
42580
|
-
return {
|
|
42581
|
-
items: page,
|
|
42582
|
-
...nextIndex < items.length ? { nextCursor: String(nextIndex) } : {},
|
|
42583
|
-
observation
|
|
42584
|
-
};
|
|
42585
|
-
};
|
|
42586
|
-
|
|
42587
|
-
// src/commands/runs/showScanner.ts
|
|
42588
|
-
var import_node_path13 = __toESM(require("node:path"));
|
|
42589
|
-
var selectLatestAdvance = (facts, threadId, runId) => {
|
|
42590
|
-
const byAdvance = /* @__PURE__ */ new Map();
|
|
42591
|
-
for (const fact of facts) {
|
|
42592
|
-
const { advanceId, threadId: fThreadId, runId: fRunId } = fact.identity;
|
|
42593
|
-
if (!advanceId) continue;
|
|
42594
|
-
if (runId && fRunId !== runId) continue;
|
|
42595
|
-
if (threadId && fThreadId !== threadId) continue;
|
|
42596
|
-
const key = advanceId;
|
|
42597
|
-
let group = byAdvance.get(key);
|
|
42598
|
-
if (!group) {
|
|
42599
|
-
group = {
|
|
42600
|
-
identity: {
|
|
42601
|
-
...fThreadId ? { threadId: fThreadId } : {},
|
|
42602
|
-
...fRunId ? { runId: fRunId } : {},
|
|
42603
|
-
advanceId
|
|
42604
|
-
},
|
|
42605
|
-
facts: [],
|
|
42606
|
-
startedAt: fact.startedAt ?? Number.MAX_SAFE_INTEGER
|
|
42607
|
-
};
|
|
42608
|
-
byAdvance.set(key, group);
|
|
42609
|
-
}
|
|
42610
|
-
group.facts.push(fact);
|
|
42611
|
-
if (fact.startedAt !== void 0 && fact.startedAt < group.startedAt) {
|
|
42612
|
-
group.startedAt = fact.startedAt;
|
|
42613
|
-
}
|
|
42614
|
-
}
|
|
42615
|
-
if (byAdvance.size === 0) return void 0;
|
|
42616
|
-
const byRun = /* @__PURE__ */ new Map();
|
|
42617
|
-
for (const group of byAdvance.values()) {
|
|
42618
|
-
const runKey = `${group.identity.threadId ?? ""}
|
|
42619
|
-
${group.identity.runId ?? ""}`;
|
|
42620
|
-
const existing = byRun.get(runKey);
|
|
42621
|
-
if (!existing || group.startedAt < existing.startedAt) {
|
|
42622
|
-
byRun.set(runKey, { runKey, startedAt: group.startedAt });
|
|
42623
|
-
}
|
|
42624
|
-
}
|
|
42625
|
-
const latestRun = [...byRun.values()].toSorted(
|
|
42626
|
-
(a, b3) => b3.startedAt - a.startedAt
|
|
42627
|
-
)[0];
|
|
42628
|
-
if (!latestRun) return void 0;
|
|
42629
|
-
const sorted = [...byAdvance.values()].filter(
|
|
42630
|
-
(g2) => `${g2.identity.threadId ?? ""}
|
|
42631
|
-
${g2.identity.runId ?? ""}` === latestRun.runKey
|
|
42632
|
-
).toSorted((a, b3) => b3.startedAt - a.startedAt);
|
|
42633
|
-
const latest = sorted[0];
|
|
42634
|
-
return latest ? { identity: latest.identity, facts: latest.facts } : void 0;
|
|
42635
|
-
};
|
|
42636
|
-
var scanExecution = async (input) => {
|
|
42637
|
-
const logsPath = import_node_path13.default.join(input.cwd, LOGS_ROOT, OTLP_LOG_FILES.logs);
|
|
42638
|
-
const tracesPath = import_node_path13.default.join(input.cwd, LOGS_ROOT, OTLP_LOG_FILES.traces);
|
|
42639
|
-
const [logsText, tracesText] = await Promise.all([
|
|
42640
|
-
readLog(logsPath),
|
|
42641
|
-
readLog(tracesPath)
|
|
42642
|
-
]);
|
|
42643
|
-
const logsResult = scanFile(logsText, "logs");
|
|
42644
|
-
const tracesResult = scanFile(tracesText, "traces");
|
|
42645
|
-
const facts = [...logsResult.facts, ...tracesResult.facts];
|
|
42646
|
-
const warnings = [...logsResult.warnings, ...tracesResult.warnings];
|
|
42647
|
-
if (input.detailRef) {
|
|
42648
|
-
const identity = parseDetailRef(input.detailRef);
|
|
42649
|
-
if (!identity) return null;
|
|
42650
|
-
const filtered = facts.filter(
|
|
42651
|
-
(f3) => (!identity.threadId || !f3.identity.threadId || f3.identity.threadId === identity.threadId) && (!identity.advanceId || f3.identity.advanceId === identity.advanceId) && (!identity.runId || !f3.identity.runId || f3.identity.runId === identity.runId)
|
|
42652
|
-
);
|
|
42653
|
-
return summarize({
|
|
42654
|
-
identity,
|
|
42655
|
-
facts: filtered,
|
|
42656
|
-
observation: { warnings }
|
|
42657
|
-
});
|
|
42658
|
-
}
|
|
42659
|
-
const selected = selectLatestAdvance(facts, input.threadId, input.runId);
|
|
42660
|
-
if (!selected) return null;
|
|
42661
|
-
return summarize({ ...selected, observation: { warnings } });
|
|
42662
|
-
};
|
|
42663
|
-
|
|
42664
|
-
// src/commands/runs/contentScanner.ts
|
|
42665
|
-
var import_node_path14 = __toESM(require("node:path"));
|
|
42666
|
-
var matchContentRef = (fact, ref) => {
|
|
42667
|
-
const { advanceId, operationId, recordId, section } = ref;
|
|
42668
|
-
if (advanceId && fact.identity.advanceId !== advanceId) return false;
|
|
42669
|
-
if (operationId && fact.identity.operationId !== operationId) return false;
|
|
42670
|
-
if (recordId && fact.identity.recordId !== recordId) return false;
|
|
42671
|
-
const body = fact.body;
|
|
42672
|
-
return body?.section === section;
|
|
42673
|
-
};
|
|
42674
|
-
var scanContent = async (input) => {
|
|
42675
|
-
const identity = parseDetailRef(input.detailRef);
|
|
42676
|
-
if (!identity) return null;
|
|
42677
|
-
let contentRef;
|
|
42678
|
-
try {
|
|
42679
|
-
contentRef = JSON.parse(
|
|
42680
|
-
Buffer.from(input.contentRef, "base64").toString("utf8")
|
|
42681
|
-
);
|
|
42682
|
-
} catch {
|
|
42683
|
-
return null;
|
|
42684
|
-
}
|
|
42685
|
-
if (!contentRef.section) return null;
|
|
42686
|
-
const logsPath = import_node_path14.default.join(input.cwd, LOGS_ROOT, OTLP_LOG_FILES.logs);
|
|
42687
|
-
const tracesPath = import_node_path14.default.join(input.cwd, LOGS_ROOT, OTLP_LOG_FILES.traces);
|
|
42688
|
-
const [logsText, tracesText] = await Promise.all([
|
|
42689
|
-
readLog(logsPath),
|
|
42690
|
-
readLog(tracesPath)
|
|
42691
|
-
]);
|
|
42692
|
-
const facts = [
|
|
42693
|
-
...scanFile(logsText, "logs").facts,
|
|
42694
|
-
...scanFile(tracesText, "traces").facts
|
|
42695
|
-
];
|
|
42696
|
-
const matched = facts.find(
|
|
42697
|
-
(f3) => f3.name === ETelemetryEventName.DEBUG_CONTENT_RECORDED && (!identity.threadId || !f3.identity.threadId || f3.identity.threadId === identity.threadId) && (!identity.advanceId || f3.identity.advanceId === identity.advanceId) && (!identity.runId || !f3.identity.runId || f3.identity.runId === identity.runId) && matchContentRef(f3, contentRef)
|
|
42698
|
-
);
|
|
42699
|
-
if (!matched) {
|
|
42700
|
-
return {
|
|
42701
|
-
availability: "not_recorded"
|
|
42702
|
-
};
|
|
42703
|
-
}
|
|
42704
|
-
const body = matched.body;
|
|
42705
|
-
const availability = body.availability === "available" ? "available" : body.availability === "partial" ? "partial" : body.availability === "unavailable" ? "unavailable" : "available";
|
|
42706
|
-
const maxBytes = input.maxBytes ?? 1024 * 1024;
|
|
42707
|
-
const serialized = JSON.stringify(body.value);
|
|
42708
|
-
const buf = Buffer.from(serialized, "utf8");
|
|
42709
|
-
const totalBytes = buf.length;
|
|
42710
|
-
const offset = input.cursor ? parseInt(input.cursor, 10) || 0 : 0;
|
|
42711
|
-
if (offset >= totalBytes) {
|
|
42712
|
-
return { availability: "available" };
|
|
42713
|
-
}
|
|
42714
|
-
const remaining = totalBytes - offset;
|
|
42715
|
-
const pageBytes = Math.min(maxBytes, remaining);
|
|
42716
|
-
const isFullContent = offset === 0 && totalBytes <= maxBytes;
|
|
42717
|
-
if (isFullContent) {
|
|
42718
|
-
return {
|
|
42719
|
-
content: body.value,
|
|
42720
|
-
contentType: body.contentType,
|
|
42721
|
-
encoding: body.encoding,
|
|
42722
|
-
availability,
|
|
42723
|
-
...body.originalBytes !== void 0 || body.storedBytes !== void 0 ? {
|
|
42724
|
-
evidence: {
|
|
42725
|
-
...body.originalBytes !== void 0 ? { originalBytes: body.originalBytes } : {},
|
|
42726
|
-
...body.storedBytes !== void 0 ? { storedBytes: body.storedBytes } : {}
|
|
42727
|
-
}
|
|
42728
|
-
} : {}
|
|
42729
|
-
};
|
|
42730
|
-
}
|
|
42731
|
-
let end = offset + pageBytes;
|
|
42732
|
-
while (end > offset && end < totalBytes && (buf[end] & 192) === 128) {
|
|
42733
|
-
end--;
|
|
42734
|
-
}
|
|
42735
|
-
const pageContent = buf.subarray(offset, end).toString("utf8");
|
|
42736
|
-
const nextOffset = end;
|
|
42737
|
-
const hasNext = nextOffset < totalBytes;
|
|
42738
|
-
return {
|
|
42739
|
-
content: pageContent,
|
|
42740
|
-
contentType: "application/json-fragment",
|
|
42741
|
-
encoding: body.encoding,
|
|
42742
|
-
availability: hasNext ? "partial" : availability,
|
|
42743
|
-
nextCursor: hasNext ? String(nextOffset) : void 0,
|
|
42744
|
-
...body.originalBytes !== void 0 || body.storedBytes !== void 0 ? {
|
|
42745
|
-
evidence: {
|
|
42746
|
-
...body.originalBytes !== void 0 ? { originalBytes: body.originalBytes } : {},
|
|
42747
|
-
...body.storedBytes !== void 0 ? { storedBytes: body.storedBytes } : {}
|
|
42748
|
-
}
|
|
42749
|
-
} : {}
|
|
42750
|
-
};
|
|
42751
|
-
};
|
|
42752
|
-
|
|
42753
|
-
// src/commands/runs/index.ts
|
|
42754
|
-
var parseLimit = (value) => {
|
|
42755
|
-
const num = Number(value);
|
|
42756
|
-
if (!Number.isInteger(num) || num < 1 || num > 1e4) {
|
|
42757
|
-
throw new InvalidArgumentError(
|
|
42758
|
-
"--limit \u5FC5\u987B\u4E3A 1~10000 \u4E4B\u95F4\u7684\u6574\u6570"
|
|
42759
|
-
);
|
|
42760
|
-
}
|
|
42761
|
-
return num;
|
|
42762
|
-
};
|
|
42763
|
-
var parseMaxBytes = (value) => {
|
|
42764
|
-
const num = Number(value);
|
|
42765
|
-
if (!Number.isInteger(num) || num < 1 || num > 16 * 1024 * 1024) {
|
|
42766
|
-
throw new InvalidArgumentError(
|
|
42767
|
-
"--max-bytes \u5FC5\u987B\u4E3A 1~16MiB \u4E4B\u95F4\u7684\u6574\u6570"
|
|
42768
|
-
);
|
|
42769
|
-
}
|
|
42770
|
-
return num;
|
|
42771
|
-
};
|
|
42772
|
-
var runsList = {
|
|
42773
|
-
name: "runs.list",
|
|
42774
|
-
description: "\u67E5\u770B\u5F53\u524D\u6C99\u7BB1\u4FDD\u7559\u65E5\u5FD7\u4E2D\u7684\u6700\u8FD1\u6267\u884C\u8BB0\u5F55",
|
|
42775
|
-
options: [
|
|
42776
|
-
{
|
|
42777
|
-
flags: "--thread-id <threadId>",
|
|
42778
|
-
description: "\u6309\u4F1A\u8BDD threadId \u8FC7\u6EE4",
|
|
42779
|
-
key: "threadId"
|
|
42780
|
-
},
|
|
42781
|
-
{
|
|
42782
|
-
flags: "--cursor <cursor>",
|
|
42783
|
-
description: "\u5206\u9875\u6E38\u6807\uFF08\u4E0D\u900F\u660E\uFF0C\u975E\u6587\u4EF6\u504F\u79FB\uFF09",
|
|
42784
|
-
key: "cursor"
|
|
42785
|
-
},
|
|
42786
|
-
{
|
|
42787
|
-
flags: "--limit <limit>",
|
|
42788
|
-
description: "\u6700\u591A\u8FD4\u56DE\u7684\u6267\u884C\u8BB0\u5F55\u6570",
|
|
42789
|
-
key: "limit",
|
|
42790
|
-
parse: parseLimit
|
|
42791
|
-
}
|
|
42792
|
-
],
|
|
42793
|
-
summarize: ({ page }) => `\u5217\u51FA ${page.items.length} \u4E2A\u6267\u884C\u8BB0\u5F55${page.nextCursor ? "\uFF08\u8FD8\u6709\u66F4\u591A\uFF09" : ""}\u3002
|
|
42794
|
-
`,
|
|
42795
|
-
run: (cwd, options) => scanQueries({
|
|
42796
|
-
cwd,
|
|
42797
|
-
threadId: options.threadId,
|
|
42798
|
-
cursor: options.cursor,
|
|
42799
|
-
limit: options.limit
|
|
42800
|
-
}).then((page) => ({ page }))
|
|
42801
|
-
};
|
|
42802
|
-
var runsShow = {
|
|
42803
|
-
name: "runs.show",
|
|
42804
|
-
description: "\u67E5\u770B\u67D0\u6B21\u6267\u884C\u7684\u6700\u65B0 advance \u5FEB\u7167\uFF08\u6216\u901A\u8FC7 detail-ref \u67E5\u770B\u6307\u5B9A\u6267\u884C\uFF09",
|
|
42805
|
-
options: [
|
|
42806
|
-
{
|
|
42807
|
-
flags: "--thread-id <threadId>",
|
|
42808
|
-
description: "\u4F1A\u8BDD threadId\uFF08\u4E0E --run-id \u914D\u5BF9\u4F7F\u7528\uFF09",
|
|
42809
|
-
key: "threadId"
|
|
42810
|
-
},
|
|
42811
|
-
{
|
|
42812
|
-
flags: "--run-id <runId>",
|
|
42813
|
-
description: "\u6267\u884C runId\uFF08\u4E0E --thread-id \u914D\u5BF9\u4F7F\u7528\uFF09",
|
|
42814
|
-
key: "runId"
|
|
42815
|
-
},
|
|
42816
|
-
{
|
|
42817
|
-
flags: "--detail-ref <detailRef>",
|
|
42818
|
-
description: "\u56FA\u5B9A\u6267\u884C\u5F15\u7528\uFF08\u4E0E\u76EE\u6807\u7B5B\u9009\u4E92\u65A5\uFF09",
|
|
42819
|
-
key: "detailRef"
|
|
42820
|
-
}
|
|
42821
|
-
],
|
|
42822
|
-
summarize: ({ snapshot }) => snapshot ? `\u6267\u884C\u5FEB\u7167 ${snapshot.identity.advanceId ?? "(\u672A\u77E5\u6267\u884C)"}\uFF1A${snapshot.operations.length} \u4E2A\u64CD\u4F5C\uFF0C${snapshot.usageReports.length} \u6761\u7528\u91CF\u8BB0\u5F55\u3002
|
|
42823
|
-
` : "\u672A\u627E\u5230\u5BF9\u5E94\u6267\u884C\u7684\u5FEB\u7167\u3002\n",
|
|
42824
|
-
run: async (cwd, options) => {
|
|
42825
|
-
const snapshot = await scanExecution({
|
|
42826
|
-
cwd,
|
|
42827
|
-
threadId: options.threadId,
|
|
42828
|
-
runId: options.runId,
|
|
42829
|
-
detailRef: options.detailRef
|
|
42830
|
-
});
|
|
42831
|
-
return { snapshot };
|
|
42832
|
-
}
|
|
42833
|
-
};
|
|
42834
|
-
var runsContent = {
|
|
42835
|
-
name: "runs.content",
|
|
42836
|
-
description: "\u8BFB\u53D6\u6307\u5B9A\u6267\u884C\u7684\u6B63\u6587\u6BB5\u843D",
|
|
42837
|
-
options: [
|
|
42838
|
-
{
|
|
42839
|
-
flags: "--detail-ref <detailRef>",
|
|
42840
|
-
description: "\u56FA\u5B9A\u6267\u884C\u5F15\u7528",
|
|
42841
|
-
key: "detailRef"
|
|
42842
|
-
},
|
|
42843
|
-
{
|
|
42844
|
-
flags: "--content-ref <contentRef>",
|
|
42845
|
-
description: "\u6267\u884C\u8BE6\u60C5\u4E2D\u7684\u6B63\u6587\u5F15\u7528",
|
|
42846
|
-
key: "contentRef"
|
|
42847
|
-
},
|
|
42848
|
-
{
|
|
42849
|
-
flags: "--cursor <cursor>",
|
|
42850
|
-
description: "\u6B63\u6587\u5206\u9875\u6E38\u6807",
|
|
42851
|
-
key: "cursor"
|
|
42852
|
-
},
|
|
42853
|
-
{
|
|
42854
|
-
flags: "--max-bytes <maxBytes>",
|
|
42855
|
-
description: "\u6BCF\u9875\u6700\u5927\u54CD\u5E94\u5B57\u8282\u6570",
|
|
42856
|
-
key: "maxBytes",
|
|
42857
|
-
parse: parseMaxBytes
|
|
42858
|
-
}
|
|
42859
|
-
],
|
|
42860
|
-
summarize: ({ content }) => content ? `\u6B63\u6587\u6BB5\u843D ${content.availability}${content.nextCursor ? "\uFF08\u5206\u9875\u4E2D\uFF09" : ""}\u3002
|
|
42861
|
-
` : "\u672A\u627E\u5230\u5BF9\u5E94\u6B63\u6587\u3002\n",
|
|
42862
|
-
run: async (cwd, options) => {
|
|
42863
|
-
if (!options.detailRef || !options.contentRef)
|
|
42864
|
-
throw new InvalidArgumentError("--detail-ref \u548C --content-ref \u5747\u4E3A\u5FC5\u586B");
|
|
42865
|
-
const content = await scanContent({
|
|
42866
|
-
cwd,
|
|
42867
|
-
detailRef: options.detailRef,
|
|
42868
|
-
contentRef: options.contentRef,
|
|
42869
|
-
cursor: options.cursor,
|
|
42870
|
-
maxBytes: options.maxBytes
|
|
42871
|
-
});
|
|
42872
|
-
return { content };
|
|
42873
|
-
}
|
|
42874
|
-
};
|
|
42875
|
-
|
|
42876
42132
|
// src/commands/registry.ts
|
|
42877
42133
|
var parsePort = (value) => {
|
|
42878
42134
|
const port = Number(value);
|
|
@@ -43513,9 +42769,6 @@ var COMMANDS = [
|
|
|
43513
42769
|
platformSdkApplyCommand,
|
|
43514
42770
|
agentBuildCommand,
|
|
43515
42771
|
agentDeployCommand,
|
|
43516
|
-
runsList,
|
|
43517
|
-
runsShow,
|
|
43518
|
-
runsContent,
|
|
43519
42772
|
version2
|
|
43520
42773
|
];
|
|
43521
42774
|
|
|
@@ -43533,8 +42786,7 @@ var GROUP_DESCRIPTIONS = {
|
|
|
43533
42786
|
build: "build archives from the workspace",
|
|
43534
42787
|
card: "inspect A2UI card drafts in the workspace",
|
|
43535
42788
|
inspector: "apply Inspector edits to the workspace",
|
|
43536
|
-
"platform-sdk": "apply platform-managed SDK bundles"
|
|
43537
|
-
runs: "query recent Query runs from retained sandbox logs"
|
|
42789
|
+
"platform-sdk": "apply platform-managed SDK bundles"
|
|
43538
42790
|
};
|
|
43539
42791
|
var collectOptions = (target, definitions, values) => {
|
|
43540
42792
|
for (const { flags, key } of definitions) {
|
|
@@ -43631,7 +42883,6 @@ function parseCliInvocation(argv, output) {
|
|
|
43631
42883
|
bindCommandGroup(program2, "card", state);
|
|
43632
42884
|
bindCommandGroup(program2, "inspector", state);
|
|
43633
42885
|
bindCommandGroup(program2, "platform-sdk", state);
|
|
43634
|
-
bindCommandGroup(program2, "runs", state);
|
|
43635
42886
|
program2.exitOverride();
|
|
43636
42887
|
for (const child of program2.commands) exitOverrideDeep(child);
|
|
43637
42888
|
program2.parse(argv, { from: "user" });
|