linkque-cli-v2 1.4.4 → 1.4.5
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 +1291 -354
- package/package.json +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-OHRCYI66.js → chunk-CLYLJ5MD.js} +591 -393
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-XL6BPKTI.js → chunk-NFVKWQGM.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-CUMXO6KK.js → chunk-S75HFRLD.js} +4 -3
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js +94 -8
- 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 +691 -381
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 path24 = 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 = path24.resolve(baseDir, baseName);
|
|
2213
2213
|
if (fs2.existsSync(localBin)) return localBin;
|
|
2214
|
-
if (sourceExt.includes(
|
|
2214
|
+
if (sourceExt.includes(path24.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 = path24.resolve(
|
|
2233
|
+
path24.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 = path24.basename(
|
|
2241
2241
|
this._scriptPath,
|
|
2242
|
-
|
|
2242
|
+
path24.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(path24.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 = path24.basename(filename, path24.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(path25) {
|
|
3183
|
+
if (path25 === void 0) return this._executableDir;
|
|
3184
|
+
this._executableDir = path25;
|
|
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(path24) {
|
|
6692
|
+
let input = path24;
|
|
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 path24 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
|
|
7102
|
+
wsComponent.path = path24 && path24 !== "/" ? path24 : void 0;
|
|
7103
7103
|
wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
|
|
7104
7104
|
wsComponent.resourceName = void 0;
|
|
7105
7105
|
}
|
|
@@ -7574,13 +7574,14 @@ var require_fast_uri = __commonJS({
|
|
|
7574
7574
|
if (!malformedIPLiteral) {
|
|
7575
7575
|
malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
|
|
7576
7576
|
}
|
|
7577
|
-
if (
|
|
7578
|
-
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
parsed.host = reescapeHostDelimiters(host, isIP);
|
|
7582
|
-
}
|
|
7577
|
+
if (uri.indexOf("%") !== -1 && parsed.host !== void 0 && !malformedIPLiteral) {
|
|
7578
|
+
let host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true);
|
|
7579
|
+
if (!isIP) {
|
|
7580
|
+
host = normalizePercentEncoding(host.toLowerCase());
|
|
7583
7581
|
}
|
|
7582
|
+
parsed.host = reescapeHostDelimiters(host, isIP);
|
|
7583
|
+
}
|
|
7584
|
+
if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
|
|
7584
7585
|
if (parsed.path) {
|
|
7585
7586
|
parsed.path = normalizePathEncoding(parsed.path);
|
|
7586
7587
|
}
|
|
@@ -19991,6 +19992,7 @@ var EDebugLogScope;
|
|
|
19991
19992
|
EDebugLogScope2["LLM"] = "LLM";
|
|
19992
19993
|
EDebugLogScope2["PI_EVENT"] = "PI_EVENT";
|
|
19993
19994
|
EDebugLogScope2["MCP"] = "MCP";
|
|
19995
|
+
EDebugLogScope2["SKILL"] = "SKILL";
|
|
19994
19996
|
EDebugLogScope2["HTTP"] = "HTTP";
|
|
19995
19997
|
EDebugLogScope2["HOOK"] = "HOOK";
|
|
19996
19998
|
})(EDebugLogScope || (EDebugLogScope = {}));
|
|
@@ -20146,10 +20148,10 @@ function canonicalizeBindingPath(rawPath, listRoot) {
|
|
|
20146
20148
|
}
|
|
20147
20149
|
return isSafeJsonPointer(candidate, true) ? candidate : void 0;
|
|
20148
20150
|
}
|
|
20149
|
-
function issue2(
|
|
20150
|
-
return { path:
|
|
20151
|
+
function issue2(path24, code, message) {
|
|
20152
|
+
return { path: path24, code, message };
|
|
20151
20153
|
}
|
|
20152
|
-
function exactKeys(value, allowed,
|
|
20154
|
+
function exactKeys(value, allowed, path24, issues) {
|
|
20153
20155
|
}
|
|
20154
20156
|
|
|
20155
20157
|
// ../agent-a2ui-card-contract/dist/esm/binding-analyzer.js
|
|
@@ -20377,9 +20379,9 @@ var SCHEMA_TYPES = /* @__PURE__ */ new Set([
|
|
|
20377
20379
|
"object",
|
|
20378
20380
|
"string"
|
|
20379
20381
|
]);
|
|
20380
|
-
function getJsonSchemaIssues(value,
|
|
20382
|
+
function getJsonSchemaIssues(value, path24 = "schema", options = {}) {
|
|
20381
20383
|
const issues = [];
|
|
20382
|
-
validateSchemaNode(value,
|
|
20384
|
+
validateSchemaNode(value, path24, issues, options);
|
|
20383
20385
|
return issues;
|
|
20384
20386
|
}
|
|
20385
20387
|
var OPAQUE_OBJECT_SCHEMA = {
|
|
@@ -20401,9 +20403,9 @@ function normalizeTargetJsonSchema(schema) {
|
|
|
20401
20403
|
normalizeObjectDefaults(cloned);
|
|
20402
20404
|
return cloned;
|
|
20403
20405
|
}
|
|
20404
|
-
function validateJsonSchemaValue2(schema, value,
|
|
20406
|
+
function validateJsonSchemaValue2(schema, value, path24 = "$") {
|
|
20405
20407
|
const issues = [];
|
|
20406
|
-
validateValue(schema, value,
|
|
20408
|
+
validateValue(schema, value, path24, issues);
|
|
20407
20409
|
return issues;
|
|
20408
20410
|
}
|
|
20409
20411
|
function generateJsonSchemaSample(schema) {
|
|
@@ -20480,9 +20482,9 @@ function getJsonSchemaAtDataPointer(schema, pointer) {
|
|
|
20480
20482
|
return schema;
|
|
20481
20483
|
return getJsonSchemaAtPath(schema, pointer.slice(1).split("/").map(decodePointerSegment));
|
|
20482
20484
|
}
|
|
20483
|
-
function getJsonSchemaAtPath(schema,
|
|
20485
|
+
function getJsonSchemaAtPath(schema, path24) {
|
|
20484
20486
|
let current = schema;
|
|
20485
|
-
for (const segment of
|
|
20487
|
+
for (const segment of path24) {
|
|
20486
20488
|
if (!current)
|
|
20487
20489
|
return void 0;
|
|
20488
20490
|
if (segment === "*" || current.type === "array") {
|
|
@@ -20500,56 +20502,56 @@ function getJsonSchemaAtPath(schema, path23) {
|
|
|
20500
20502
|
}
|
|
20501
20503
|
return current;
|
|
20502
20504
|
}
|
|
20503
|
-
function getJsonSchemaCompatibilityIssues(source, target,
|
|
20505
|
+
function getJsonSchemaCompatibilityIssues(source, target, path24 = "$") {
|
|
20504
20506
|
const issues = [];
|
|
20505
|
-
compareSchemas(source, target,
|
|
20507
|
+
compareSchemas(source, target, path24, issues);
|
|
20506
20508
|
return issues;
|
|
20507
20509
|
}
|
|
20508
20510
|
function areJsonSchemaTypesCompatible(sourceType, targetType) {
|
|
20509
20511
|
return sourceType === targetType || sourceType === "integer" && targetType === "number";
|
|
20510
20512
|
}
|
|
20511
|
-
function validateSchemaNode(value,
|
|
20513
|
+
function validateSchemaNode(value, path24, issues, options) {
|
|
20512
20514
|
if (!isPlainRecord(value) || !isJsonValue(value)) {
|
|
20513
|
-
issues.push(issue2(
|
|
20515
|
+
issues.push(issue2(path24, "INVALID_JSON_SCHEMA", `${path24} must be a JSON object`));
|
|
20514
20516
|
return false;
|
|
20515
20517
|
}
|
|
20516
20518
|
if (value.type === void 0 && options.allowMissingType) {
|
|
20517
20519
|
return true;
|
|
20518
20520
|
}
|
|
20519
20521
|
if (typeof value.type !== "string" || !SCHEMA_TYPES.has(value.type)) {
|
|
20520
|
-
issues.push(issue2(`${
|
|
20522
|
+
issues.push(issue2(`${path24}.type`, "INVALID_JSON_SCHEMA_TYPE", `${path24}.type must be a supported scalar, object or array type`));
|
|
20521
20523
|
return false;
|
|
20522
20524
|
}
|
|
20523
20525
|
if (value.required !== void 0 && (!Array.isArray(value.required) || value.required.some((entry) => typeof entry !== "string"))) {
|
|
20524
|
-
issues.push(issue2(`${
|
|
20526
|
+
issues.push(issue2(`${path24}.required`, "INVALID_JSON_SCHEMA_REQUIRED", `${path24}.required must be a string array`));
|
|
20525
20527
|
}
|
|
20526
20528
|
if (value.type === "object") {
|
|
20527
20529
|
if (!isPlainRecord(value.properties)) {
|
|
20528
20530
|
if (options.requireCompleteStructures) {
|
|
20529
|
-
issues.push(issue2(`${
|
|
20531
|
+
issues.push(issue2(`${path24}.properties`, "INCOMPLETE_OBJECT_SCHEMA", "object schemas must declare properties"));
|
|
20530
20532
|
}
|
|
20531
20533
|
} else {
|
|
20532
20534
|
for (const [name, child] of Object.entries(value.properties)) {
|
|
20533
|
-
validateSchemaNode(child, `${
|
|
20535
|
+
validateSchemaNode(child, `${path24}.properties.${name}`, issues, options);
|
|
20534
20536
|
}
|
|
20535
20537
|
const required2 = Array.isArray(value.required) ? value.required.filter((entry) => typeof entry === "string") : [];
|
|
20536
20538
|
for (const name of required2) {
|
|
20537
20539
|
if (!(name in value.properties)) {
|
|
20538
|
-
issues.push(issue2(`${
|
|
20540
|
+
issues.push(issue2(`${path24}.required`, "UNKNOWN_REQUIRED_PROPERTY", `required property ${name} is not declared`));
|
|
20539
20541
|
}
|
|
20540
20542
|
}
|
|
20541
20543
|
}
|
|
20542
20544
|
if (value.additionalProperties !== void 0 && typeof value.additionalProperties !== "boolean" && !isPlainRecord(value.additionalProperties)) {
|
|
20543
|
-
issues.push(issue2(`${
|
|
20545
|
+
issues.push(issue2(`${path24}.additionalProperties`, "INVALID_ADDITIONAL_PROPERTIES", "additionalProperties must be a boolean or schema"));
|
|
20544
20546
|
}
|
|
20545
20547
|
}
|
|
20546
20548
|
if (value.type === "array") {
|
|
20547
20549
|
if (!isPlainRecord(value.items)) {
|
|
20548
20550
|
if (options.requireCompleteStructures) {
|
|
20549
|
-
issues.push(issue2(`${
|
|
20551
|
+
issues.push(issue2(`${path24}.items`, "INCOMPLETE_ARRAY_SCHEMA", "array schemas must declare items"));
|
|
20550
20552
|
}
|
|
20551
20553
|
} else {
|
|
20552
|
-
validateSchemaNode(value.items, `${
|
|
20554
|
+
validateSchemaNode(value.items, `${path24}.items`, issues, options);
|
|
20553
20555
|
}
|
|
20554
20556
|
}
|
|
20555
20557
|
return true;
|
|
@@ -20569,53 +20571,53 @@ function normalizeObjectDefaults(schema) {
|
|
|
20569
20571
|
normalizeObjectDefaults(schema.items);
|
|
20570
20572
|
}
|
|
20571
20573
|
}
|
|
20572
|
-
function validateValue(schema, value,
|
|
20574
|
+
function validateValue(schema, value, path24, issues) {
|
|
20573
20575
|
if (typeof schema.type === "string" && !matchesType(schema.type, value)) {
|
|
20574
|
-
issues.push(issue2(
|
|
20576
|
+
issues.push(issue2(path24, "SCHEMA_TYPE_MISMATCH", `expected ${schema.type}, received ${valueType(value)}`));
|
|
20575
20577
|
return;
|
|
20576
20578
|
}
|
|
20577
20579
|
if (Array.isArray(schema.enum) && !schema.enum.some((entry) => Object.is(entry, value))) {
|
|
20578
|
-
issues.push(issue2(
|
|
20580
|
+
issues.push(issue2(path24, "SCHEMA_ENUM_MISMATCH", "value is not in the declared enum"));
|
|
20579
20581
|
return;
|
|
20580
20582
|
}
|
|
20581
20583
|
if (schema.const !== void 0 && !Object.is(schema.const, value)) {
|
|
20582
|
-
issues.push(issue2(
|
|
20584
|
+
issues.push(issue2(path24, "SCHEMA_CONST_MISMATCH", "value does not match const"));
|
|
20583
20585
|
return;
|
|
20584
20586
|
}
|
|
20585
20587
|
if (schema.type === "object" && isPlainRecord(value)) {
|
|
20586
20588
|
const required2 = Array.isArray(schema.required) ? schema.required.filter((entry) => typeof entry === "string") : [];
|
|
20587
20589
|
for (const key of required2) {
|
|
20588
20590
|
if (!(key in value)) {
|
|
20589
|
-
issues.push(issue2(`${
|
|
20591
|
+
issues.push(issue2(`${path24}/${key}`, "SCHEMA_REQUIRED_MISSING", `required property ${key} is missing`));
|
|
20590
20592
|
}
|
|
20591
20593
|
}
|
|
20592
20594
|
const properties = isPlainRecord(schema.properties) ? schema.properties : {};
|
|
20593
20595
|
for (const [key, childSchema] of Object.entries(properties)) {
|
|
20594
20596
|
if (!(key in value) || !isPlainRecord(childSchema))
|
|
20595
20597
|
continue;
|
|
20596
|
-
validateValue(childSchema, value[key], `${
|
|
20598
|
+
validateValue(childSchema, value[key], `${path24}/${key}`, issues);
|
|
20597
20599
|
}
|
|
20598
20600
|
if (schema.additionalProperties === false) {
|
|
20599
20601
|
for (const key of Object.keys(value)) {
|
|
20600
20602
|
if (!(key in properties)) {
|
|
20601
|
-
issues.push(issue2(`${
|
|
20603
|
+
issues.push(issue2(`${path24}/${key}`, "SCHEMA_ADDITIONAL_PROPERTY", `property ${key} is not allowed`));
|
|
20602
20604
|
}
|
|
20603
20605
|
}
|
|
20604
20606
|
}
|
|
20605
20607
|
}
|
|
20606
20608
|
if (schema.type === "array" && Array.isArray(value) && isPlainRecord(schema.items)) {
|
|
20607
20609
|
value.forEach((entry, index) => {
|
|
20608
|
-
validateValue(schema.items, entry, `${
|
|
20610
|
+
validateValue(schema.items, entry, `${path24}/${index}`, issues);
|
|
20609
20611
|
});
|
|
20610
20612
|
}
|
|
20611
20613
|
}
|
|
20612
|
-
function compareSchemas(source, target,
|
|
20614
|
+
function compareSchemas(source, target, path24, issues) {
|
|
20613
20615
|
if (!areJsonSchemaTypesCompatible(source.type, target.type)) {
|
|
20614
|
-
issues.push(issue2(
|
|
20616
|
+
issues.push(issue2(path24, "SCHEMA_TYPE_INCOMPATIBLE", `source type ${String(source.type)} cannot supply ${String(target.type)}`));
|
|
20615
20617
|
return;
|
|
20616
20618
|
}
|
|
20617
20619
|
if (source.type === "array" && target.type === "array" && isPlainRecord(source.items) && isPlainRecord(target.items)) {
|
|
20618
|
-
compareSchemas(source.items, target.items, `${
|
|
20620
|
+
compareSchemas(source.items, target.items, `${path24}[*]`, issues);
|
|
20619
20621
|
}
|
|
20620
20622
|
if (source.type === "object" && target.type === "object" && isPlainRecord(source.properties) && isPlainRecord(target.properties)) {
|
|
20621
20623
|
const required2 = Array.isArray(target.required) ? target.required.filter((entry) => typeof entry === "string") : [];
|
|
@@ -20623,10 +20625,10 @@ function compareSchemas(source, target, path23, issues) {
|
|
|
20623
20625
|
const sourceChild = source.properties[name];
|
|
20624
20626
|
const targetChild = target.properties[name];
|
|
20625
20627
|
if (!isPlainRecord(sourceChild) || !isPlainRecord(targetChild)) {
|
|
20626
|
-
issues.push(issue2(`${
|
|
20628
|
+
issues.push(issue2(`${path24}.${name}`, "SCHEMA_REQUIRED_MISSING", `source does not provide required property ${name}`));
|
|
20627
20629
|
continue;
|
|
20628
20630
|
}
|
|
20629
|
-
compareSchemas(sourceChild, targetChild, `${
|
|
20631
|
+
compareSchemas(sourceChild, targetChild, `${path24}.${name}`, issues);
|
|
20630
20632
|
}
|
|
20631
20633
|
}
|
|
20632
20634
|
}
|
|
@@ -20715,37 +20717,37 @@ var A2UICardExpressionError = class extends Error {
|
|
|
20715
20717
|
this.fieldId = fieldId;
|
|
20716
20718
|
}
|
|
20717
20719
|
};
|
|
20718
|
-
function getA2UICardTransformIssues(value,
|
|
20720
|
+
function getA2UICardTransformIssues(value, path24 = "transform") {
|
|
20719
20721
|
if (!isPlainRecord(value)) {
|
|
20720
20722
|
return [
|
|
20721
|
-
issue2(
|
|
20723
|
+
issue2(path24, "CARD_EXPRESSION_INVALID", "transform must be an object")
|
|
20722
20724
|
];
|
|
20723
20725
|
}
|
|
20724
20726
|
const issues = [];
|
|
20725
20727
|
const allowedKeys = /* @__PURE__ */ new Set(["language", "profile", "expression"]);
|
|
20726
20728
|
for (const key of Object.keys(value)) {
|
|
20727
20729
|
if (!allowedKeys.has(key)) {
|
|
20728
|
-
issues.push(issue2(`${
|
|
20730
|
+
issues.push(issue2(`${path24}.${key}`, "CARD_EXPRESSION_INVALID", `${key} is not supported by transform`));
|
|
20729
20731
|
}
|
|
20730
20732
|
}
|
|
20731
20733
|
if (value.language !== A2UI_CARD_TRANSFORM_LANGUAGE) {
|
|
20732
|
-
issues.push(issue2(`${
|
|
20734
|
+
issues.push(issue2(`${path24}.language`, "CARD_EXPRESSION_INVALID", `language must be ${A2UI_CARD_TRANSFORM_LANGUAGE}`));
|
|
20733
20735
|
}
|
|
20734
20736
|
if (value.profile !== A2UI_CARD_TRANSFORM_PROFILE) {
|
|
20735
|
-
issues.push(issue2(`${
|
|
20737
|
+
issues.push(issue2(`${path24}.profile`, "CARD_EXPRESSION_INVALID", `profile must be ${A2UI_CARD_TRANSFORM_PROFILE}`));
|
|
20736
20738
|
}
|
|
20737
20739
|
if (typeof value.expression !== "string" || value.expression.trim().length === 0) {
|
|
20738
|
-
issues.push(issue2(`${
|
|
20740
|
+
issues.push(issue2(`${path24}.expression`, "CARD_EXPRESSION_INVALID", "expression must be a non-empty string"));
|
|
20739
20741
|
return issues;
|
|
20740
20742
|
}
|
|
20741
20743
|
if (value.expression.length > A2UI_CARD_EXPRESSION_MAX_LENGTH) {
|
|
20742
|
-
issues.push(issue2(`${
|
|
20744
|
+
issues.push(issue2(`${path24}.expression`, "CARD_EXPRESSION_LIMIT_EXCEEDED", `expression exceeds ${A2UI_CARD_EXPRESSION_MAX_LENGTH} characters`));
|
|
20743
20745
|
return issues;
|
|
20744
20746
|
}
|
|
20745
20747
|
try {
|
|
20746
20748
|
validateAst((0, import_jmespath2.compile)(value.expression));
|
|
20747
20749
|
} catch (error2) {
|
|
20748
|
-
issues.push(issue2(`${
|
|
20750
|
+
issues.push(issue2(`${path24}.expression`, error2 instanceof A2UICardExpressionError ? error2.code : "CARD_EXPRESSION_INVALID", error2 instanceof Error ? error2.message : "expression is invalid"));
|
|
20749
20751
|
}
|
|
20750
20752
|
return issues;
|
|
20751
20753
|
}
|
|
@@ -20857,11 +20859,11 @@ function parseA2UICardBindingContext(value) {
|
|
|
20857
20859
|
issues: []
|
|
20858
20860
|
};
|
|
20859
20861
|
}
|
|
20860
|
-
function getA2UICardBindingContextIssues(value,
|
|
20862
|
+
function getA2UICardBindingContextIssues(value, path24 = "bindingContext") {
|
|
20861
20863
|
const issues = [];
|
|
20862
20864
|
if (!isPlainRecord(value)) {
|
|
20863
20865
|
return [
|
|
20864
|
-
issue2(
|
|
20866
|
+
issue2(path24, "CARD_BINDING_CONTEXT_INVALID", "binding context must be an object")
|
|
20865
20867
|
];
|
|
20866
20868
|
}
|
|
20867
20869
|
exactKeys(value, [
|
|
@@ -20873,36 +20875,36 @@ function getA2UICardBindingContextIssues(value, path23 = "bindingContext") {
|
|
|
20873
20875
|
"generatedAt",
|
|
20874
20876
|
"candidates",
|
|
20875
20877
|
"preferredTools"
|
|
20876
|
-
],
|
|
20878
|
+
], path24, issues);
|
|
20877
20879
|
if (value.schemaVersion !== "1") {
|
|
20878
|
-
issues.push(issue2(`${
|
|
20880
|
+
issues.push(issue2(`${path24}.schemaVersion`, "CARD_BINDING_CONTEXT_INVALID", "schemaVersion must be 1"));
|
|
20879
20881
|
}
|
|
20880
20882
|
for (const key of ["draftId", "resourceId"]) {
|
|
20881
20883
|
if (!isSafeIdentifier(value[key])) {
|
|
20882
|
-
issues.push(issue2(`${
|
|
20884
|
+
issues.push(issue2(`${path24}.${key}`, "CARD_BINDING_CONTEXT_INVALID", `${key} is invalid`));
|
|
20883
20885
|
}
|
|
20884
20886
|
}
|
|
20885
20887
|
for (const key of ["draftStructureChecksum", "mcpConfigChecksum"]) {
|
|
20886
20888
|
if (typeof value[key] !== "string" || !/^[0-9a-f]{64}$/u.test(value[key])) {
|
|
20887
|
-
issues.push(issue2(`${
|
|
20889
|
+
issues.push(issue2(`${path24}.${key}`, "CARD_BINDING_CONTEXT_INVALID", `${key} must be a sha256 checksum`));
|
|
20888
20890
|
}
|
|
20889
20891
|
}
|
|
20890
20892
|
if (typeof value.generatedAt !== "string" || !Number.isFinite(Date.parse(value.generatedAt))) {
|
|
20891
|
-
issues.push(issue2(`${
|
|
20893
|
+
issues.push(issue2(`${path24}.generatedAt`, "CARD_BINDING_CONTEXT_INVALID", "generatedAt must be an ISO timestamp"));
|
|
20892
20894
|
}
|
|
20893
|
-
validateCandidates(value.candidates, `${
|
|
20894
|
-
validatePreferences(value.preferredTools, `${
|
|
20895
|
+
validateCandidates(value.candidates, `${path24}.candidates`, issues);
|
|
20896
|
+
validatePreferences(value.preferredTools, `${path24}.preferredTools`, issues);
|
|
20895
20897
|
return issues;
|
|
20896
20898
|
}
|
|
20897
|
-
function getA2UICardBindingSelectionIssues(value,
|
|
20899
|
+
function getA2UICardBindingSelectionIssues(value, path24 = "bindings", fields) {
|
|
20898
20900
|
const issues = [];
|
|
20899
20901
|
if (!Array.isArray(value)) {
|
|
20900
|
-
return [issue2(
|
|
20902
|
+
return [issue2(path24, "CARD_BINDING_INVALID", "bindings must be an array")];
|
|
20901
20903
|
}
|
|
20902
20904
|
const fieldById = new Map(fields?.map((field) => [field.fieldId, field]) ?? []);
|
|
20903
20905
|
const seen = /* @__PURE__ */ new Set();
|
|
20904
20906
|
value.forEach((candidate, index) => {
|
|
20905
|
-
const itemPath = `${
|
|
20907
|
+
const itemPath = `${path24}[${index}]`;
|
|
20906
20908
|
if (!isPlainRecord(candidate)) {
|
|
20907
20909
|
issues.push(issue2(itemPath, "CARD_BINDING_INVALID", "binding must be an object"));
|
|
20908
20910
|
return;
|
|
@@ -21015,14 +21017,14 @@ function validateA2UICardBindings(input, options = {}) {
|
|
|
21015
21017
|
validateConsistencyGroups(input.draft.manifest.fields, bindings, issues, selectedFields);
|
|
21016
21018
|
return issues;
|
|
21017
21019
|
}
|
|
21018
|
-
function validateCandidates(value,
|
|
21020
|
+
function validateCandidates(value, path24, issues) {
|
|
21019
21021
|
if (!Array.isArray(value) || value.length > 200) {
|
|
21020
|
-
issues.push(issue2(
|
|
21022
|
+
issues.push(issue2(path24, "CARD_BINDING_CONTEXT_INVALID", "candidates must be an array with at most 200 items"));
|
|
21021
21023
|
return;
|
|
21022
21024
|
}
|
|
21023
21025
|
const candidateKeys = /* @__PURE__ */ new Set();
|
|
21024
21026
|
value.forEach((candidate, index) => {
|
|
21025
|
-
const itemPath = `${
|
|
21027
|
+
const itemPath = `${path24}[${index}]`;
|
|
21026
21028
|
if (!isPlainRecord(candidate)) {
|
|
21027
21029
|
issues.push(issue2(itemPath, "CARD_BINDING_CONTEXT_INVALID", "candidate must be an object"));
|
|
21028
21030
|
return;
|
|
@@ -21063,9 +21065,9 @@ function validateCandidates(value, path23, issues) {
|
|
|
21063
21065
|
}
|
|
21064
21066
|
});
|
|
21065
21067
|
}
|
|
21066
|
-
function validateTool(value,
|
|
21068
|
+
function validateTool(value, path24, resourceId, issues) {
|
|
21067
21069
|
if (!isPlainRecord(value)) {
|
|
21068
|
-
issues.push(issue2(
|
|
21070
|
+
issues.push(issue2(path24, "CARD_BINDING_CONTEXT_INVALID", "tool must be an object"));
|
|
21069
21071
|
return;
|
|
21070
21072
|
}
|
|
21071
21073
|
exactKeys(value, [
|
|
@@ -21076,16 +21078,16 @@ function validateTool(value, path23, resourceId, issues) {
|
|
|
21076
21078
|
"outputSchema",
|
|
21077
21079
|
"outputSchemaMode",
|
|
21078
21080
|
"annotations"
|
|
21079
|
-
],
|
|
21081
|
+
], path24, issues);
|
|
21080
21082
|
if (value.resourceId !== resourceId) {
|
|
21081
|
-
issues.push(issue2(`${
|
|
21083
|
+
issues.push(issue2(`${path24}.resourceId`, "CARD_BINDING_CONTEXT_INVALID", "tool resourceId must match candidate"));
|
|
21082
21084
|
}
|
|
21083
21085
|
if (typeof value.toolName !== "string" || !value.toolName.trim()) {
|
|
21084
|
-
issues.push(issue2(`${
|
|
21086
|
+
issues.push(issue2(`${path24}.toolName`, "CARD_BINDING_CONTEXT_INVALID", "toolName is required"));
|
|
21085
21087
|
}
|
|
21086
|
-
issues.push(...getJsonSchemaIssues(value.inputSchema, `${
|
|
21088
|
+
issues.push(...getJsonSchemaIssues(value.inputSchema, `${path24}.inputSchema`));
|
|
21087
21089
|
if (value.outputSchemaMode !== void 0 && value.outputSchemaMode !== "declared" && value.outputSchemaMode !== "opaque") {
|
|
21088
|
-
issues.push(issue2(`${
|
|
21090
|
+
issues.push(issue2(`${path24}.outputSchemaMode`, "CARD_BINDING_CONTEXT_INVALID", "outputSchemaMode must be declared or opaque"));
|
|
21089
21091
|
}
|
|
21090
21092
|
}
|
|
21091
21093
|
function normalizeBindingContext(context) {
|
|
@@ -21106,16 +21108,16 @@ function normalizeBindingContext(context) {
|
|
|
21106
21108
|
});
|
|
21107
21109
|
return cloned;
|
|
21108
21110
|
}
|
|
21109
|
-
function validatePreferences(value,
|
|
21111
|
+
function validatePreferences(value, path24, issues) {
|
|
21110
21112
|
if (value === void 0)
|
|
21111
21113
|
return;
|
|
21112
21114
|
if (!Array.isArray(value) || value.length > 512) {
|
|
21113
|
-
issues.push(issue2(
|
|
21115
|
+
issues.push(issue2(path24, "CARD_BINDING_CONTEXT_INVALID", "preferredTools must be an array"));
|
|
21114
21116
|
return;
|
|
21115
21117
|
}
|
|
21116
21118
|
const fields = /* @__PURE__ */ new Set();
|
|
21117
21119
|
value.forEach((preference, index) => {
|
|
21118
|
-
const itemPath = `${
|
|
21120
|
+
const itemPath = `${path24}[${index}]`;
|
|
21119
21121
|
if (!isPlainRecord(preference)) {
|
|
21120
21122
|
issues.push(issue2(itemPath, "CARD_BINDING_CONTEXT_INVALID", "preference must be an object"));
|
|
21121
21123
|
return;
|
|
@@ -21135,14 +21137,14 @@ function validatePreferences(value, path23, issues) {
|
|
|
21135
21137
|
fields.add(preference.fieldId);
|
|
21136
21138
|
});
|
|
21137
21139
|
}
|
|
21138
|
-
function validateInputBindings(value,
|
|
21140
|
+
function validateInputBindings(value, path24, issues) {
|
|
21139
21141
|
if (!Array.isArray(value) || value.length > 64) {
|
|
21140
|
-
issues.push(issue2(
|
|
21142
|
+
issues.push(issue2(path24, "CARD_BINDING_INVALID", "inputBindings must be an array with at most 64 items"));
|
|
21141
21143
|
return;
|
|
21142
21144
|
}
|
|
21143
21145
|
const inputs = /* @__PURE__ */ new Set();
|
|
21144
21146
|
value.forEach((binding, index) => {
|
|
21145
|
-
const itemPath = `${
|
|
21147
|
+
const itemPath = `${path24}[${index}]`;
|
|
21146
21148
|
if (!isPlainRecord(binding)) {
|
|
21147
21149
|
issues.push(issue2(itemPath, "CARD_BINDING_INVALID", "input binding must be an object"));
|
|
21148
21150
|
return;
|
|
@@ -21173,18 +21175,18 @@ function validateInputBindings(value, path23, issues) {
|
|
|
21173
21175
|
}
|
|
21174
21176
|
});
|
|
21175
21177
|
}
|
|
21176
|
-
function validateRequiredToolInputs(toolSchema, presentationSchema, bindings,
|
|
21178
|
+
function validateRequiredToolInputs(toolSchema, presentationSchema, bindings, path24, issues) {
|
|
21177
21179
|
const byInput = new Map(bindings.map((binding) => [binding.inputPath, binding]));
|
|
21178
21180
|
for (const input of requiredLeafInputs(toolSchema)) {
|
|
21179
21181
|
const binding = byInput.get(input.path);
|
|
21180
21182
|
if (!binding) {
|
|
21181
|
-
issues.push(issue2(
|
|
21183
|
+
issues.push(issue2(path24, "CARD_BINDING_INCOMPLETE", `required Tool input ${input.path} is not bound`));
|
|
21182
21184
|
continue;
|
|
21183
21185
|
}
|
|
21184
21186
|
if (binding.source.kind === "invocation") {
|
|
21185
21187
|
const source = getJsonSchemaAtDataPointer(presentationSchema, binding.source.path);
|
|
21186
21188
|
if (!source || !areJsonSchemaTypesCompatible(source.type, input.schema.type)) {
|
|
21187
|
-
issues.push(issue2(
|
|
21189
|
+
issues.push(issue2(path24, "CARD_BINDING_INVALID", `invocation source ${binding.source.path} is incompatible with ${input.path}`));
|
|
21188
21190
|
}
|
|
21189
21191
|
}
|
|
21190
21192
|
}
|
|
@@ -21196,11 +21198,11 @@ function requiredLeafInputs(schema, basePath = "", parentRequired = true) {
|
|
|
21196
21198
|
return Object.entries(schema.properties).flatMap(([name, child]) => {
|
|
21197
21199
|
if (!isPlainRecord(child))
|
|
21198
21200
|
return [];
|
|
21199
|
-
const
|
|
21201
|
+
const path24 = `${basePath}/${name.replace(/~/gu, "~0").replace(/\//gu, "~1")}`;
|
|
21200
21202
|
const isRequired = parentRequired && required2.has(name);
|
|
21201
21203
|
if (child.type === "object")
|
|
21202
|
-
return requiredLeafInputs(child,
|
|
21203
|
-
return isRequired ? [{ path:
|
|
21204
|
+
return requiredLeafInputs(child, path24, isRequired);
|
|
21205
|
+
return isRequired ? [{ path: path24, schema: child }] : [];
|
|
21204
21206
|
});
|
|
21205
21207
|
}
|
|
21206
21208
|
function validateConsistencyGroups(fields, bindings, issues, selectedFields) {
|
|
@@ -21544,16 +21546,16 @@ var A2UI_V4_COMPONENT_CATALOG = Object.freeze({
|
|
|
21544
21546
|
}
|
|
21545
21547
|
}
|
|
21546
21548
|
});
|
|
21547
|
-
function getA2UIV4ProtocolIssues(value,
|
|
21549
|
+
function getA2UIV4ProtocolIssues(value, path24 = "card") {
|
|
21548
21550
|
const issues = [];
|
|
21549
21551
|
if (!Array.isArray(value) || value.length === 0)
|
|
21550
21552
|
return [
|
|
21551
|
-
issue2(
|
|
21553
|
+
issue2(path24, "INVALID_A2UI_PROTOCOL", "card must be a non-empty array")
|
|
21552
21554
|
];
|
|
21553
21555
|
const surfaces = /* @__PURE__ */ new Map();
|
|
21554
21556
|
const createdSurfaces = /* @__PURE__ */ new Set();
|
|
21555
21557
|
for (const [messageIndex, message] of value.entries()) {
|
|
21556
|
-
const messagePath = `${
|
|
21558
|
+
const messagePath = `${path24}[${messageIndex}]`;
|
|
21557
21559
|
if (!isPlainRecord(message) || message.version !== "0.9" || !Array.isArray(message.datas)) {
|
|
21558
21560
|
issues.push(issue2(messagePath, "INVALID_A2UI_MESSAGE", "V4 messages require version 0.9 and a datas array"));
|
|
21559
21561
|
continue;
|
|
@@ -21607,9 +21609,9 @@ function getA2UIV4ProtocolIssues(value, path23 = "card") {
|
|
|
21607
21609
|
}
|
|
21608
21610
|
surfaces.forEach((_components, surfaceId) => {
|
|
21609
21611
|
if (!createdSurfaces.has(surfaceId))
|
|
21610
|
-
issues.push(issue2(`${
|
|
21612
|
+
issues.push(issue2(`${path24}.surfaces.${surfaceId}`, "MISSING_CREATE_SURFACE", "every V4 surface must declare createSurface with the V4 catalog"));
|
|
21611
21613
|
});
|
|
21612
|
-
validateReferences(surfaces,
|
|
21614
|
+
validateReferences(surfaces, path24, issues);
|
|
21613
21615
|
return issues;
|
|
21614
21616
|
}
|
|
21615
21617
|
function validateV4Component(component, componentPath, issues) {
|
|
@@ -21660,15 +21662,15 @@ function validateV4Component(component, componentPath, issues) {
|
|
|
21660
21662
|
if (component.action !== void 0)
|
|
21661
21663
|
validateAction(component.action, `${componentPath}.action`, issues, 0);
|
|
21662
21664
|
}
|
|
21663
|
-
function validateComponents(payload,
|
|
21665
|
+
function validateComponents(payload, path24, surfaces, issues) {
|
|
21664
21666
|
if (!Array.isArray(payload.components)) {
|
|
21665
|
-
issues.push(issue2(`${
|
|
21667
|
+
issues.push(issue2(`${path24}.updateComponents.components`, "INVALID_A2UI_COMPONENTS", "components must be an array"));
|
|
21666
21668
|
return;
|
|
21667
21669
|
}
|
|
21668
21670
|
const surface = surfaces.get(payload.surfaceId) ?? /* @__PURE__ */ new Map();
|
|
21669
21671
|
surfaces.set(payload.surfaceId, surface);
|
|
21670
21672
|
payload.components.forEach((component, index) => {
|
|
21671
|
-
const componentPath = `${
|
|
21673
|
+
const componentPath = `${path24}.updateComponents.components[${index}]`;
|
|
21672
21674
|
if (!isPlainRecord(component) || !isSafeIdentifier(component.id) || typeof component.component !== "string") {
|
|
21673
21675
|
issues.push(issue2(componentPath, "INVALID_A2UI_COMPONENT", "component requires a safe id and component name"));
|
|
21674
21676
|
return;
|
|
@@ -21679,23 +21681,23 @@ function validateComponents(payload, path23, surfaces, issues) {
|
|
|
21679
21681
|
validateV4Component(component, componentPath, issues);
|
|
21680
21682
|
});
|
|
21681
21683
|
}
|
|
21682
|
-
function validateProperty(value, schema,
|
|
21684
|
+
function validateProperty(value, schema, path24, issues, propertyName) {
|
|
21683
21685
|
if (schema.kind === "binding") {
|
|
21684
21686
|
const stringOnly = propertyName === "label" || propertyName === "src" || propertyName === "alt";
|
|
21685
21687
|
const literalValid = typeof value === "string" || !stringOnly && typeof value === "number" && Number.isFinite(value);
|
|
21686
21688
|
if (!literalValid && !isDisplayBinding(value, stringOnly))
|
|
21687
|
-
issues.push(issue2(
|
|
21689
|
+
issues.push(issue2(path24, "INVALID_DISPLAY_VALUE", `display value must be ${stringOnly ? "a string" : "a string or finite number"}, or a compatible display binding`));
|
|
21688
21690
|
return;
|
|
21689
21691
|
}
|
|
21690
21692
|
if (schema.kind === "child") {
|
|
21691
21693
|
if (!isSafeIdentifier(value))
|
|
21692
|
-
issues.push(issue2(
|
|
21694
|
+
issues.push(issue2(path24, "INVALID_CHILD", "child must be a safe component id"));
|
|
21693
21695
|
return;
|
|
21694
21696
|
}
|
|
21695
21697
|
if (schema.kind === "children") {
|
|
21696
21698
|
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);
|
|
21697
21699
|
if (!valid)
|
|
21698
|
-
issues.push(issue2(
|
|
21700
|
+
issues.push(issue2(path24, "INVALID_CHILDREN", "children must be component ids or one dynamic children binding"));
|
|
21699
21701
|
return;
|
|
21700
21702
|
}
|
|
21701
21703
|
if (schema.kind === "action")
|
|
@@ -21703,11 +21705,11 @@ function validateProperty(value, schema, path23, issues, propertyName) {
|
|
|
21703
21705
|
if (schema.kind === "options" || schema.kind === "format")
|
|
21704
21706
|
return;
|
|
21705
21707
|
if (schema.kind === "boolean" && typeof value !== "boolean")
|
|
21706
|
-
issues.push(issue2(
|
|
21708
|
+
issues.push(issue2(path24, "INVALID_COMPONENT_PROP_TYPE", "value must be boolean"));
|
|
21707
21709
|
if (schema.kind === "number" && (!Number.isFinite(value) || schema.values && !schema.values.includes(value)))
|
|
21708
|
-
issues.push(issue2(
|
|
21710
|
+
issues.push(issue2(path24, "INVALID_COMPONENT_PROP_VALUE", "value is not an allowed finite number"));
|
|
21709
21711
|
if (schema.kind === "string" && (typeof value !== "string" || schema.values && !schema.values.includes(value)))
|
|
21710
|
-
issues.push(issue2(
|
|
21712
|
+
issues.push(issue2(path24, "INVALID_COMPONENT_PROP_VALUE", "value is not an allowed string"));
|
|
21711
21713
|
}
|
|
21712
21714
|
function isDisplayBinding(value, stringOnly = false) {
|
|
21713
21715
|
if (!isPlainRecord(value) || typeof value.path !== "string" || !isSafePath(value.path))
|
|
@@ -21721,132 +21723,132 @@ function isStrictBinding(value) {
|
|
|
21721
21723
|
function isSafePath(value) {
|
|
21722
21724
|
return (value === "/" || value.startsWith("/") || value.startsWith("./")) && !value.split("/").some((part) => ["__proto__", "constructor", "prototype"].includes(part));
|
|
21723
21725
|
}
|
|
21724
|
-
function validateAction(value,
|
|
21726
|
+
function validateAction(value, path24, issues, depth) {
|
|
21725
21727
|
if (!isPlainRecord(value) || depth > 4) {
|
|
21726
|
-
issues.push(issue2(
|
|
21728
|
+
issues.push(issue2(path24, "INVALID_ACTION", "action must be an object with at most four nested selects"));
|
|
21727
21729
|
return;
|
|
21728
21730
|
}
|
|
21729
21731
|
const branches = ["event", "function", "local", "client", "select"].filter((key) => key in value);
|
|
21730
21732
|
if (branches.length !== 1 || Object.keys(value).length !== 1) {
|
|
21731
|
-
issues.push(issue2(
|
|
21733
|
+
issues.push(issue2(path24, "INVALID_ACTION", "action must contain exactly one branch"));
|
|
21732
21734
|
return;
|
|
21733
21735
|
}
|
|
21734
21736
|
const branch = branches[0];
|
|
21735
21737
|
const body = value[branch];
|
|
21736
21738
|
if (!isPlainRecord(body))
|
|
21737
|
-
return void issues.push(issue2(`${
|
|
21739
|
+
return void issues.push(issue2(`${path24}.${branch}`, "INVALID_ACTION", `${branch} must be an object`));
|
|
21738
21740
|
if (branch === "event") {
|
|
21739
|
-
rejectUnknownKeys(body, ["name", "context", "x2-user-message", "target"], `${
|
|
21741
|
+
rejectUnknownKeys(body, ["name", "context", "x2-user-message", "target"], `${path24}.event`, issues);
|
|
21740
21742
|
if (typeof body.name !== "string" || !/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/.test(body.name) || body.name.length > 96)
|
|
21741
|
-
issues.push(issue2(`${
|
|
21743
|
+
issues.push(issue2(`${path24}.event.name`, "INVALID_ACTION_NAME", "event name is invalid"));
|
|
21742
21744
|
if (body.context !== void 0 && !isPlainRecord(body.context))
|
|
21743
|
-
issues.push(issue2(`${
|
|
21745
|
+
issues.push(issue2(`${path24}.event.context`, "INVALID_ACTION_CONTEXT", "event context must be an object"));
|
|
21744
21746
|
else if (body.context !== void 0)
|
|
21745
|
-
validateActionDynamicValue(body.context, `${
|
|
21747
|
+
validateActionDynamicValue(body.context, `${path24}.event.context`, issues);
|
|
21746
21748
|
if (body["x2-user-message"] !== void 0 && typeof body["x2-user-message"] !== "string" && !isStrictBinding(body["x2-user-message"]))
|
|
21747
|
-
issues.push(issue2(`${
|
|
21749
|
+
issues.push(issue2(`${path24}.event.x2-user-message`, "INVALID_ACTION_CONTEXT", "x2-user-message must be a string or strict binding"));
|
|
21748
21750
|
if (body.target !== void 0)
|
|
21749
|
-
validateOverlayTarget(body.target, `${
|
|
21751
|
+
validateOverlayTarget(body.target, `${path24}.event.target`, issues);
|
|
21750
21752
|
} else if (branch === "function") {
|
|
21751
|
-
rejectUnknownKeys(body, ["ref"], `${
|
|
21753
|
+
rejectUnknownKeys(body, ["ref"], `${path24}.function`, issues);
|
|
21752
21754
|
if (!isFunctionActionRef(body.ref))
|
|
21753
|
-
issues.push(issue2(`${
|
|
21755
|
+
issues.push(issue2(`${path24}.function.ref`, "INVALID_FUNCTION_ACTION_REF", "function ref must be a dot-separated identifier up to 128 characters"));
|
|
21754
21756
|
} else if (branch === "local") {
|
|
21755
|
-
rejectUnknownKeys(body, ["name", "path", "value"], `${
|
|
21757
|
+
rejectUnknownKeys(body, ["name", "path", "value"], `${path24}.local`, issues);
|
|
21756
21758
|
if (body.name !== "data.set" || typeof body.path !== "string" || !isSafePath(body.path) || !Object.prototype.hasOwnProperty.call(body, "value"))
|
|
21757
|
-
issues.push(issue2(`${
|
|
21759
|
+
issues.push(issue2(`${path24}.local`, "INVALID_LOCAL_ACTION", "local action must be data.set with a safe path and value"));
|
|
21758
21760
|
else
|
|
21759
|
-
validateActionDynamicValue(body.value, `${
|
|
21761
|
+
validateActionDynamicValue(body.value, `${path24}.local.value`, issues);
|
|
21760
21762
|
} else if (branch === "client") {
|
|
21761
|
-
validateClientAction(body, `${
|
|
21763
|
+
validateClientAction(body, `${path24}.client`, issues);
|
|
21762
21764
|
} else {
|
|
21763
|
-
rejectUnknownKeys(body, ["value", "cases", "default"], `${
|
|
21765
|
+
rejectUnknownKeys(body, ["value", "cases", "default"], `${path24}.select`, issues);
|
|
21764
21766
|
if (!isStrictBinding(body.value) || !Array.isArray(body.cases) || body.cases.length < 1 || body.cases.length > 16)
|
|
21765
|
-
return void issues.push(issue2(`${
|
|
21767
|
+
return void issues.push(issue2(`${path24}.select`, "INVALID_SELECT_ACTION", "select requires a strict binding and 1-16 cases"));
|
|
21766
21768
|
const seen = /* @__PURE__ */ new Set();
|
|
21767
21769
|
body.cases.forEach((entry, index) => {
|
|
21768
21770
|
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"))
|
|
21769
|
-
return void issues.push(issue2(`${
|
|
21771
|
+
return void issues.push(issue2(`${path24}.select.cases[${index}]`, "INVALID_SELECT_CASE", "case requires only a primitive equals and action"));
|
|
21770
21772
|
const key = JSON.stringify([typeof entry.equals, entry.equals]);
|
|
21771
21773
|
if (seen.has(key))
|
|
21772
|
-
issues.push(issue2(`${
|
|
21774
|
+
issues.push(issue2(`${path24}.select.cases[${index}].equals`, "DUPLICATE_SELECT_CASE", "select case values must be unique"));
|
|
21773
21775
|
seen.add(key);
|
|
21774
|
-
validateAction(entry.action, `${
|
|
21776
|
+
validateAction(entry.action, `${path24}.select.cases[${index}].action`, issues, depth + 1);
|
|
21775
21777
|
});
|
|
21776
21778
|
if (body.default !== void 0)
|
|
21777
|
-
validateAction(body.default, `${
|
|
21779
|
+
validateAction(body.default, `${path24}.select.default`, issues, depth + 1);
|
|
21778
21780
|
}
|
|
21779
21781
|
}
|
|
21780
21782
|
function isFunctionActionRef(value) {
|
|
21781
21783
|
return typeof value === "string" && value.length <= 128 && /^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u.test(value);
|
|
21782
21784
|
}
|
|
21783
|
-
function validateClientAction(body,
|
|
21784
|
-
rejectUnknownKeys(body, ["name", "context"],
|
|
21785
|
+
function validateClientAction(body, path24, issues) {
|
|
21786
|
+
rejectUnknownKeys(body, ["name", "context"], path24, issues);
|
|
21785
21787
|
if (body.name === "ui.overlay.close") {
|
|
21786
21788
|
if (body.context !== void 0)
|
|
21787
|
-
issues.push(issue2(`${
|
|
21789
|
+
issues.push(issue2(`${path24}.context`, "INVALID_CLIENT_ACTION_CONTEXT", "ui.overlay.close does not accept context"));
|
|
21788
21790
|
return;
|
|
21789
21791
|
}
|
|
21790
21792
|
if (body.name === "ui.surface.open") {
|
|
21791
21793
|
if (!isPlainRecord(body.context) || Object.keys(body.context).length !== 1 || typeof body.context.surfaceId !== "string")
|
|
21792
|
-
issues.push(issue2(`${
|
|
21794
|
+
issues.push(issue2(`${path24}.context`, "INVALID_CLIENT_ACTION_CONTEXT", "ui.surface.open requires context.surfaceId"));
|
|
21793
21795
|
return;
|
|
21794
21796
|
}
|
|
21795
21797
|
if (body.name === "ui.page.open") {
|
|
21796
21798
|
if (!isPlainRecord(body.context) || Object.keys(body.context).length !== 1 || typeof body.context.url !== "string" && !isStrictBinding(body.context.url))
|
|
21797
|
-
issues.push(issue2(`${
|
|
21799
|
+
issues.push(issue2(`${path24}.context`, "INVALID_CLIENT_ACTION_CONTEXT", "ui.page.open requires one literal or bound URL"));
|
|
21798
21800
|
else if (typeof body.context.url === "string" && !isSafePageUrl(body.context.url))
|
|
21799
|
-
issues.push(issue2(`${
|
|
21801
|
+
issues.push(issue2(`${path24}.context.url`, "INVALID_PAGE_URL", "ui.page.open URL must use https or the approved Alipay scheme"));
|
|
21800
21802
|
return;
|
|
21801
21803
|
}
|
|
21802
21804
|
if (body.name === "payment.trade-pay") {
|
|
21803
|
-
validatePaymentActionContext(body.context, `${
|
|
21805
|
+
validatePaymentActionContext(body.context, `${path24}.context`, issues);
|
|
21804
21806
|
return;
|
|
21805
21807
|
}
|
|
21806
|
-
issues.push(issue2(`${
|
|
21808
|
+
issues.push(issue2(`${path24}.name`, "UNSUPPORTED_CLIENT_ACTION", `unsupported client action ${String(body.name)}`));
|
|
21807
21809
|
}
|
|
21808
|
-
function validatePaymentActionContext(value,
|
|
21810
|
+
function validatePaymentActionContext(value, path24, issues) {
|
|
21809
21811
|
if (!isPlainRecord(value)) {
|
|
21810
|
-
issues.push(issue2(
|
|
21812
|
+
issues.push(issue2(path24, "INVALID_CLIENT_ACTION_CONTEXT", "payment.trade-pay requires createTrade and onSuccess"));
|
|
21811
21813
|
return;
|
|
21812
21814
|
}
|
|
21813
|
-
rejectUnknownKeys(value, ["createTrade", "onSuccess"],
|
|
21815
|
+
rejectUnknownKeys(value, ["createTrade", "onSuccess"], path24, issues);
|
|
21814
21816
|
const createTrade = isPlainRecord(value.createTrade) ? value.createTrade : void 0;
|
|
21815
21817
|
if (!createTrade) {
|
|
21816
|
-
issues.push(issue2(`${
|
|
21818
|
+
issues.push(issue2(`${path24}.createTrade`, "INVALID_PAYMENT_CREATE_TRADE", "createTrade must be an object"));
|
|
21817
21819
|
} else {
|
|
21818
|
-
rejectUnknownKeys(createTrade, ["mcpResourceId", "toolName", "input", "tradeNoPath"], `${
|
|
21820
|
+
rejectUnknownKeys(createTrade, ["mcpResourceId", "toolName", "input", "tradeNoPath"], `${path24}.createTrade`, issues);
|
|
21819
21821
|
if (!isSafeIdentifier(createTrade.mcpResourceId))
|
|
21820
|
-
issues.push(issue2(`${
|
|
21822
|
+
issues.push(issue2(`${path24}.createTrade.mcpResourceId`, "INVALID_MCP_RESOURCE_ID", "mcpResourceId is invalid"));
|
|
21821
21823
|
if (typeof createTrade.toolName !== "string" || !createTrade.toolName.trim())
|
|
21822
|
-
issues.push(issue2(`${
|
|
21824
|
+
issues.push(issue2(`${path24}.createTrade.toolName`, "INVALID_TOOL_NAME", "toolName is required"));
|
|
21823
21825
|
if (!isPlainRecord(createTrade.input))
|
|
21824
|
-
issues.push(issue2(`${
|
|
21826
|
+
issues.push(issue2(`${path24}.createTrade.input`, "INVALID_PAYMENT_INPUT", "input must be an object"));
|
|
21825
21827
|
else
|
|
21826
|
-
validateActionDynamicValue(createTrade.input, `${
|
|
21828
|
+
validateActionDynamicValue(createTrade.input, `${path24}.createTrade.input`, issues);
|
|
21827
21829
|
if (!isSafeJsonPointer(createTrade.tradeNoPath))
|
|
21828
|
-
issues.push(issue2(`${
|
|
21830
|
+
issues.push(issue2(`${path24}.createTrade.tradeNoPath`, "INVALID_TRADE_NO_PATH", "tradeNoPath must be an absolute JSON Pointer"));
|
|
21829
21831
|
}
|
|
21830
21832
|
const onSuccess = isPlainRecord(value.onSuccess) ? value.onSuccess : void 0;
|
|
21831
21833
|
const event = onSuccess && isPlainRecord(onSuccess.event) ? onSuccess.event : void 0;
|
|
21832
21834
|
if (!onSuccess || !event) {
|
|
21833
|
-
issues.push(issue2(`${
|
|
21835
|
+
issues.push(issue2(`${path24}.onSuccess`, "INVALID_PAYMENT_SUCCESS_EVENT", "onSuccess.event is required"));
|
|
21834
21836
|
return;
|
|
21835
21837
|
}
|
|
21836
|
-
rejectUnknownKeys(onSuccess, ["event"], `${
|
|
21837
|
-
rejectUnknownKeys(event, ["name", "context", "x2-user-message"], `${
|
|
21838
|
+
rejectUnknownKeys(onSuccess, ["event"], `${path24}.onSuccess`, issues);
|
|
21839
|
+
rejectUnknownKeys(event, ["name", "context", "x2-user-message"], `${path24}.onSuccess.event`, issues);
|
|
21838
21840
|
if (typeof event.name !== "string" || !/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/.test(event.name) || event.name.length > 96)
|
|
21839
|
-
issues.push(issue2(`${
|
|
21841
|
+
issues.push(issue2(`${path24}.onSuccess.event.name`, "INVALID_ACTION_NAME", "event name is invalid"));
|
|
21840
21842
|
if (event.context !== void 0 && !isPlainRecord(event.context))
|
|
21841
|
-
issues.push(issue2(`${
|
|
21843
|
+
issues.push(issue2(`${path24}.onSuccess.event.context`, "INVALID_ACTION_CONTEXT", "event context must be an object"));
|
|
21842
21844
|
else if (event.context !== void 0)
|
|
21843
|
-
validateActionDynamicValue(event.context, `${
|
|
21845
|
+
validateActionDynamicValue(event.context, `${path24}.onSuccess.event.context`, issues);
|
|
21844
21846
|
if (typeof event["x2-user-message"] !== "string" || !event["x2-user-message"].trim())
|
|
21845
|
-
issues.push(issue2(`${
|
|
21847
|
+
issues.push(issue2(`${path24}.onSuccess.event.x2-user-message`, "INVALID_ACTION_CONTEXT", "x2-user-message must be a non-empty string"));
|
|
21846
21848
|
}
|
|
21847
|
-
function validateActionDynamicValue(value,
|
|
21849
|
+
function validateActionDynamicValue(value, path24, issues) {
|
|
21848
21850
|
if (Array.isArray(value)) {
|
|
21849
|
-
value.forEach((entry, index) => validateActionDynamicValue(entry, `${
|
|
21851
|
+
value.forEach((entry, index) => validateActionDynamicValue(entry, `${path24}[${index}]`, issues));
|
|
21850
21852
|
return;
|
|
21851
21853
|
}
|
|
21852
21854
|
if (!isPlainRecord(value))
|
|
@@ -21854,94 +21856,94 @@ function validateActionDynamicValue(value, path23, issues) {
|
|
|
21854
21856
|
const keys = Object.keys(value);
|
|
21855
21857
|
if (keys.includes("path") && keys.every((key) => key === "path" || key === "fallback")) {
|
|
21856
21858
|
if (!isStrictBinding(value))
|
|
21857
|
-
issues.push(issue2(
|
|
21859
|
+
issues.push(issue2(path24, "INVALID_ACTION_BINDING", "action values require a strict binding without fallback"));
|
|
21858
21860
|
return;
|
|
21859
21861
|
}
|
|
21860
|
-
Object.entries(value).forEach(([key, entry]) => validateActionDynamicValue(entry, `${
|
|
21862
|
+
Object.entries(value).forEach(([key, entry]) => validateActionDynamicValue(entry, `${path24}.${key}`, issues));
|
|
21861
21863
|
}
|
|
21862
|
-
function validateOverlayTarget(value,
|
|
21864
|
+
function validateOverlayTarget(value, path24, issues) {
|
|
21863
21865
|
if (!isPlainRecord(value) || value.type !== "overlay" || !isPlainRecord(value.presentation) || value.presentation.kind !== "bottom-sheet")
|
|
21864
|
-
issues.push(issue2(
|
|
21866
|
+
issues.push(issue2(path24, "INVALID_EVENT_TARGET", "event target must be an overlay bottom-sheet presentation"));
|
|
21865
21867
|
}
|
|
21866
|
-
function validateOptions(value,
|
|
21868
|
+
function validateOptions(value, path24, issues) {
|
|
21867
21869
|
if (isStrictBinding(value))
|
|
21868
21870
|
return;
|
|
21869
21871
|
if (!Array.isArray(value) || value.length === 0)
|
|
21870
|
-
return void issues.push(issue2(
|
|
21872
|
+
return void issues.push(issue2(path24, "INVALID_OPTIONS", "options must be a non-empty array"));
|
|
21871
21873
|
const seen = /* @__PURE__ */ new Set();
|
|
21872
21874
|
value.forEach((entry, index) => {
|
|
21873
21875
|
if (!isPlainRecord(entry) || Object.keys(entry).some((key) => key !== "label" && key !== "value") || typeof entry.label !== "string" || !entry.label || typeof entry.value !== "string" || !entry.value)
|
|
21874
|
-
issues.push(issue2(`${
|
|
21876
|
+
issues.push(issue2(`${path24}[${index}]`, "INVALID_OPTION", "option requires only non-empty label and value"));
|
|
21875
21877
|
else if (seen.has(entry.value))
|
|
21876
|
-
issues.push(issue2(`${
|
|
21878
|
+
issues.push(issue2(`${path24}[${index}].value`, "DUPLICATE_OPTION_VALUE", "option values must be unique"));
|
|
21877
21879
|
else
|
|
21878
21880
|
seen.add(entry.value);
|
|
21879
21881
|
});
|
|
21880
21882
|
}
|
|
21881
|
-
function validateTextField(component,
|
|
21883
|
+
function validateTextField(component, path24, issues) {
|
|
21882
21884
|
if (!isStrictBinding(component.value))
|
|
21883
|
-
issues.push(issue2(`${
|
|
21885
|
+
issues.push(issue2(`${path24}.value`, "INPUT_REQUIRES_BINDING", "TextField.value must be a strict writable binding"));
|
|
21884
21886
|
if (component["x2-limit"] !== void 0 && (!Number.isInteger(component["x2-limit"]) || Number(component["x2-limit"]) < 1 || Number(component["x2-limit"]) > 1e4))
|
|
21885
|
-
issues.push(issue2(`${
|
|
21887
|
+
issues.push(issue2(`${path24}.x2-limit`, "INVALID_TEXT_LIMIT", "x2-limit must be an integer from 1 to 10000"));
|
|
21886
21888
|
if (typeof component.validationRegexp === "string") {
|
|
21887
21889
|
if (component.validationRegexp.length > 512)
|
|
21888
|
-
issues.push(issue2(`${
|
|
21890
|
+
issues.push(issue2(`${path24}.validationRegexp`, "INVALID_VALIDATION_REGEXP", "validationRegexp is too long"));
|
|
21889
21891
|
else
|
|
21890
21892
|
try {
|
|
21891
21893
|
new RegExp(component.validationRegexp);
|
|
21892
21894
|
} catch {
|
|
21893
|
-
issues.push(issue2(`${
|
|
21895
|
+
issues.push(issue2(`${path24}.validationRegexp`, "INVALID_VALIDATION_REGEXP", "validationRegexp is invalid"));
|
|
21894
21896
|
}
|
|
21895
21897
|
}
|
|
21896
21898
|
}
|
|
21897
|
-
function validateStepper(component,
|
|
21899
|
+
function validateStepper(component, path24, issues) {
|
|
21898
21900
|
if (!isStrictBinding(component.value))
|
|
21899
|
-
issues.push(issue2(`${
|
|
21901
|
+
issues.push(issue2(`${path24}.value`, "INPUT_REQUIRES_BINDING", "Stepper.value must be a strict writable binding"));
|
|
21900
21902
|
if (component.step !== void 0 && (!Number.isFinite(component.step) || Number(component.step) <= 0))
|
|
21901
|
-
issues.push(issue2(`${
|
|
21903
|
+
issues.push(issue2(`${path24}.step`, "INVALID_STEPPER_RANGE", "step must be greater than zero"));
|
|
21902
21904
|
if (Number.isFinite(component.min) && Number.isFinite(component.max) && Number(component.min) > Number(component.max))
|
|
21903
|
-
issues.push(issue2(`${
|
|
21905
|
+
issues.push(issue2(`${path24}`, "INVALID_STEPPER_RANGE", "min must not exceed max"));
|
|
21904
21906
|
}
|
|
21905
|
-
function validateChecks(value,
|
|
21907
|
+
function validateChecks(value, path24, issues) {
|
|
21906
21908
|
if (!Array.isArray(value))
|
|
21907
|
-
return void issues.push(issue2(
|
|
21909
|
+
return void issues.push(issue2(path24, "INVALID_CHECKS", "checks must be an array"));
|
|
21908
21910
|
value.forEach((entry, index) => {
|
|
21909
21911
|
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") {
|
|
21910
|
-
issues.push(issue2(`${
|
|
21912
|
+
issues.push(issue2(`${path24}[${index}]`, "INVALID_CHECK", "check must be an implemented required check with a strict binding"));
|
|
21911
21913
|
}
|
|
21912
21914
|
});
|
|
21913
21915
|
}
|
|
21914
|
-
function validateOverflow(component,
|
|
21916
|
+
function validateOverflow(component, path24, issues) {
|
|
21915
21917
|
const value = component["x2-overflow"];
|
|
21916
21918
|
const children = component.children;
|
|
21917
21919
|
if (!isPlainRecord(children) || !isPlainRecord(value)) {
|
|
21918
|
-
issues.push(issue2(`${
|
|
21920
|
+
issues.push(issue2(`${path24}.x2-overflow`, "INVALID_OVERFLOW", "x2-overflow requires dynamic children and an object value"));
|
|
21919
21921
|
return;
|
|
21920
21922
|
}
|
|
21921
|
-
rejectUnknownKeys(value, ["mode", "previewCount", "trigger", "overlay"], `${
|
|
21923
|
+
rejectUnknownKeys(value, ["mode", "previewCount", "trigger", "overlay"], `${path24}.x2-overflow`, issues);
|
|
21922
21924
|
if (value.mode !== "overlay-all" || !Number.isInteger(value.previewCount) || Number(value.previewCount) < 0 || Number(value.previewCount) > 100) {
|
|
21923
|
-
issues.push(issue2(`${
|
|
21925
|
+
issues.push(issue2(`${path24}.x2-overflow`, "INVALID_OVERFLOW", "overlay-all requires an integer previewCount from 0 to 100"));
|
|
21924
21926
|
}
|
|
21925
21927
|
if (!isPlainRecord(value.trigger)) {
|
|
21926
|
-
issues.push(issue2(`${
|
|
21928
|
+
issues.push(issue2(`${path24}.x2-overflow.trigger`, "INVALID_OVERFLOW_TRIGGER", "trigger must contain display text"));
|
|
21927
21929
|
} else {
|
|
21928
|
-
rejectUnknownKeys(value.trigger, ["text"], `${
|
|
21930
|
+
rejectUnknownKeys(value.trigger, ["text"], `${path24}.x2-overflow.trigger`, issues);
|
|
21929
21931
|
if (!isDisplayBinding(value.trigger.text, true) && typeof value.trigger.text !== "string") {
|
|
21930
|
-
issues.push(issue2(`${
|
|
21932
|
+
issues.push(issue2(`${path24}.x2-overflow.trigger.text`, "INVALID_OVERFLOW_TRIGGER", "trigger.text must be a string or display binding"));
|
|
21931
21933
|
}
|
|
21932
21934
|
}
|
|
21933
21935
|
if (!isPlainRecord(value.overlay)) {
|
|
21934
|
-
issues.push(issue2(`${
|
|
21936
|
+
issues.push(issue2(`${path24}.x2-overflow.overlay`, "INVALID_OVERFLOW_PRESENTATION", "overlay must be a bottom-sheet presentation"));
|
|
21935
21937
|
} else {
|
|
21936
|
-
rejectUnknownKeys(value.overlay, ["kind", "title", "size"], `${
|
|
21938
|
+
rejectUnknownKeys(value.overlay, ["kind", "title", "size"], `${path24}.x2-overflow.overlay`, issues);
|
|
21937
21939
|
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))) {
|
|
21938
|
-
issues.push(issue2(`${
|
|
21940
|
+
issues.push(issue2(`${path24}.x2-overflow.overlay`, "INVALID_OVERFLOW_PRESENTATION", "overlay must be a bottom-sheet with an optional string title and supported size"));
|
|
21939
21941
|
}
|
|
21940
21942
|
}
|
|
21941
21943
|
}
|
|
21942
|
-
function validateNumberFormat(value,
|
|
21944
|
+
function validateNumberFormat(value, path24, issues) {
|
|
21943
21945
|
if (!isPlainRecord(value))
|
|
21944
|
-
return void issues.push(issue2(
|
|
21946
|
+
return void issues.push(issue2(path24, "INVALID_NUMBER_FORMAT", "format must be an object"));
|
|
21945
21947
|
rejectUnknownKeys(value, [
|
|
21946
21948
|
"type",
|
|
21947
21949
|
"style",
|
|
@@ -21952,40 +21954,40 @@ function validateNumberFormat(value, path23, issues) {
|
|
|
21952
21954
|
"useGrouping",
|
|
21953
21955
|
"prefix",
|
|
21954
21956
|
"suffix"
|
|
21955
|
-
],
|
|
21957
|
+
], path24, issues);
|
|
21956
21958
|
const style = value.style ?? "decimal";
|
|
21957
21959
|
const digit = (entry) => entry === void 0 || Number.isInteger(entry) && Number(entry) >= 0 && Number(entry) <= 20;
|
|
21958
21960
|
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)) {
|
|
21959
|
-
issues.push(issue2(
|
|
21961
|
+
issues.push(issue2(path24, "INVALID_NUMBER_FORMAT", "number format options are invalid"));
|
|
21960
21962
|
}
|
|
21961
21963
|
}
|
|
21962
|
-
function rejectUnknownKeys(value, allowed,
|
|
21964
|
+
function rejectUnknownKeys(value, allowed, path24, issues) {
|
|
21963
21965
|
const allowedKeys = new Set(allowed);
|
|
21964
21966
|
Object.keys(value).forEach((key) => {
|
|
21965
21967
|
if (!allowedKeys.has(key))
|
|
21966
|
-
issues.push(issue2(`${
|
|
21968
|
+
issues.push(issue2(`${path24}.${key}`, "UNKNOWN_PROTOCOL_FIELD", `unknown field ${key}`));
|
|
21967
21969
|
});
|
|
21968
21970
|
}
|
|
21969
21971
|
function isSafePageUrl(value) {
|
|
21970
21972
|
return value.length <= 2e3 && (value.startsWith("https://") || value.startsWith("alipays://"));
|
|
21971
21973
|
}
|
|
21972
|
-
function validateReferences(surfaces,
|
|
21974
|
+
function validateReferences(surfaces, path24, issues) {
|
|
21973
21975
|
for (const [surfaceId, components] of surfaces) {
|
|
21974
21976
|
if (!components.has("root"))
|
|
21975
|
-
issues.push(issue2(`${
|
|
21977
|
+
issues.push(issue2(`${path24}.surfaces.${surfaceId}`, "MISSING_ROOT_COMPONENT", "surface must define root"));
|
|
21976
21978
|
const edges = /* @__PURE__ */ new Map();
|
|
21977
21979
|
for (const [id, component] of components) {
|
|
21978
21980
|
const refs = getComponentReferences(component);
|
|
21979
21981
|
edges.set(id, refs);
|
|
21980
21982
|
refs.forEach((ref) => {
|
|
21981
21983
|
if (!components.has(ref))
|
|
21982
|
-
issues.push(issue2(`${
|
|
21984
|
+
issues.push(issue2(`${path24}.surfaces.${surfaceId}.components.${id}.${component.child !== void 0 ? "child" : "children"}`, "MISSING_COMPONENT_REFERENCE", `component ${ref} does not exist`));
|
|
21983
21985
|
});
|
|
21984
21986
|
if ((component.component === "Button" || component.component === "Card" && component.action !== void 0) && refs.some((ref) => hasInteractiveDescendant(ref, components, /* @__PURE__ */ new Set())))
|
|
21985
|
-
issues.push(issue2(`${
|
|
21987
|
+
issues.push(issue2(`${path24}.surfaces.${surfaceId}.components.${id}.${component.child !== void 0 ? "child" : "children"}`, "NESTED_INTERACTION", "action components cannot contain interactive descendants"));
|
|
21986
21988
|
collectSurfaceOpenReferences(component.action).forEach((targetSurfaceId) => {
|
|
21987
21989
|
if (!surfaces.has(targetSurfaceId))
|
|
21988
|
-
issues.push(issue2(`${
|
|
21990
|
+
issues.push(issue2(`${path24}.surfaces.${surfaceId}.components.${id}.action`, "MISSING_SURFACE_REFERENCE", `surface ${targetSurfaceId} does not exist`));
|
|
21989
21991
|
});
|
|
21990
21992
|
}
|
|
21991
21993
|
components.forEach((component, id) => {
|
|
@@ -21993,14 +21995,14 @@ function validateReferences(surfaces, path23, issues) {
|
|
|
21993
21995
|
return;
|
|
21994
21996
|
const parents = [...components.values()].filter((parent) => getComponentReferences(parent).includes(id));
|
|
21995
21997
|
if (id === "root" || parents.length === 0 || parents.some((parent) => parent.component !== "Row" && parent.component !== "Column")) {
|
|
21996
|
-
issues.push(issue2(`${
|
|
21998
|
+
issues.push(issue2(`${path24}.surfaces.${surfaceId}.components.${id}.grow`, "INVALID_LAYOUT_PARENT", "grow requires a direct Row or Column parent in every occurrence"));
|
|
21997
21999
|
}
|
|
21998
22000
|
});
|
|
21999
22001
|
const visiting = /* @__PURE__ */ new Set();
|
|
22000
22002
|
const visited = /* @__PURE__ */ new Set();
|
|
22001
22003
|
const walk = (id) => {
|
|
22002
22004
|
if (visiting.has(id))
|
|
22003
|
-
return void issues.push(issue2(`${
|
|
22005
|
+
return void issues.push(issue2(`${path24}.surfaces.${surfaceId}.components.${id}`, "CIRCULAR_COMPONENT_REFERENCE", "component references must not contain a cycle"));
|
|
22004
22006
|
if (visited.has(id))
|
|
22005
22007
|
return;
|
|
22006
22008
|
visiting.add(id);
|
|
@@ -22101,29 +22103,29 @@ function getA2UICardDraftBundleIssues(value) {
|
|
|
22101
22103
|
}
|
|
22102
22104
|
return issues;
|
|
22103
22105
|
}
|
|
22104
|
-
function getPersistedV4ProtocolIssues(card,
|
|
22106
|
+
function getPersistedV4ProtocolIssues(card, path24) {
|
|
22105
22107
|
const issues = [];
|
|
22106
22108
|
if (card.length !== 1) {
|
|
22107
|
-
issues.push(issue2(
|
|
22109
|
+
issues.push(issue2(path24, "INVALID_PERSISTED_V4_MESSAGES", "V4 persisted cards must use exactly one message"));
|
|
22108
22110
|
}
|
|
22109
22111
|
const instructions = card.flatMap((message) => message.datas);
|
|
22110
22112
|
const creates = instructions.filter((instruction) => "createSurface" in instruction);
|
|
22111
22113
|
const updates = instructions.filter((instruction) => "updateComponents" in instruction);
|
|
22112
22114
|
if (creates.length < 1 || creates.length !== updates.length || instructions.length !== creates.length + updates.length) {
|
|
22113
|
-
issues.push(issue2(
|
|
22115
|
+
issues.push(issue2(path24, "INVALID_PERSISTED_V4_INSTRUCTIONS", "V4 persisted cards require one createSurface and one complete updateComponents per Surface"));
|
|
22114
22116
|
}
|
|
22115
22117
|
const createIds = creates.flatMap((instruction) => "createSurface" in instruction ? [instruction.createSurface.surfaceId] : []);
|
|
22116
22118
|
const updateIds = updates.flatMap((instruction) => "updateComponents" in instruction ? [instruction.updateComponents.surfaceId] : []);
|
|
22117
22119
|
for (const surfaceId of /* @__PURE__ */ new Set([...createIds, ...updateIds])) {
|
|
22118
22120
|
if (createIds.filter((id) => id === surfaceId).length !== 1 || updateIds.filter((id) => id === surfaceId).length !== 1) {
|
|
22119
|
-
issues.push(issue2(`${
|
|
22121
|
+
issues.push(issue2(`${path24}.surfaces.${surfaceId}`, "SURFACE_INSTRUCTION_MISMATCH", "each persisted Surface requires exactly one create and one component update"));
|
|
22120
22122
|
}
|
|
22121
22123
|
}
|
|
22122
22124
|
return issues;
|
|
22123
22125
|
}
|
|
22124
|
-
function validateV4Fixture(value, fields,
|
|
22126
|
+
function validateV4Fixture(value, fields, path24, issues) {
|
|
22125
22127
|
if (!isPlainRecord(value)) {
|
|
22126
|
-
issues.push(issue2(
|
|
22128
|
+
issues.push(issue2(path24, "INVALID_FIXTURE", "fixture must be a JSON object"));
|
|
22127
22129
|
return;
|
|
22128
22130
|
}
|
|
22129
22131
|
for (const field of fields) {
|
|
@@ -22132,17 +22134,17 @@ function validateV4Fixture(value, fields, path23, issues) {
|
|
|
22132
22134
|
const resolved = getFixtureValue(value, field.path);
|
|
22133
22135
|
if (!resolved.found) {
|
|
22134
22136
|
if (field.required)
|
|
22135
|
-
issues.push(issue2(`${
|
|
22137
|
+
issues.push(issue2(`${path24}${field.path}`, "REQUIRED_FIXTURE_FIELD_MISSING", `fixture is missing required field ${field.fieldId}`));
|
|
22136
22138
|
continue;
|
|
22137
22139
|
}
|
|
22138
|
-
issues.push(...validateJsonSchemaValue2(field.valueSchema, resolved.value, `${
|
|
22140
|
+
issues.push(...validateJsonSchemaValue2(field.valueSchema, resolved.value, `${path24}${field.path}`));
|
|
22139
22141
|
}
|
|
22140
22142
|
}
|
|
22141
|
-
function validateV4BindingContracts(card, occurrences, fields,
|
|
22143
|
+
function validateV4BindingContracts(card, occurrences, fields, path24, issues) {
|
|
22142
22144
|
const ordered = fields.slice().sort((left, right) => right.path.length - left.path.length);
|
|
22143
22145
|
for (const occurrence of occurrences) {
|
|
22144
22146
|
const field = ordered.find((candidate) => occurrence.canonicalPath === candidate.path || occurrence.canonicalPath.startsWith(`${candidate.path}/*/`) || occurrence.canonicalPath.startsWith(`${candidate.path}/`));
|
|
22145
|
-
const issuePath = `${
|
|
22147
|
+
const issuePath = `${path24}.surfaces.${occurrence.surfaceId ?? "unknown"}.components.${occurrence.componentId}.${occurrence.propertyPath}`;
|
|
22146
22148
|
if (!field) {
|
|
22147
22149
|
issues.push(issue2(issuePath, "UNDECLARED_BINDING_PATH", `binding path ${occurrence.rawPath} is not declared by a manifest field`));
|
|
22148
22150
|
continue;
|
|
@@ -22296,14 +22298,14 @@ function getA2UICardResourceConfigV3Issues(value) {
|
|
|
22296
22298
|
}
|
|
22297
22299
|
return issues;
|
|
22298
22300
|
}
|
|
22299
|
-
function validateDataSources(value,
|
|
22301
|
+
function validateDataSources(value, path24, issues, options = {}) {
|
|
22300
22302
|
if (!Array.isArray(value)) {
|
|
22301
|
-
issues.push(issue2(
|
|
22303
|
+
issues.push(issue2(path24, "INVALID_DATA_SOURCES", "dataSources must be a non-empty array"));
|
|
22302
22304
|
return void 0;
|
|
22303
22305
|
}
|
|
22304
22306
|
const ids = /* @__PURE__ */ new Set();
|
|
22305
22307
|
value.forEach((candidate, index) => {
|
|
22306
|
-
const itemPath = `${
|
|
22308
|
+
const itemPath = `${path24}[${index}]`;
|
|
22307
22309
|
if (!isPlainRecord(candidate)) {
|
|
22308
22310
|
issues.push(issue2(itemPath, "INVALID_DATA_SOURCE", "data source must be an object"));
|
|
22309
22311
|
return;
|
|
@@ -22341,7 +22343,7 @@ function validateDataSources(value, path23, issues, options = {}) {
|
|
|
22341
22343
|
for (const [index, source] of value.entries()) {
|
|
22342
22344
|
for (const dependency of source.dependsOn ?? []) {
|
|
22343
22345
|
if (!ids.has(dependency) || dependency === source.sourceId) {
|
|
22344
|
-
issues.push(issue2(`${
|
|
22346
|
+
issues.push(issue2(`${path24}[${index}].dependsOn`, "UNKNOWN_SOURCE_DEPENDENCY", `Unknown dependency ${dependency}`));
|
|
22345
22347
|
}
|
|
22346
22348
|
}
|
|
22347
22349
|
}
|
|
@@ -22360,18 +22362,18 @@ function validateDataSources(value, path23, issues, options = {}) {
|
|
|
22360
22362
|
return cyclic;
|
|
22361
22363
|
};
|
|
22362
22364
|
if ([...byId.keys()].some(visit)) {
|
|
22363
|
-
issues.push(issue2(
|
|
22365
|
+
issues.push(issue2(path24, "CYCLIC_SOURCE_DEPENDENCY", "data source dependencies must be acyclic"));
|
|
22364
22366
|
}
|
|
22365
22367
|
return value;
|
|
22366
22368
|
}
|
|
22367
|
-
function validateV3OutputBindings(value,
|
|
22369
|
+
function validateV3OutputBindings(value, path24, issues) {
|
|
22368
22370
|
if (!Array.isArray(value)) {
|
|
22369
|
-
issues.push(issue2(
|
|
22371
|
+
issues.push(issue2(path24, "INVALID_OUTPUT_BINDINGS", "bindings must be an array"));
|
|
22370
22372
|
return void 0;
|
|
22371
22373
|
}
|
|
22372
22374
|
const fields = /* @__PURE__ */ new Set();
|
|
22373
22375
|
value.forEach((candidate, index) => {
|
|
22374
|
-
const itemPath = `${
|
|
22376
|
+
const itemPath = `${path24}[${index}]`;
|
|
22375
22377
|
if (!isPlainRecord(candidate)) {
|
|
22376
22378
|
issues.push(issue2(itemPath, "INVALID_OUTPUT_BINDING", "binding must be an object"));
|
|
22377
22379
|
return;
|
|
@@ -22414,9 +22416,9 @@ function validateV3Coverage(fields, dataSources, bindings, issues, options = {})
|
|
|
22414
22416
|
}
|
|
22415
22417
|
}
|
|
22416
22418
|
}
|
|
22417
|
-
function validateV3BindingSelections(value,
|
|
22419
|
+
function validateV3BindingSelections(value, path24, fields, issues) {
|
|
22418
22420
|
if (!Array.isArray(value)) {
|
|
22419
|
-
issues.push(issue2(
|
|
22421
|
+
issues.push(issue2(path24, "INVALID_BINDINGS", "bindings must be an array"));
|
|
22420
22422
|
return;
|
|
22421
22423
|
}
|
|
22422
22424
|
if (value.length === 0)
|
|
@@ -22425,7 +22427,7 @@ function validateV3BindingSelections(value, path23, fields, issues) {
|
|
|
22425
22427
|
const outputBindings = [];
|
|
22426
22428
|
const dataSources = [];
|
|
22427
22429
|
value.forEach((candidate, index) => {
|
|
22428
|
-
const itemPath = `${
|
|
22430
|
+
const itemPath = `${path24}[${index}]`;
|
|
22429
22431
|
if (!isPlainRecord(candidate)) {
|
|
22430
22432
|
issues.push(issue2(itemPath, "INVALID_BINDING", "binding must be an object"));
|
|
22431
22433
|
return;
|
|
@@ -22470,24 +22472,24 @@ function validateV3BindingSelections(value, path23, fields, issues) {
|
|
|
22470
22472
|
});
|
|
22471
22473
|
}
|
|
22472
22474
|
});
|
|
22473
|
-
validateDataSources(dataSources, `${
|
|
22475
|
+
validateDataSources(dataSources, `${path24}.dataSources`, issues, {
|
|
22474
22476
|
validateOutputSchema: false
|
|
22475
22477
|
});
|
|
22476
|
-
validateV3OutputBindings(outputBindings, `${
|
|
22478
|
+
validateV3OutputBindings(outputBindings, `${path24}.outputs`, issues);
|
|
22477
22479
|
if (fields) {
|
|
22478
22480
|
validateV3Coverage(fields, dataSources, outputBindings, issues, {
|
|
22479
22481
|
requireComplete: false
|
|
22480
22482
|
});
|
|
22481
22483
|
}
|
|
22482
22484
|
}
|
|
22483
|
-
function validateManifest(value,
|
|
22485
|
+
function validateManifest(value, path24, issues) {
|
|
22484
22486
|
if (!isPlainRecord(value)) {
|
|
22485
|
-
issues.push(issue2(
|
|
22487
|
+
issues.push(issue2(path24, "INVALID_MANIFEST", `${path24} must be an object`));
|
|
22486
22488
|
return void 0;
|
|
22487
22489
|
}
|
|
22488
22490
|
if (value.schemaVersion === "3" || value.schemaVersion === "4") {
|
|
22489
22491
|
if (value.actionBindings !== void 0) {
|
|
22490
|
-
issues.push(issue2(`${
|
|
22492
|
+
issues.push(issue2(`${path24}.actionBindings`, "LEGACY_PAYMENT_ACTION_BINDINGS_UNSUPPORTED", "payment actions must be defined inline in card JSON"));
|
|
22491
22493
|
}
|
|
22492
22494
|
exactKeys(value, [
|
|
22493
22495
|
"schemaVersion",
|
|
@@ -22500,24 +22502,24 @@ function validateManifest(value, path23, issues) {
|
|
|
22500
22502
|
"whenNotToUse",
|
|
22501
22503
|
"fields",
|
|
22502
22504
|
"bindings"
|
|
22503
|
-
],
|
|
22505
|
+
], path24, issues);
|
|
22504
22506
|
if (!isSafeIdentifier(value.draftId)) {
|
|
22505
|
-
issues.push(issue2(`${
|
|
22507
|
+
issues.push(issue2(`${path24}.draftId`, "INVALID_DRAFT_ID", "draftId is invalid"));
|
|
22506
22508
|
}
|
|
22507
22509
|
if (!isSafeIdentifier(value.resourceId)) {
|
|
22508
|
-
issues.push(issue2(`${
|
|
22509
|
-
}
|
|
22510
|
-
optionalString(value.baseRevision, `${
|
|
22511
|
-
requiredString(value.displayName, `${
|
|
22512
|
-
requiredString(value.description, `${
|
|
22513
|
-
requiredString(value.whenToUse, `${
|
|
22514
|
-
optionalString(value.whenNotToUse, `${
|
|
22515
|
-
const fields2 = validateFields(value.fields, `${
|
|
22510
|
+
issues.push(issue2(`${path24}.resourceId`, "INVALID_RESOURCE_ID", "resourceId is invalid"));
|
|
22511
|
+
}
|
|
22512
|
+
optionalString(value.baseRevision, `${path24}.baseRevision`, issues);
|
|
22513
|
+
requiredString(value.displayName, `${path24}.displayName`, issues);
|
|
22514
|
+
requiredString(value.description, `${path24}.description`, issues);
|
|
22515
|
+
requiredString(value.whenToUse, `${path24}.whenToUse`, issues);
|
|
22516
|
+
optionalString(value.whenNotToUse, `${path24}.whenNotToUse`, issues);
|
|
22517
|
+
const fields2 = validateFields(value.fields, `${path24}.fields`, issues);
|
|
22516
22518
|
if (fields2?.some((field) => field.source === "invocation")) {
|
|
22517
|
-
issues.push(issue2(`${
|
|
22519
|
+
issues.push(issue2(`${path24}.fields`, "INVOCATION_FIELD_UNSUPPORTED", `schema v${value.schemaVersion} does not support invocation fields`));
|
|
22518
22520
|
}
|
|
22519
22521
|
if (value.bindings !== void 0) {
|
|
22520
|
-
validateV3BindingSelections(value.bindings, `${
|
|
22522
|
+
validateV3BindingSelections(value.bindings, `${path24}.bindings`, fields2, issues);
|
|
22521
22523
|
}
|
|
22522
22524
|
return fields2 ? value : void 0;
|
|
22523
22525
|
}
|
|
@@ -22533,37 +22535,37 @@ function validateManifest(value, path23, issues) {
|
|
|
22533
22535
|
"presentationInputSchema",
|
|
22534
22536
|
"fields",
|
|
22535
22537
|
"bindings"
|
|
22536
|
-
],
|
|
22538
|
+
], path24, issues);
|
|
22537
22539
|
if (value.schemaVersion !== "2") {
|
|
22538
|
-
issues.push(issue2(`${
|
|
22540
|
+
issues.push(issue2(`${path24}.schemaVersion`, "UNSUPPORTED_DRAFT_VERSION", "schemaVersion must be 2, 3 or 4"));
|
|
22539
22541
|
}
|
|
22540
22542
|
if (!isSafeIdentifier(value.draftId)) {
|
|
22541
|
-
issues.push(issue2(`${
|
|
22543
|
+
issues.push(issue2(`${path24}.draftId`, "INVALID_DRAFT_ID", "draftId is invalid"));
|
|
22542
22544
|
}
|
|
22543
22545
|
if (!isSafeIdentifier(value.resourceId)) {
|
|
22544
|
-
issues.push(issue2(`${
|
|
22545
|
-
}
|
|
22546
|
-
optionalString(value.baseRevision, `${
|
|
22547
|
-
requiredString(value.displayName, `${
|
|
22548
|
-
requiredString(value.description, `${
|
|
22549
|
-
requiredString(value.whenToUse, `${
|
|
22550
|
-
optionalString(value.whenNotToUse, `${
|
|
22551
|
-
const schema = validateLooseJsonSchema(value.presentationInputSchema, `${
|
|
22552
|
-
const fields = validateFields(value.fields, `${
|
|
22546
|
+
issues.push(issue2(`${path24}.resourceId`, "INVALID_RESOURCE_ID", "resourceId is invalid"));
|
|
22547
|
+
}
|
|
22548
|
+
optionalString(value.baseRevision, `${path24}.baseRevision`, issues);
|
|
22549
|
+
requiredString(value.displayName, `${path24}.displayName`, issues);
|
|
22550
|
+
requiredString(value.description, `${path24}.description`, issues);
|
|
22551
|
+
requiredString(value.whenToUse, `${path24}.whenToUse`, issues);
|
|
22552
|
+
optionalString(value.whenNotToUse, `${path24}.whenNotToUse`, issues);
|
|
22553
|
+
const schema = validateLooseJsonSchema(value.presentationInputSchema, `${path24}.presentationInputSchema`, issues);
|
|
22554
|
+
const fields = validateFields(value.fields, `${path24}.fields`, issues);
|
|
22553
22555
|
if (value.bindings !== void 0) {
|
|
22554
|
-
issues.push(...getA2UICardBindingSelectionIssues(value.bindings, `${
|
|
22556
|
+
issues.push(...getA2UICardBindingSelectionIssues(value.bindings, `${path24}.bindings`, fields));
|
|
22555
22557
|
}
|
|
22556
22558
|
return schema && fields ? value : void 0;
|
|
22557
22559
|
}
|
|
22558
|
-
function validateFields(value,
|
|
22560
|
+
function validateFields(value, path24, issues) {
|
|
22559
22561
|
if (!Array.isArray(value)) {
|
|
22560
|
-
issues.push(issue2(
|
|
22562
|
+
issues.push(issue2(path24, "INVALID_FIELDS", `${path24} must be an array`));
|
|
22561
22563
|
return void 0;
|
|
22562
22564
|
}
|
|
22563
22565
|
const ids = /* @__PURE__ */ new Set();
|
|
22564
22566
|
const paths = /* @__PURE__ */ new Set();
|
|
22565
22567
|
value.forEach((candidate, index) => {
|
|
22566
|
-
const itemPath = `${
|
|
22568
|
+
const itemPath = `${path24}[${index}]`;
|
|
22567
22569
|
if (!isPlainRecord(candidate)) {
|
|
22568
22570
|
issues.push(issue2(itemPath, "INVALID_FIELD", `${itemPath} must be an object`));
|
|
22569
22571
|
return;
|
|
@@ -22622,24 +22624,24 @@ function validateFields(value, path23, issues) {
|
|
|
22622
22624
|
function validateFieldPresentation(value, itemPath, issues) {
|
|
22623
22625
|
if (value === void 0)
|
|
22624
22626
|
return;
|
|
22625
|
-
const
|
|
22627
|
+
const path24 = `${itemPath}.presentation`;
|
|
22626
22628
|
if (!isPlainRecord(value)) {
|
|
22627
|
-
issues.push(issue2(
|
|
22629
|
+
issues.push(issue2(path24, "INVALID_FIELD_PRESENTATION", `${path24} must be an object`));
|
|
22628
22630
|
return;
|
|
22629
22631
|
}
|
|
22630
22632
|
if (!["echo", "reference-only", "never"].includes(String(value.visibility))) {
|
|
22631
|
-
issues.push(issue2(`${
|
|
22633
|
+
issues.push(issue2(`${path24}.visibility`, "INVALID_PRESENTATION_VISIBILITY", "presentation visibility must be echo, reference-only or never"));
|
|
22632
22634
|
}
|
|
22633
22635
|
if (value.labelPath !== void 0 && !isSafeJsonPointer(value.labelPath)) {
|
|
22634
|
-
issues.push(issue2(`${
|
|
22636
|
+
issues.push(issue2(`${path24}.labelPath`, "INVALID_PRESENTATION_PATH", "labelPath must be a safe JSON pointer"));
|
|
22635
22637
|
}
|
|
22636
22638
|
if (value.attributePaths !== void 0) {
|
|
22637
22639
|
if (!Array.isArray(value.attributePaths) || value.attributePaths.length > 3 || value.attributePaths.some((candidate) => !isSafeJsonPointer(candidate))) {
|
|
22638
|
-
issues.push(issue2(`${
|
|
22640
|
+
issues.push(issue2(`${path24}.attributePaths`, "INVALID_PRESENTATION_PATHS", "attributePaths must contain at most 3 safe JSON pointers"));
|
|
22639
22641
|
}
|
|
22640
22642
|
}
|
|
22641
22643
|
if (value.maxItems !== void 0 && (!Number.isInteger(value.maxItems) || Number(value.maxItems) < 1 || Number(value.maxItems) > 10)) {
|
|
22642
|
-
issues.push(issue2(`${
|
|
22644
|
+
issues.push(issue2(`${path24}.maxItems`, "INVALID_PRESENTATION_MAX_ITEMS", "maxItems must be an integer between 1 and 10"));
|
|
22643
22645
|
}
|
|
22644
22646
|
}
|
|
22645
22647
|
function validateFieldSource(candidate, itemPath, issues) {
|
|
@@ -22658,35 +22660,35 @@ function validateFieldSource(candidate, itemPath, issues) {
|
|
|
22658
22660
|
issues.push(issue2(`${itemPath}.runtimeContextKey`, "UNEXPECTED_RUNTIME_CONTEXT", "runtimeContextKey is only allowed for runtime-context fields"));
|
|
22659
22661
|
}
|
|
22660
22662
|
}
|
|
22661
|
-
function validateResolver(value,
|
|
22663
|
+
function validateResolver(value, path24, issues) {
|
|
22662
22664
|
if (!isPlainRecord(value)) {
|
|
22663
|
-
issues.push(issue2(
|
|
22665
|
+
issues.push(issue2(path24, "INVALID_RESOLVER", "resolver must be an object"));
|
|
22664
22666
|
return void 0;
|
|
22665
22667
|
}
|
|
22666
|
-
exactKeys(value, ["version", "calls", "outputBindings"],
|
|
22668
|
+
exactKeys(value, ["version", "calls", "outputBindings"], path24, issues);
|
|
22667
22669
|
if (value.version !== 2) {
|
|
22668
|
-
issues.push(issue2(`${
|
|
22670
|
+
issues.push(issue2(`${path24}.version`, "UNSUPPORTED_RESOLVER_VERSION", "resolver version must be 2"));
|
|
22669
22671
|
}
|
|
22670
|
-
const calls = validateResolverCalls(value.calls, `${
|
|
22671
|
-
const outputs = validateOutputBindings(value.outputBindings, `${
|
|
22672
|
+
const calls = validateResolverCalls(value.calls, `${path24}.calls`, issues);
|
|
22673
|
+
const outputs = validateOutputBindings(value.outputBindings, `${path24}.outputBindings`, issues);
|
|
22672
22674
|
if (!calls || !outputs)
|
|
22673
22675
|
return void 0;
|
|
22674
22676
|
const callIds = new Set(calls.map((call) => call.callId));
|
|
22675
22677
|
outputs.forEach((binding, index) => {
|
|
22676
22678
|
if (!callIds.has(binding.callId)) {
|
|
22677
|
-
issues.push(issue2(`${
|
|
22679
|
+
issues.push(issue2(`${path24}.outputBindings[${index}].callId`, "UNKNOWN_RESOLVER_CALL", `Unknown resolver call ${binding.callId}`));
|
|
22678
22680
|
}
|
|
22679
22681
|
});
|
|
22680
22682
|
return value;
|
|
22681
22683
|
}
|
|
22682
|
-
function validateResolverCalls(value,
|
|
22684
|
+
function validateResolverCalls(value, path24, issues) {
|
|
22683
22685
|
if (!Array.isArray(value)) {
|
|
22684
|
-
issues.push(issue2(
|
|
22686
|
+
issues.push(issue2(path24, "INVALID_RESOLVER_CALLS", "calls must be an array"));
|
|
22685
22687
|
return void 0;
|
|
22686
22688
|
}
|
|
22687
22689
|
const callIds = /* @__PURE__ */ new Set();
|
|
22688
22690
|
value.forEach((candidate, index) => {
|
|
22689
|
-
const itemPath = `${
|
|
22691
|
+
const itemPath = `${path24}[${index}]`;
|
|
22690
22692
|
if (!isPlainRecord(candidate)) {
|
|
22691
22693
|
issues.push(issue2(itemPath, "INVALID_RESOLVER_CALL", "call must be an object"));
|
|
22692
22694
|
return;
|
|
@@ -22707,14 +22709,14 @@ function validateResolverCalls(value, path23, issues) {
|
|
|
22707
22709
|
});
|
|
22708
22710
|
return value;
|
|
22709
22711
|
}
|
|
22710
|
-
function validateInputBindings2(value,
|
|
22712
|
+
function validateInputBindings2(value, path24, issues) {
|
|
22711
22713
|
if (!Array.isArray(value)) {
|
|
22712
|
-
issues.push(issue2(
|
|
22714
|
+
issues.push(issue2(path24, "INVALID_INPUT_BINDINGS", "inputBindings must be an array"));
|
|
22713
22715
|
return void 0;
|
|
22714
22716
|
}
|
|
22715
22717
|
const paths = /* @__PURE__ */ new Set();
|
|
22716
22718
|
value.forEach((candidate, index) => {
|
|
22717
|
-
const itemPath = `${
|
|
22719
|
+
const itemPath = `${path24}[${index}]`;
|
|
22718
22720
|
if (!isPlainRecord(candidate)) {
|
|
22719
22721
|
issues.push(issue2(itemPath, "INVALID_INPUT_BINDING", "binding must be an object"));
|
|
22720
22722
|
return;
|
|
@@ -22731,35 +22733,35 @@ function validateInputBindings2(value, path23, issues) {
|
|
|
22731
22733
|
});
|
|
22732
22734
|
return value;
|
|
22733
22735
|
}
|
|
22734
|
-
function validateInputSource(value,
|
|
22736
|
+
function validateInputSource(value, path24, issues) {
|
|
22735
22737
|
if (!isPlainRecord(value)) {
|
|
22736
|
-
issues.push(issue2(
|
|
22738
|
+
issues.push(issue2(path24, "INVALID_INPUT_SOURCE", "source must be an object"));
|
|
22737
22739
|
return;
|
|
22738
22740
|
}
|
|
22739
22741
|
if (value.kind === "invocation") {
|
|
22740
|
-
exactKeys(value, ["kind", "path"],
|
|
22742
|
+
exactKeys(value, ["kind", "path"], path24, issues);
|
|
22741
22743
|
if (!isSafeJsonPointer(value.path)) {
|
|
22742
|
-
issues.push(issue2(`${
|
|
22744
|
+
issues.push(issue2(`${path24}.path`, "INVALID_INPUT_SOURCE_PATH", "invocation source path must be a safe JSON pointer"));
|
|
22743
22745
|
}
|
|
22744
22746
|
return;
|
|
22745
22747
|
}
|
|
22746
22748
|
if (value.kind === "runtime-context") {
|
|
22747
|
-
exactKeys(value, ["kind", "key"],
|
|
22749
|
+
exactKeys(value, ["kind", "key"], path24, issues);
|
|
22748
22750
|
if (!RUNTIME_CONTEXT_KEYS2.has(value.key)) {
|
|
22749
|
-
issues.push(issue2(`${
|
|
22751
|
+
issues.push(issue2(`${path24}.key`, "INVALID_RUNTIME_CONTEXT", "runtime context key is invalid"));
|
|
22750
22752
|
}
|
|
22751
22753
|
return;
|
|
22752
22754
|
}
|
|
22753
|
-
issues.push(issue2(`${
|
|
22755
|
+
issues.push(issue2(`${path24}.kind`, "INVALID_INPUT_SOURCE", "source.kind must be invocation or runtime-context"));
|
|
22754
22756
|
}
|
|
22755
|
-
function validateOutputBindings(value,
|
|
22757
|
+
function validateOutputBindings(value, path24, issues) {
|
|
22756
22758
|
if (!Array.isArray(value)) {
|
|
22757
|
-
issues.push(issue2(
|
|
22759
|
+
issues.push(issue2(path24, "INVALID_OUTPUT_BINDINGS", "outputBindings must be an array"));
|
|
22758
22760
|
return void 0;
|
|
22759
22761
|
}
|
|
22760
22762
|
const fields = /* @__PURE__ */ new Set();
|
|
22761
22763
|
value.forEach((candidate, index) => {
|
|
22762
|
-
const itemPath = `${
|
|
22764
|
+
const itemPath = `${path24}[${index}]`;
|
|
22763
22765
|
if (!isPlainRecord(candidate)) {
|
|
22764
22766
|
issues.push(issue2(itemPath, "INVALID_OUTPUT_BINDING", "binding must be an object"));
|
|
22765
22767
|
return;
|
|
@@ -22779,33 +22781,33 @@ function validateOutputBindings(value, path23, issues) {
|
|
|
22779
22781
|
});
|
|
22780
22782
|
return value;
|
|
22781
22783
|
}
|
|
22782
|
-
function validateTransformShape(value,
|
|
22784
|
+
function validateTransformShape(value, path24, issues) {
|
|
22783
22785
|
if (!isPlainRecord(value)) {
|
|
22784
|
-
issues.push(issue2(
|
|
22786
|
+
issues.push(issue2(path24, "INVALID_TRANSFORM", "transform must be an object"));
|
|
22785
22787
|
return false;
|
|
22786
22788
|
}
|
|
22787
|
-
exactKeys(value, ["language", "profile", "expression"],
|
|
22789
|
+
exactKeys(value, ["language", "profile", "expression"], path24, issues);
|
|
22788
22790
|
if (value.language !== A2UI_CARD_TRANSFORM_LANGUAGE) {
|
|
22789
|
-
issues.push(issue2(`${
|
|
22791
|
+
issues.push(issue2(`${path24}.language`, "INVALID_TRANSFORM_LANGUAGE", `language must be ${A2UI_CARD_TRANSFORM_LANGUAGE}`));
|
|
22790
22792
|
}
|
|
22791
22793
|
if (value.profile !== A2UI_CARD_TRANSFORM_PROFILE) {
|
|
22792
|
-
issues.push(issue2(`${
|
|
22794
|
+
issues.push(issue2(`${path24}.profile`, "INVALID_TRANSFORM_PROFILE", `profile must be ${A2UI_CARD_TRANSFORM_PROFILE}`));
|
|
22793
22795
|
}
|
|
22794
22796
|
if (typeof value.expression !== "string" || value.expression.trim().length === 0) {
|
|
22795
|
-
issues.push(issue2(`${
|
|
22797
|
+
issues.push(issue2(`${path24}.expression`, "INVALID_TRANSFORM_EXPRESSION", "expression must be a non-empty string"));
|
|
22796
22798
|
} else if (value.expression.length > A2UI_CARD_EXPRESSION_MAX_LENGTH) {
|
|
22797
|
-
issues.push(issue2(`${
|
|
22799
|
+
issues.push(issue2(`${path24}.expression`, "TRANSFORM_EXPRESSION_TOO_LONG", `expression exceeds ${A2UI_CARD_EXPRESSION_MAX_LENGTH} characters`));
|
|
22798
22800
|
}
|
|
22799
22801
|
return true;
|
|
22800
22802
|
}
|
|
22801
|
-
function validateProtocol(value,
|
|
22803
|
+
function validateProtocol(value, path24, issues) {
|
|
22802
22804
|
if (!Array.isArray(value) || value.length === 0) {
|
|
22803
|
-
issues.push(issue2(
|
|
22805
|
+
issues.push(issue2(path24, "INVALID_A2UI_PROTOCOL", "card must be a non-empty array"));
|
|
22804
22806
|
return void 0;
|
|
22805
22807
|
}
|
|
22806
22808
|
const issueCountBeforeValidation = issues.length;
|
|
22807
22809
|
value.forEach((message, messageIndex) => {
|
|
22808
|
-
const messagePath = `${
|
|
22810
|
+
const messagePath = `${path24}[${messageIndex}]`;
|
|
22809
22811
|
if (!isPlainRecord(message)) {
|
|
22810
22812
|
issues.push(issue2(messagePath, "INVALID_A2UI_MESSAGE", "A2UI message must be an object"));
|
|
22811
22813
|
return;
|
|
@@ -22834,7 +22836,7 @@ function validateProtocol(value, path23, issues) {
|
|
|
22834
22836
|
return void 0;
|
|
22835
22837
|
return value;
|
|
22836
22838
|
}
|
|
22837
|
-
function validateInstructionShape(instruction,
|
|
22839
|
+
function validateInstructionShape(instruction, path24, issues) {
|
|
22838
22840
|
const knownKeys = [
|
|
22839
22841
|
"createSurface",
|
|
22840
22842
|
"updateComponents",
|
|
@@ -22843,31 +22845,31 @@ function validateInstructionShape(instruction, path23, issues) {
|
|
|
22843
22845
|
"x2DeleteComponent"
|
|
22844
22846
|
].filter((key) => key in instruction);
|
|
22845
22847
|
if (knownKeys.length !== 1) {
|
|
22846
|
-
issues.push(issue2(
|
|
22848
|
+
issues.push(issue2(path24, "INVALID_A2UI_INSTRUCTION", "instruction must contain exactly one supported operation"));
|
|
22847
22849
|
return;
|
|
22848
22850
|
}
|
|
22849
22851
|
const operation = knownKeys[0];
|
|
22850
22852
|
const payload = instruction[operation];
|
|
22851
22853
|
if (!isPlainRecord(payload)) {
|
|
22852
|
-
issues.push(issue2(`${
|
|
22854
|
+
issues.push(issue2(`${path24}.${operation}`, "INVALID_A2UI_INSTRUCTION_PAYLOAD", `${operation} must be an object`));
|
|
22853
22855
|
return;
|
|
22854
22856
|
}
|
|
22855
22857
|
if (!isSafeIdentifier(payload.surfaceId)) {
|
|
22856
|
-
issues.push(issue2(`${
|
|
22858
|
+
issues.push(issue2(`${path24}.${operation}.surfaceId`, "INVALID_SURFACE_ID", "surfaceId must be a non-empty safe identifier"));
|
|
22857
22859
|
}
|
|
22858
22860
|
if (operation === "updateComponents") {
|
|
22859
22861
|
if (!Array.isArray(payload.components)) {
|
|
22860
|
-
issues.push(issue2(`${
|
|
22862
|
+
issues.push(issue2(`${path24}.${operation}.components`, "INVALID_A2UI_COMPONENTS", "components must be an array"));
|
|
22861
22863
|
return;
|
|
22862
22864
|
}
|
|
22863
22865
|
payload.components.forEach((component, componentIndex) => {
|
|
22864
22866
|
if (!isPlainRecord(component) || !isJsonValue(component)) {
|
|
22865
|
-
issues.push(issue2(`${
|
|
22867
|
+
issues.push(issue2(`${path24}.${operation}.components[${componentIndex}]`, "INVALID_A2UI_COMPONENT", "component must be a JSON object"));
|
|
22866
22868
|
}
|
|
22867
22869
|
});
|
|
22868
22870
|
}
|
|
22869
22871
|
if (operation === "x2DeleteComponent" && !isSafeIdentifier(payload.componentId)) {
|
|
22870
|
-
issues.push(issue2(`${
|
|
22872
|
+
issues.push(issue2(`${path24}.${operation}.componentId`, "INVALID_COMPONENT_ID", "componentId must be a non-empty safe identifier"));
|
|
22871
22873
|
}
|
|
22872
22874
|
}
|
|
22873
22875
|
function validateTemplate(value, fields, issues) {
|
|
@@ -22893,8 +22895,8 @@ function validateTemplate(value, fields, issues) {
|
|
|
22893
22895
|
}
|
|
22894
22896
|
return void 0;
|
|
22895
22897
|
}
|
|
22896
|
-
function validateLooseJsonSchema(value,
|
|
22897
|
-
const schemaIssues = getJsonSchemaIssues(value,
|
|
22898
|
+
function validateLooseJsonSchema(value, path24, issues) {
|
|
22899
|
+
const schemaIssues = getJsonSchemaIssues(value, path24, {
|
|
22898
22900
|
allowMissingType: true
|
|
22899
22901
|
});
|
|
22900
22902
|
issues.push(...schemaIssues);
|
|
@@ -22916,14 +22918,14 @@ function validateResolverCoverage(fields, resolver, issues, card) {
|
|
|
22916
22918
|
}
|
|
22917
22919
|
}
|
|
22918
22920
|
}
|
|
22919
|
-
function requiredString(value,
|
|
22921
|
+
function requiredString(value, path24, issues) {
|
|
22920
22922
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
22921
|
-
issues.push(issue2(
|
|
22923
|
+
issues.push(issue2(path24, "REQUIRED_STRING", `${path24} must be a non-empty string`));
|
|
22922
22924
|
}
|
|
22923
22925
|
}
|
|
22924
|
-
function optionalString(value,
|
|
22926
|
+
function optionalString(value, path24, issues) {
|
|
22925
22927
|
if (value !== void 0 && typeof value !== "string") {
|
|
22926
|
-
issues.push(issue2(
|
|
22928
|
+
issues.push(issue2(path24, "INVALID_STRING", `${path24} must be a string`));
|
|
22927
22929
|
}
|
|
22928
22930
|
}
|
|
22929
22931
|
|
|
@@ -23564,8 +23566,8 @@ function isSafePageUrl2(url2) {
|
|
|
23564
23566
|
tokenCount++;
|
|
23565
23567
|
if (tokenCount > 32)
|
|
23566
23568
|
return false;
|
|
23567
|
-
const
|
|
23568
|
-
if (!(
|
|
23569
|
+
const path24 = match[1]?.trim() ?? "";
|
|
23570
|
+
if (!(path24 === "/" || path24.startsWith("/") || path24.startsWith("./")) || path24.split("/").some((part) => ["..", "__proto__", "constructor", "prototype"].includes(part))) {
|
|
23569
23571
|
return false;
|
|
23570
23572
|
}
|
|
23571
23573
|
}
|
|
@@ -23799,21 +23801,8 @@ function cloneBinding(binding) {
|
|
|
23799
23801
|
return JSON.parse(JSON.stringify(binding));
|
|
23800
23802
|
}
|
|
23801
23803
|
|
|
23802
|
-
// ../linkque-agent-runtime/dist/esm/core/mcpProxyTool.js
|
|
23803
|
-
var MCP_PROXY_DESCRIPTION = [
|
|
23804
|
-
"MCP \u7F51\u5173:\u53D1\u73B0\u5E76\u8C03\u7528 MCP server \u63D0\u4F9B\u7684\u5DE5\u5177\u3002\u53EF\u7528\u52A8\u4F5C:",
|
|
23805
|
-
"- mcp({}) \u6216 mcp({ status: true }):\u67E5\u770B\u6240\u6709 server \u8FDE\u63A5\u72B6\u6001\u4E0E\u5DE5\u5177\u6570\u3002",
|
|
23806
|
-
'- mcp({ connect: "server" }):\u8FDE\u63A5\u5E76\u5237\u65B0\u67D0 server \u7684\u5DE5\u5177\u5217\u8868\u3002',
|
|
23807
|
-
'- mcp({ server: "name" }):\u5217\u51FA\u8BE5 server \u7684\u5DE5\u5177\u3002',
|
|
23808
|
-
'- mcp({ search: "\u5173\u952E\u8BCD" }):\u6309\u540D\u79F0/\u63CF\u8FF0\u6A21\u7CCA\u641C\u7D22\u5DE5\u5177(\u7A7A\u683C\u5206\u8BCD OR)\u3002',
|
|
23809
|
-
'- mcp({ searches: ["\u5173\u952E\u8BCD1", "\u5173\u952E\u8BCD2"] }):\u4E00\u6B21\u6267\u884C\u591A\u7EC4\u641C\u7D22\u5E76\u6309 query \u5206\u7EC4\u8FD4\u56DE(\u6700\u591A 5 \u7EC4)\u3002',
|
|
23810
|
-
'- mcp({ describe: "toolName" }):\u67E5\u770B\u67D0\u5DE5\u5177\u7684\u53C2\u6570 schema\u3002',
|
|
23811
|
-
'- mcp({ tool: "toolName", args: { ... } }):\u8C03\u7528\u67D0\u5DE5\u5177,args \u4E3A\u5BF9\u8C61\u3002',
|
|
23812
|
-
"\u53EF\u7528 server \u540D\u89C1 mcp({}) \u8F93\u51FA\u3002\u4EC5\u5728\u786E\u9700\u8C03\u7528 MCP \u5DE5\u5177\u65F6\u4F7F\u7528\u672C\u5DE5\u5177\u3002",
|
|
23813
|
-
"\u4EC5 mcp({}) \u5217\u51FA\u7684\u5DE5\u5177\u53EF\u8C03\u7528(\u672A\u58F0\u660E\u7684\u5DE5\u5177\u4E0D\u4F1A\u51FA\u73B0)\u3002"
|
|
23814
|
-
].join("\n");
|
|
23815
|
-
|
|
23816
23804
|
// ../linkque-agent-protocol/dist/esm/telemetry/telemetryEnums.js
|
|
23805
|
+
var CONTENT_VALUE_MAX_LENGTH = 16 * 1024;
|
|
23817
23806
|
var ETelemetryAttribute;
|
|
23818
23807
|
(function(ETelemetryAttribute2) {
|
|
23819
23808
|
ETelemetryAttribute2["HARNESS_TELEMETRY_SCHEMA_VERSION"] = "harness.telemetry.schema.version";
|
|
@@ -23870,6 +23859,7 @@ var ETelemetryAttribute;
|
|
|
23870
23859
|
ETelemetryAttribute2["GEN_AI_REQUEST_MODEL"] = "gen_ai.request.model";
|
|
23871
23860
|
ETelemetryAttribute2["GEN_AI_RESPONSE_MODEL"] = "gen_ai.response.model";
|
|
23872
23861
|
ETelemetryAttribute2["GEN_AI_RESPONSE_ID"] = "gen_ai.response.id";
|
|
23862
|
+
ETelemetryAttribute2["LINKQUE_CONTENT_VALUE_TRUNCATED"] = "linkque.content.value.truncated";
|
|
23873
23863
|
ETelemetryAttribute2["GEN_AI_RESPONSE_FINISH_REASONS"] = "gen_ai.response.finish_reasons";
|
|
23874
23864
|
ETelemetryAttribute2["GEN_AI_USAGE_INPUT_TOKENS"] = "gen_ai.usage.input_tokens";
|
|
23875
23865
|
ETelemetryAttribute2["GEN_AI_USAGE_OUTPUT_TOKENS"] = "gen_ai.usage.output_tokens";
|
|
@@ -23973,7 +23963,23 @@ var ETelemetryEventName;
|
|
|
23973
23963
|
ETelemetryEventName2["HISTORY_APPEND_FINISHED"] = "linkque.history.append.finished";
|
|
23974
23964
|
ETelemetryEventName2["HOOK_DRAIN_STARTED"] = "linkque.hook.drain.started";
|
|
23975
23965
|
ETelemetryEventName2["HOOK_DRAIN_FINISHED"] = "linkque.hook.drain.finished";
|
|
23966
|
+
ETelemetryEventName2["CONTENT_RECORDED"] = "linkque.content.recorded";
|
|
23976
23967
|
})(ETelemetryEventName || (ETelemetryEventName = {}));
|
|
23968
|
+
var ETelemetryContentSection;
|
|
23969
|
+
(function(ETelemetryContentSection2) {
|
|
23970
|
+
ETelemetryContentSection2["QUERY_INPUT"] = "query.input";
|
|
23971
|
+
ETelemetryContentSection2["MODEL_OUTPUT"] = "model.output";
|
|
23972
|
+
ETelemetryContentSection2["MCP_ACTION_OUTPUT"] = "mcp_action.output";
|
|
23973
|
+
ETelemetryContentSection2["TOOL_INPUT"] = "tool.input";
|
|
23974
|
+
ETelemetryContentSection2["TOOL_OUTPUT"] = "tool.output";
|
|
23975
|
+
ETelemetryContentSection2["MCP_REQUESTED_INPUT"] = "mcp.requested_input";
|
|
23976
|
+
ETelemetryContentSection2["MCP_INPUT"] = "mcp.input";
|
|
23977
|
+
ETelemetryContentSection2["MCP_OUTPUT"] = "mcp.output";
|
|
23978
|
+
ETelemetryContentSection2["SKILL_INPUT"] = "skill.input";
|
|
23979
|
+
ETelemetryContentSection2["SKILL_OUTPUT"] = "skill.output";
|
|
23980
|
+
ETelemetryContentSection2["KNOWLEDGE_INPUT"] = "knowledge.input";
|
|
23981
|
+
ETelemetryContentSection2["KNOWLEDGE_OUTPUT"] = "knowledge.output";
|
|
23982
|
+
})(ETelemetryContentSection || (ETelemetryContentSection = {}));
|
|
23977
23983
|
var ETelemetryOperationName;
|
|
23978
23984
|
(function(ETelemetryOperationName2) {
|
|
23979
23985
|
ETelemetryOperationName2["OPERATION"] = "linkque.operation";
|
|
@@ -24141,6 +24147,20 @@ var ETelemetryVersion;
|
|
|
24141
24147
|
ETelemetryVersion2["V1_0"] = "1.0";
|
|
24142
24148
|
})(ETelemetryVersion || (ETelemetryVersion = {}));
|
|
24143
24149
|
|
|
24150
|
+
// ../linkque-agent-runtime/dist/esm/core/mcpProxyTool.js
|
|
24151
|
+
var MCP_PROXY_DESCRIPTION = [
|
|
24152
|
+
"MCP \u7F51\u5173:\u53D1\u73B0\u5E76\u8C03\u7528 MCP server \u63D0\u4F9B\u7684\u5DE5\u5177\u3002\u53EF\u7528\u52A8\u4F5C:",
|
|
24153
|
+
"- mcp({}) \u6216 mcp({ status: true }):\u67E5\u770B\u6240\u6709 server \u8FDE\u63A5\u72B6\u6001\u4E0E\u5DE5\u5177\u6570\u3002",
|
|
24154
|
+
'- mcp({ connect: "server" }):\u8FDE\u63A5\u5E76\u5237\u65B0\u67D0 server \u7684\u5DE5\u5177\u5217\u8868\u3002',
|
|
24155
|
+
'- mcp({ server: "name" }):\u5217\u51FA\u8BE5 server \u7684\u5DE5\u5177\u3002',
|
|
24156
|
+
'- mcp({ search: "\u5173\u952E\u8BCD" }):\u6309\u540D\u79F0/\u63CF\u8FF0\u6A21\u7CCA\u641C\u7D22\u5DE5\u5177(\u7A7A\u683C\u5206\u8BCD OR)\u3002',
|
|
24157
|
+
'- mcp({ searches: ["\u5173\u952E\u8BCD1", "\u5173\u952E\u8BCD2"] }):\u4E00\u6B21\u6267\u884C\u591A\u7EC4\u641C\u7D22\u5E76\u6309 query \u5206\u7EC4\u8FD4\u56DE(\u6700\u591A 5 \u7EC4)\u3002',
|
|
24158
|
+
'- mcp({ describe: "toolName" }):\u67E5\u770B\u67D0\u5DE5\u5177\u7684\u53C2\u6570 schema\u3002',
|
|
24159
|
+
'- mcp({ tool: "toolName", args: { ... } }):\u8C03\u7528\u67D0\u5DE5\u5177,args \u4E3A\u5BF9\u8C61\u3002',
|
|
24160
|
+
"\u53EF\u7528 server \u540D\u89C1 mcp({}) \u8F93\u51FA\u3002\u4EC5\u5728\u786E\u9700\u8C03\u7528 MCP \u5DE5\u5177\u65F6\u4F7F\u7528\u672C\u5DE5\u5177\u3002",
|
|
24161
|
+
"\u4EC5 mcp({}) \u5217\u51FA\u7684\u5DE5\u5177\u53EF\u8C03\u7528(\u672A\u58F0\u660E\u7684\u5DE5\u5177\u4E0D\u4F1A\u51FA\u73B0)\u3002"
|
|
24162
|
+
].join("\n");
|
|
24163
|
+
|
|
24144
24164
|
// ../linkque-agent-runtime/dist/esm/core/telemetry/telemetryEnums.js
|
|
24145
24165
|
var ETelemetryDiagnosticCode;
|
|
24146
24166
|
(function(ETelemetryDiagnosticCode2) {
|
|
@@ -24695,8 +24715,8 @@ function getErrorMap() {
|
|
|
24695
24715
|
|
|
24696
24716
|
// ../../node_modules/zod/v3/helpers/parseUtil.js
|
|
24697
24717
|
var makeIssue = (params) => {
|
|
24698
|
-
const { data, path:
|
|
24699
|
-
const fullPath = [...
|
|
24718
|
+
const { data, path: path24, errorMaps, issueData } = params;
|
|
24719
|
+
const fullPath = [...path24, ...issueData.path || []];
|
|
24700
24720
|
const fullIssue = {
|
|
24701
24721
|
...issueData,
|
|
24702
24722
|
path: fullPath
|
|
@@ -24812,11 +24832,11 @@ var errorUtil;
|
|
|
24812
24832
|
|
|
24813
24833
|
// ../../node_modules/zod/v3/types.js
|
|
24814
24834
|
var ParseInputLazyPath = class {
|
|
24815
|
-
constructor(parent, value,
|
|
24835
|
+
constructor(parent, value, path24, key) {
|
|
24816
24836
|
this._cachedPath = [];
|
|
24817
24837
|
this.parent = parent;
|
|
24818
24838
|
this.data = value;
|
|
24819
|
-
this._path =
|
|
24839
|
+
this._path = path24;
|
|
24820
24840
|
this._key = key;
|
|
24821
24841
|
}
|
|
24822
24842
|
get path() {
|
|
@@ -28454,10 +28474,10 @@ function assignProp(target, prop, value) {
|
|
|
28454
28474
|
configurable: true
|
|
28455
28475
|
});
|
|
28456
28476
|
}
|
|
28457
|
-
function getElementAtPath(obj,
|
|
28458
|
-
if (!
|
|
28477
|
+
function getElementAtPath(obj, path24) {
|
|
28478
|
+
if (!path24)
|
|
28459
28479
|
return obj;
|
|
28460
|
-
return
|
|
28480
|
+
return path24.reduce((acc, key) => acc?.[key], obj);
|
|
28461
28481
|
}
|
|
28462
28482
|
function promiseAllObject(promisesObj) {
|
|
28463
28483
|
const keys = Object.keys(promisesObj);
|
|
@@ -28777,11 +28797,11 @@ function aborted(x, startIndex = 0) {
|
|
|
28777
28797
|
}
|
|
28778
28798
|
return false;
|
|
28779
28799
|
}
|
|
28780
|
-
function prefixIssues(
|
|
28800
|
+
function prefixIssues(path24, issues) {
|
|
28781
28801
|
return issues.map((iss) => {
|
|
28782
28802
|
var _a;
|
|
28783
28803
|
(_a = iss).path ?? (_a.path = []);
|
|
28784
|
-
iss.path.unshift(
|
|
28804
|
+
iss.path.unshift(path24);
|
|
28785
28805
|
return iss;
|
|
28786
28806
|
});
|
|
28787
28807
|
}
|
|
@@ -34499,6 +34519,7 @@ var allowedAttributeKeys = /* @__PURE__ */ new Set([
|
|
|
34499
34519
|
ETelemetryAttribute.GEN_AI_REQUEST_MODEL,
|
|
34500
34520
|
ETelemetryAttribute.GEN_AI_RESPONSE_MODEL,
|
|
34501
34521
|
ETelemetryAttribute.GEN_AI_RESPONSE_ID,
|
|
34522
|
+
ETelemetryAttribute.LINKQUE_CONTENT_VALUE_TRUNCATED,
|
|
34502
34523
|
ETelemetryAttribute.GEN_AI_RESPONSE_FINISH_REASONS,
|
|
34503
34524
|
ETelemetryAttribute.GEN_AI_USAGE_INPUT_TOKENS,
|
|
34504
34525
|
ETelemetryAttribute.GEN_AI_USAGE_OUTPUT_TOKENS,
|
|
@@ -35169,7 +35190,7 @@ var FUNCTION_DEFS = [
|
|
|
35169
35190
|
runtime: "node-22",
|
|
35170
35191
|
entrypoint: AGENT_BUNDLE_ENTRY,
|
|
35171
35192
|
commands: "",
|
|
35172
|
-
timeout:
|
|
35193
|
+
timeout: 300,
|
|
35173
35194
|
execute: ["users"],
|
|
35174
35195
|
// chat Function 会读写 run、session、lease、索引和搜索文档。AppBase 根据这里的
|
|
35175
35196
|
// scopes 注入运行期动态 Server key;缺少 write 会以 role=applications 报 401。
|
|
@@ -36012,6 +36033,7 @@ var agentDeploy = async (cwd, options) => {
|
|
|
36012
36033
|
// src/commands/agentdev/sandboxIntegrate/sandboxRuntimeConfigProvider.ts
|
|
36013
36034
|
var SANDBOX_RUNTIME_CONFIG_DEFAULTS = Object.freeze({
|
|
36014
36035
|
...RUNTIME_CONFIG_DEFAULTS,
|
|
36036
|
+
LOG_LEVEL: "DEBUG",
|
|
36015
36037
|
LINKQUE_MCP_SIGN_ENDPOINT: RUNTIME_CONFIG_DEFAULTS.LINKQUEGW_MCP_SIGN_ENDPOINT,
|
|
36016
36038
|
LINKQUE_OPEN_MCP_BASE_URL: "https://opengw.alipay.com",
|
|
36017
36039
|
LINKQUEGW_TELEMETRY_LOGS_ENDPOINT: `${LINKQUE_ENDPOINT_PROD}/api/telemetry/v1/logs`,
|
|
@@ -40612,8 +40634,12 @@ async function rollbackCardFinalize(cwd, rollbackToken) {
|
|
|
40612
40634
|
}
|
|
40613
40635
|
async function validateCardBindingsFromDisk(cwd, draftId, fieldId) {
|
|
40614
40636
|
const directory = draftDirectory(cwd, draftId);
|
|
40615
|
-
const
|
|
40616
|
-
|
|
40637
|
+
const bundle = await readBundle(directory, draftId);
|
|
40638
|
+
return validateCardBindingsForBundle(cwd, draftId, bundle, fieldId);
|
|
40639
|
+
}
|
|
40640
|
+
async function validateCardBindingsForBundle(cwd, draftId, bundle, fieldId) {
|
|
40641
|
+
const directory = draftDirectory(cwd, draftId);
|
|
40642
|
+
const [contextValue, configValue] = await Promise.all([
|
|
40617
40643
|
readOptionalJson(import_path22.default.join(directory, "binding-context.json")),
|
|
40618
40644
|
readRequiredJson(import_path22.default.join(cwd, AGENT_CONFIG_PATH))
|
|
40619
40645
|
]);
|
|
@@ -40649,15 +40675,15 @@ async function validateCardBindingsFromDisk(cwd, draftId, fieldId) {
|
|
|
40649
40675
|
};
|
|
40650
40676
|
}
|
|
40651
40677
|
async function finalizeCardWhileLocked(cwd, draftId, expectedDraftChecksum) {
|
|
40652
|
-
const
|
|
40678
|
+
const directory = draftDirectory(cwd, draftId);
|
|
40679
|
+
const bundle = await readBundle(directory, draftId);
|
|
40680
|
+
const validation = await validateCardBindingsForBundle(cwd, draftId, bundle);
|
|
40653
40681
|
if (validation.draftChecksum !== expectedDraftChecksum) {
|
|
40654
40682
|
throw new LinkqueCliError(
|
|
40655
40683
|
"CARD_FINALIZE_CONFLICT",
|
|
40656
40684
|
"\u5361\u7247\u8349\u7A3F\u5728\u6821\u9A8C\u540E\u5DF2\u53D8\u5316\uFF0C\u62D2\u7EDD finalize"
|
|
40657
40685
|
);
|
|
40658
40686
|
}
|
|
40659
|
-
const directory = draftDirectory(cwd, draftId);
|
|
40660
|
-
const bundle = await readBundle(directory, draftId);
|
|
40661
40687
|
const runtimeSupportedSchemaVersions = await readRuntimeSupportedSchemaVersions(cwd);
|
|
40662
40688
|
if (!runtimeSupportedSchemaVersions.includes(bundle.manifest.schemaVersion)) {
|
|
40663
40689
|
throw new LinkqueCliError(
|
|
@@ -40683,17 +40709,6 @@ async function finalizeCardWhileLocked(cwd, draftId, expectedDraftChecksum) {
|
|
|
40683
40709
|
const existingIndex = resources.findIndex(
|
|
40684
40710
|
(resource) => resource.resourceType === "CARD" && resource.resourceId === bundle.manifest.resourceId
|
|
40685
40711
|
);
|
|
40686
|
-
const existing = existingIndex >= 0 ? resources[existingIndex] : void 0;
|
|
40687
|
-
const existingRevision = isJsonObject(existing?.config) && typeof existing.config.revision === "string" ? existing.config.revision : void 0;
|
|
40688
|
-
const saved = parseSavedMarker(
|
|
40689
|
-
await readOptionalJson(import_path22.default.join(directory, "saved.json"))
|
|
40690
|
-
);
|
|
40691
|
-
if ((bundle.manifest.baseRevision ?? void 0) !== existingRevision && (saved === void 0 || saved.cardRevision !== existingRevision)) {
|
|
40692
|
-
throw new LinkqueCliError(
|
|
40693
|
-
"CARD_FINALIZE_CONFLICT",
|
|
40694
|
-
"\u5DF2\u4FDD\u5B58\u5361\u7247 revision \u4E0E\u8349\u7A3F baseRevision \u4E0D\u4E00\u81F4"
|
|
40695
|
-
);
|
|
40696
|
-
}
|
|
40697
40712
|
const bindings = bundle.manifest.bindings ?? [];
|
|
40698
40713
|
const cardRevision = createA2UICardRevision(
|
|
40699
40714
|
validation.draftStructureChecksum,
|
|
@@ -42132,6 +42147,919 @@ var SourceArchiveExtractor = class {
|
|
|
42132
42147
|
};
|
|
42133
42148
|
var unzipArchive = (cwd, input, output) => new SourceArchiveExtractor(cwd, input, output).extract();
|
|
42134
42149
|
|
|
42150
|
+
// ../linkque-agent-runtime-trace/dist/esm/utils.js
|
|
42151
|
+
var decodeAnyValue = (value) => {
|
|
42152
|
+
if (!value)
|
|
42153
|
+
return void 0;
|
|
42154
|
+
if (value.stringValue !== void 0)
|
|
42155
|
+
return value.stringValue;
|
|
42156
|
+
if (value.intValue !== void 0)
|
|
42157
|
+
return Number(value.intValue);
|
|
42158
|
+
if (value.doubleValue !== void 0)
|
|
42159
|
+
return value.doubleValue;
|
|
42160
|
+
if (value.boolValue !== void 0)
|
|
42161
|
+
return value.boolValue;
|
|
42162
|
+
if (value.bytesValue !== void 0)
|
|
42163
|
+
return { __otlpBytes: true, base64: value.bytesValue };
|
|
42164
|
+
if (value.arrayValue)
|
|
42165
|
+
return value.arrayValue.values.map((child) => decodeAnyValue(child));
|
|
42166
|
+
if (value.kvlistValue) {
|
|
42167
|
+
const record2 = {};
|
|
42168
|
+
for (const { key, value: child } of value.kvlistValue.values)
|
|
42169
|
+
record2[key] = decodeAnyValue(child);
|
|
42170
|
+
return record2;
|
|
42171
|
+
}
|
|
42172
|
+
return void 0;
|
|
42173
|
+
};
|
|
42174
|
+
var decodeAttributes = (attrs) => {
|
|
42175
|
+
const out = {};
|
|
42176
|
+
if (!Array.isArray(attrs))
|
|
42177
|
+
return out;
|
|
42178
|
+
for (const { key, value } of attrs) {
|
|
42179
|
+
const decoded = decodeAnyValue(value);
|
|
42180
|
+
if (decoded !== void 0)
|
|
42181
|
+
out[key] = decoded;
|
|
42182
|
+
}
|
|
42183
|
+
return out;
|
|
42184
|
+
};
|
|
42185
|
+
var nanoToMs = (nano) => {
|
|
42186
|
+
if (!nano || !/^[0-9]+$/.test(nano))
|
|
42187
|
+
return void 0;
|
|
42188
|
+
try {
|
|
42189
|
+
return Number(BigInt(nano) / 1000000n);
|
|
42190
|
+
} catch {
|
|
42191
|
+
return void 0;
|
|
42192
|
+
}
|
|
42193
|
+
};
|
|
42194
|
+
|
|
42195
|
+
// ../linkque-agent-runtime-trace/dist/esm/decode.js
|
|
42196
|
+
var strAttr = (attrs, key) => {
|
|
42197
|
+
const value = attrs[key];
|
|
42198
|
+
return typeof value === "string" && value !== "" ? value : void 0;
|
|
42199
|
+
};
|
|
42200
|
+
var identityFromAttributes = (source, attrs, span) => {
|
|
42201
|
+
return Object.freeze({
|
|
42202
|
+
source,
|
|
42203
|
+
threadId: strAttr(attrs, ETelemetryAttribute.LINKQUE_CONVERSATION_ID),
|
|
42204
|
+
runId: strAttr(attrs, ETelemetryAttribute.LINKQUE_RUN_ID),
|
|
42205
|
+
advanceId: strAttr(attrs, ETelemetryAttribute.HARNESS_ADVANCE_ID),
|
|
42206
|
+
operationId: strAttr(attrs, ETelemetryAttribute.LINKQUE_OPERATION_ID),
|
|
42207
|
+
recordId: strAttr(attrs, ETelemetryAttribute.HARNESS_RECORD_ID),
|
|
42208
|
+
invocationId: strAttr(attrs, ETelemetryAttribute.HARNESS_INVOCATION_ID),
|
|
42209
|
+
traceId: span?.traceId,
|
|
42210
|
+
spanId: span?.spanId
|
|
42211
|
+
});
|
|
42212
|
+
};
|
|
42213
|
+
var decodeLogRecord = (source, record2, byteRange, push) => {
|
|
42214
|
+
const attributes = decodeAttributes(record2.attributes);
|
|
42215
|
+
const rawName = record2.eventName ?? record2.name;
|
|
42216
|
+
const name = typeof rawName === "string" && rawName ? rawName : void 0;
|
|
42217
|
+
const identity = identityFromAttributes(source, attributes);
|
|
42218
|
+
const startedAt = nanoToMs(record2.timeUnixNano);
|
|
42219
|
+
const outcome = strAttr(attributes, ETelemetryAttribute.HARNESS_OPERATION_OUTCOME);
|
|
42220
|
+
const body = record2.body !== void 0 ? decodeAnyValue(record2.body) : void 0;
|
|
42221
|
+
if (body && typeof body === "object" && "valueJson" in body) {
|
|
42222
|
+
const content = body;
|
|
42223
|
+
try {
|
|
42224
|
+
content.value = JSON.parse(String(content.valueJson));
|
|
42225
|
+
} catch {
|
|
42226
|
+
content.availability = "unavailable";
|
|
42227
|
+
}
|
|
42228
|
+
delete content.valueJson;
|
|
42229
|
+
}
|
|
42230
|
+
push({
|
|
42231
|
+
kind: "event",
|
|
42232
|
+
identity,
|
|
42233
|
+
name,
|
|
42234
|
+
body,
|
|
42235
|
+
attributes: Object.freeze(attributes),
|
|
42236
|
+
startedAt,
|
|
42237
|
+
outcome,
|
|
42238
|
+
byteRange
|
|
42239
|
+
});
|
|
42240
|
+
};
|
|
42241
|
+
var decodeSpan = (source, span, byteRange, push) => {
|
|
42242
|
+
const attributes = decodeAttributes(span.attributes);
|
|
42243
|
+
const spanId = {
|
|
42244
|
+
traceId: span.traceId,
|
|
42245
|
+
spanId: span.spanId
|
|
42246
|
+
};
|
|
42247
|
+
const identity = identityFromAttributes(source, attributes, spanId);
|
|
42248
|
+
const startedAt = nanoToMs(span.startTimeUnixNano);
|
|
42249
|
+
const finishedAt = nanoToMs(span.endTimeUnixNano);
|
|
42250
|
+
const statusCode = span.status?.code;
|
|
42251
|
+
const outcome = strAttr(attributes, ETelemetryAttribute.HARNESS_OPERATION_OUTCOME) ?? (statusCode === 2 ? "error" : statusCode === 1 ? "success" : void 0);
|
|
42252
|
+
const links = [];
|
|
42253
|
+
if (Array.isArray(span.links)) {
|
|
42254
|
+
for (const link3 of span.links) {
|
|
42255
|
+
if (!link3 || typeof link3.traceId !== "string" || typeof link3.spanId !== "string")
|
|
42256
|
+
continue;
|
|
42257
|
+
const attrs = decodeAttributes(link3.attributes);
|
|
42258
|
+
const relation = attrs[ETelemetryAttribute.LINKQUE_LINK_RELATION];
|
|
42259
|
+
if (typeof relation === "string")
|
|
42260
|
+
links.push({ traceId: link3.traceId, spanId: link3.spanId, relation });
|
|
42261
|
+
}
|
|
42262
|
+
}
|
|
42263
|
+
push({
|
|
42264
|
+
kind: "span",
|
|
42265
|
+
links,
|
|
42266
|
+
identity,
|
|
42267
|
+
name: typeof span.name === "string" ? span.name : void 0,
|
|
42268
|
+
attributes: Object.freeze(attributes),
|
|
42269
|
+
startedAt,
|
|
42270
|
+
finishedAt,
|
|
42271
|
+
outcome,
|
|
42272
|
+
byteRange
|
|
42273
|
+
});
|
|
42274
|
+
const events = span.events;
|
|
42275
|
+
if (Array.isArray(events)) {
|
|
42276
|
+
for (const event of events) {
|
|
42277
|
+
const eventAttributes = decodeAttributes(event.attributes);
|
|
42278
|
+
for (const key of [
|
|
42279
|
+
ETelemetryAttribute.HARNESS_ADVANCE_ID,
|
|
42280
|
+
ETelemetryAttribute.LINKQUE_CONVERSATION_ID,
|
|
42281
|
+
ETelemetryAttribute.LINKQUE_RUN_ID,
|
|
42282
|
+
ETelemetryAttribute.LINKQUE_OPERATION_ID,
|
|
42283
|
+
ETelemetryAttribute.HARNESS_INVOCATION_ID
|
|
42284
|
+
]) {
|
|
42285
|
+
eventAttributes[key] ??= attributes[key];
|
|
42286
|
+
}
|
|
42287
|
+
push({
|
|
42288
|
+
kind: "span-event",
|
|
42289
|
+
identity: identityFromAttributes(source, eventAttributes, spanId),
|
|
42290
|
+
name: event.name,
|
|
42291
|
+
attributes: Object.freeze(eventAttributes),
|
|
42292
|
+
startedAt: nanoToMs(event.timeUnixNano),
|
|
42293
|
+
outcome: strAttr(eventAttributes, ETelemetryAttribute.HARNESS_OPERATION_OUTCOME),
|
|
42294
|
+
byteRange
|
|
42295
|
+
});
|
|
42296
|
+
}
|
|
42297
|
+
}
|
|
42298
|
+
};
|
|
42299
|
+
function decodeOtlpLine(line, source, byteRange) {
|
|
42300
|
+
const warnings = [];
|
|
42301
|
+
let json;
|
|
42302
|
+
try {
|
|
42303
|
+
json = JSON.parse(typeof line === "string" ? line : line.toString("utf8"));
|
|
42304
|
+
} catch {
|
|
42305
|
+
return { facts: [], warnings: ["json_parse_failed"] };
|
|
42306
|
+
}
|
|
42307
|
+
if (!json || typeof json !== "object") {
|
|
42308
|
+
return { facts: [], warnings: ["not_an_object"] };
|
|
42309
|
+
}
|
|
42310
|
+
const root = json;
|
|
42311
|
+
const facts = [];
|
|
42312
|
+
const push = (fact) => {
|
|
42313
|
+
facts.push(fact);
|
|
42314
|
+
};
|
|
42315
|
+
if (source === "logs") {
|
|
42316
|
+
const resourceLogs = root.resourceLogs;
|
|
42317
|
+
if (Array.isArray(resourceLogs)) {
|
|
42318
|
+
for (const entry of resourceLogs) {
|
|
42319
|
+
if (!entry || typeof entry !== "object")
|
|
42320
|
+
continue;
|
|
42321
|
+
for (const scope of entry.scopeLogs ?? []) {
|
|
42322
|
+
if (!scope || typeof scope !== "object")
|
|
42323
|
+
continue;
|
|
42324
|
+
for (const record2 of scope.logRecords ?? [])
|
|
42325
|
+
decodeLogRecord(source, record2, byteRange, push);
|
|
42326
|
+
}
|
|
42327
|
+
}
|
|
42328
|
+
} else {
|
|
42329
|
+
warnings.push("logs_without_resourceLogs");
|
|
42330
|
+
}
|
|
42331
|
+
return { facts, warnings };
|
|
42332
|
+
}
|
|
42333
|
+
const resourceSpans = root.resourceSpans;
|
|
42334
|
+
if (Array.isArray(resourceSpans)) {
|
|
42335
|
+
for (const entry of resourceSpans) {
|
|
42336
|
+
if (!entry || typeof entry !== "object")
|
|
42337
|
+
continue;
|
|
42338
|
+
for (const scope of entry.scopeSpans ?? []) {
|
|
42339
|
+
if (!scope || typeof scope !== "object")
|
|
42340
|
+
continue;
|
|
42341
|
+
for (const span of scope.spans ?? [])
|
|
42342
|
+
decodeSpan(source, span, byteRange, push);
|
|
42343
|
+
}
|
|
42344
|
+
}
|
|
42345
|
+
} else {
|
|
42346
|
+
warnings.push("traces_without_resourceSpans");
|
|
42347
|
+
}
|
|
42348
|
+
return { facts, warnings };
|
|
42349
|
+
}
|
|
42350
|
+
|
|
42351
|
+
// ../linkque-agent-runtime-trace/dist/esm/summarize.js
|
|
42352
|
+
var import_node_crypto2 = require("node:crypto");
|
|
42353
|
+
var dedupKey = (advanceId, suffix) => `${advanceId ?? ""}
|
|
42354
|
+
${suffix ?? ""}`;
|
|
42355
|
+
var extractQueryInput = (facts) => {
|
|
42356
|
+
for (const fact of facts) {
|
|
42357
|
+
if (fact.name !== ETelemetryEventName.CONTENT_RECORDED)
|
|
42358
|
+
continue;
|
|
42359
|
+
const body = fact.body;
|
|
42360
|
+
if (!body || body.section !== ETelemetryContentSection.QUERY_INPUT)
|
|
42361
|
+
continue;
|
|
42362
|
+
const text = typeof body.value === "string" && body.value ? body.value : void 0;
|
|
42363
|
+
const inputType = body.inputType === "card" ? "card" : void 0;
|
|
42364
|
+
const displayText = typeof body.displayText === "string" && body.displayText ? body.displayText : void 0;
|
|
42365
|
+
const availability = body.availability === "available" ? "available" : body.availability === "partial" ? "partial" : "not_recorded";
|
|
42366
|
+
return { text, inputType, displayText, availability };
|
|
42367
|
+
}
|
|
42368
|
+
return { availability: "not_recorded" };
|
|
42369
|
+
};
|
|
42370
|
+
var buildOperations = (facts) => {
|
|
42371
|
+
const groups = /* @__PURE__ */ new Map();
|
|
42372
|
+
for (const fact of facts) {
|
|
42373
|
+
if (!fact.identity.operationId)
|
|
42374
|
+
continue;
|
|
42375
|
+
const key = dedupKey(fact.identity.advanceId, fact.identity.operationId);
|
|
42376
|
+
const group = groups.get(key) ?? [];
|
|
42377
|
+
group.push(fact);
|
|
42378
|
+
groups.set(key, group);
|
|
42379
|
+
}
|
|
42380
|
+
const operations = [];
|
|
42381
|
+
const relations = [];
|
|
42382
|
+
for (const group of groups.values()) {
|
|
42383
|
+
const attrs = {};
|
|
42384
|
+
for (const fact of group)
|
|
42385
|
+
Object.assign(attrs, fact.attributes);
|
|
42386
|
+
const starts = group.filter((f3) => f3.kind === "span" || f3.name?.endsWith(".started")).map((f3) => f3.startedAt).filter((n3) => n3 !== void 0);
|
|
42387
|
+
const ends = group.flatMap((f3) => f3.finishedAt !== void 0 ? [f3.finishedAt] : f3.name?.endsWith(".finished") && f3.startedAt !== void 0 ? [f3.startedAt] : []);
|
|
42388
|
+
const startedAt = starts.length ? Math.min(...starts) : void 0;
|
|
42389
|
+
const finishedAt = ends.length ? Math.max(...ends) : void 0;
|
|
42390
|
+
const terminal = group.filter((f3) => f3.kind === "span" || f3.name?.endsWith(".finished")).reverse();
|
|
42391
|
+
const outcome = terminal.map((f3) => f3.outcome).find((v2) => v2 && v2 !== "0") ?? void 0;
|
|
42392
|
+
const operationId = group[0].identity.operationId;
|
|
42393
|
+
const parentOperationId = attrs[ETelemetryAttribute.LINKQUE_OPERATION_PARENT_ID];
|
|
42394
|
+
const operationName = attrs[ETelemetryAttribute.LINKQUE_OPERATION_NAME] ?? group.find((f3) => f3.kind === "span")?.name ?? group.find((f3) => f3.name?.endsWith(".started"))?.name?.replace(/\.started$/, "");
|
|
42395
|
+
operations.push({
|
|
42396
|
+
operationId,
|
|
42397
|
+
operationName,
|
|
42398
|
+
kind: "operation",
|
|
42399
|
+
startedAt,
|
|
42400
|
+
finishedAt,
|
|
42401
|
+
durationMs: startedAt !== void 0 && finishedAt !== void 0 ? Math.max(0, finishedAt - startedAt) : void 0,
|
|
42402
|
+
outcome,
|
|
42403
|
+
attributes: attrs,
|
|
42404
|
+
...parentOperationId ? { parentOperationId } : {}
|
|
42405
|
+
});
|
|
42406
|
+
if (parentOperationId)
|
|
42407
|
+
relations.push({
|
|
42408
|
+
fromOperationId: parentOperationId,
|
|
42409
|
+
toOperationId: operationId,
|
|
42410
|
+
relation: "parent"
|
|
42411
|
+
});
|
|
42412
|
+
}
|
|
42413
|
+
const spanOperations = new Map(facts.filter((f3) => f3.kind === "span" && f3.identity.operationId).map((f3) => [`${f3.identity.traceId}:${f3.identity.spanId}`, f3.identity.operationId]));
|
|
42414
|
+
const linkKeys = /* @__PURE__ */ new Set();
|
|
42415
|
+
for (const fact of facts) {
|
|
42416
|
+
if (!fact.identity.operationId)
|
|
42417
|
+
continue;
|
|
42418
|
+
for (const link3 of fact.links ?? []) {
|
|
42419
|
+
const source = spanOperations.get(`${link3.traceId}:${link3.spanId}`);
|
|
42420
|
+
if (!source)
|
|
42421
|
+
continue;
|
|
42422
|
+
const key = `${source}:${fact.identity.operationId}:${link3.relation}`;
|
|
42423
|
+
if (linkKeys.has(key))
|
|
42424
|
+
continue;
|
|
42425
|
+
linkKeys.add(key);
|
|
42426
|
+
relations.push({ fromOperationId: source, toOperationId: fact.identity.operationId, relation: link3.relation });
|
|
42427
|
+
}
|
|
42428
|
+
}
|
|
42429
|
+
operations.sort((a, b3) => (a.startedAt ?? Infinity) - (b3.startedAt ?? Infinity) || a.operationId.localeCompare(b3.operationId));
|
|
42430
|
+
return { operations, relations };
|
|
42431
|
+
};
|
|
42432
|
+
var buildUsage = (facts) => {
|
|
42433
|
+
const byInv = /* @__PURE__ */ new Map();
|
|
42434
|
+
for (const fact of facts) {
|
|
42435
|
+
const { invocationId } = fact.identity;
|
|
42436
|
+
if (!invocationId)
|
|
42437
|
+
continue;
|
|
42438
|
+
const key = dedupKey(fact.identity.advanceId, invocationId);
|
|
42439
|
+
const attrs = fact.attributes;
|
|
42440
|
+
const inputTokens = attrs["gen_ai.usage.input_tokens"];
|
|
42441
|
+
const outputTokens = attrs["gen_ai.usage.output_tokens"];
|
|
42442
|
+
const totalTokens = attrs["gen_ai.usage.total_tokens"];
|
|
42443
|
+
const model = attrs["gen_ai.request.model"];
|
|
42444
|
+
const finishReason = attrs[ETelemetryAttribute.GEN_AI_RESPONSE_FINISH_REASONS];
|
|
42445
|
+
const existing = byInv.get(key);
|
|
42446
|
+
if (!existing) {
|
|
42447
|
+
byInv.set(key, {
|
|
42448
|
+
invocationId,
|
|
42449
|
+
...model ? { model } : {},
|
|
42450
|
+
...inputTokens !== void 0 ? { inputTokens } : {},
|
|
42451
|
+
...outputTokens !== void 0 ? { outputTokens } : {},
|
|
42452
|
+
...totalTokens !== void 0 ? { totalTokens } : {},
|
|
42453
|
+
...finishReason ? { finishReason } : {},
|
|
42454
|
+
coverage: "not_recorded"
|
|
42455
|
+
});
|
|
42456
|
+
} else {
|
|
42457
|
+
byInv.set(key, {
|
|
42458
|
+
...existing,
|
|
42459
|
+
...existing.inputTokens === void 0 && inputTokens !== void 0 ? { inputTokens } : {},
|
|
42460
|
+
...existing.outputTokens === void 0 && outputTokens !== void 0 ? { outputTokens } : {},
|
|
42461
|
+
...existing.totalTokens === void 0 && totalTokens !== void 0 ? { totalTokens } : {},
|
|
42462
|
+
...existing.model === void 0 && model !== void 0 ? { model } : {},
|
|
42463
|
+
...existing.finishReason === void 0 && finishReason !== void 0 ? { finishReason } : {}
|
|
42464
|
+
});
|
|
42465
|
+
}
|
|
42466
|
+
}
|
|
42467
|
+
const reports = [...byInv.values()].map((report) => {
|
|
42468
|
+
const { inputTokens, outputTokens } = report;
|
|
42469
|
+
const totalTokens = report.totalTokens ?? (inputTokens !== void 0 && outputTokens !== void 0 ? inputTokens + outputTokens : void 0);
|
|
42470
|
+
const coverage = inputTokens !== void 0 && outputTokens !== void 0 ? "available" : inputTokens !== void 0 || outputTokens !== void 0 || totalTokens !== void 0 ? "partial" : "not_recorded";
|
|
42471
|
+
return { ...report, totalTokens, coverage };
|
|
42472
|
+
});
|
|
42473
|
+
const sum = (key) => {
|
|
42474
|
+
const values = reports.map((r2) => r2[key]).filter((n3) => n3 !== void 0);
|
|
42475
|
+
return values.length ? values.reduce((a, b3) => a + b3, 0) : void 0;
|
|
42476
|
+
};
|
|
42477
|
+
const summary = {
|
|
42478
|
+
inputTokens: sum("inputTokens"),
|
|
42479
|
+
outputTokens: sum("outputTokens"),
|
|
42480
|
+
totalTokens: sum("totalTokens"),
|
|
42481
|
+
coverage: reports.every((r2) => r2.coverage === "not_recorded") ? "not_recorded" : reports.every((r2) => r2.coverage === "available") ? "available" : "partial"
|
|
42482
|
+
};
|
|
42483
|
+
return { reports, summary };
|
|
42484
|
+
};
|
|
42485
|
+
var buildContentDescriptors = (facts) => {
|
|
42486
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
42487
|
+
const replyChunks = /* @__PURE__ */ new Map();
|
|
42488
|
+
for (const fact of facts) {
|
|
42489
|
+
if (fact.name !== ETelemetryEventName.CONTENT_RECORDED)
|
|
42490
|
+
continue;
|
|
42491
|
+
const body = fact.body;
|
|
42492
|
+
if (!body?.section)
|
|
42493
|
+
continue;
|
|
42494
|
+
const { operationId, recordId, advanceId } = fact.identity;
|
|
42495
|
+
if (body.section === "model.output" && typeof body.chunkIndex === "number") {
|
|
42496
|
+
const key = `${advanceId}:${operationId}:model.output`;
|
|
42497
|
+
const chunks = replyChunks.get(key) ?? /* @__PURE__ */ new Map();
|
|
42498
|
+
if (recordId)
|
|
42499
|
+
chunks.set(recordId, fact);
|
|
42500
|
+
replyChunks.set(key, chunks);
|
|
42501
|
+
continue;
|
|
42502
|
+
}
|
|
42503
|
+
const dedup = `${advanceId ?? ""}
|
|
42504
|
+
${recordId ?? ""}
|
|
42505
|
+
${body.section}`;
|
|
42506
|
+
if (byKey.has(dedup))
|
|
42507
|
+
continue;
|
|
42508
|
+
const contentRef = {
|
|
42509
|
+
...advanceId ? { advanceId } : {},
|
|
42510
|
+
...operationId ? { operationId } : {},
|
|
42511
|
+
...recordId ? { recordId } : {},
|
|
42512
|
+
section: body.section
|
|
42513
|
+
};
|
|
42514
|
+
byKey.set(dedup, {
|
|
42515
|
+
...operationId ? { operationId } : {},
|
|
42516
|
+
section: body.section,
|
|
42517
|
+
contentRef,
|
|
42518
|
+
valueDigest: (0, import_node_crypto2.createHash)("sha256").update(JSON.stringify(body.value) ?? "").digest("hex"),
|
|
42519
|
+
...body.value && typeof body.value === "object" && (body.section.endsWith(".output") || body.section === "knowledge.input") ? {
|
|
42520
|
+
result: Object.fromEntries(Object.entries(body.value).filter(([key, value]) => ["status", "name", "isError", "action", "server", "knowledgeBaseId"].includes(key) && ["string", "boolean"].includes(typeof value)))
|
|
42521
|
+
} : {},
|
|
42522
|
+
availability: body.availability === "available" ? "available" : body.availability === "partial" ? "partial" : body.availability === "unavailable" ? "unavailable" : "not_recorded"
|
|
42523
|
+
});
|
|
42524
|
+
}
|
|
42525
|
+
for (const [key, records] of replyChunks) {
|
|
42526
|
+
const chunks = [...records.values()].sort((a, b3) => a.body.chunkIndex - b3.body.chunkIndex);
|
|
42527
|
+
if (!chunks.length)
|
|
42528
|
+
continue;
|
|
42529
|
+
const { advanceId, operationId } = chunks[0].identity;
|
|
42530
|
+
const bodies = chunks.map((chunk) => chunk.body);
|
|
42531
|
+
const complete = bodies.every((body, index) => body.chunkIndex === index) && bodies.at(-1)?.final && bodies.at(-1)?.availability === "available";
|
|
42532
|
+
byKey.set(key, {
|
|
42533
|
+
operationId,
|
|
42534
|
+
section: "model.output",
|
|
42535
|
+
contentRef: { advanceId, operationId, section: "model.output", recordIds: chunks.map((chunk) => chunk.identity.recordId) },
|
|
42536
|
+
availability: complete ? "available" : "partial"
|
|
42537
|
+
});
|
|
42538
|
+
}
|
|
42539
|
+
return [...byKey.values()];
|
|
42540
|
+
};
|
|
42541
|
+
var buildDetailRef = (identity) => Buffer.from(JSON.stringify({
|
|
42542
|
+
...identity.threadId ? { threadId: identity.threadId } : {},
|
|
42543
|
+
...identity.runId ? { runId: identity.runId } : {},
|
|
42544
|
+
...identity.advanceId ? { advanceId: identity.advanceId } : {}
|
|
42545
|
+
})).toString("base64");
|
|
42546
|
+
function summarize(input) {
|
|
42547
|
+
const { identity } = input;
|
|
42548
|
+
const facts = [...input.facts].sort((a, b3) => (a.finishedAt ?? a.startedAt ?? 0) - (b3.finishedAt ?? b3.startedAt ?? 0) || Number(a.kind === "span") - Number(b3.kind === "span") || (a.identity.recordId ?? "").localeCompare(b3.identity.recordId ?? "") || a.identity.source.localeCompare(b3.identity.source));
|
|
42549
|
+
const query = extractQueryInput(facts);
|
|
42550
|
+
const { operations, relations } = buildOperations(facts);
|
|
42551
|
+
const { reports: usageReports, summary: usageSummary } = buildUsage(facts);
|
|
42552
|
+
const contentDescriptors = buildContentDescriptors(facts);
|
|
42553
|
+
const observation = {
|
|
42554
|
+
terminalObserved: operations.some((op) => (op.operationName === "harness.advance" || op.operationName?.startsWith("invoke_agent ")) && op.finishedAt !== void 0),
|
|
42555
|
+
sourceExhausted: input.observation?.sourceExhausted ?? true,
|
|
42556
|
+
coverage: facts.length === 0 ? "not_recorded" : input.observation?.warnings?.length || operations.some((op) => op.finishedAt === void 0) ? "partial" : "available",
|
|
42557
|
+
warnings: input.observation?.warnings ?? []
|
|
42558
|
+
};
|
|
42559
|
+
return {
|
|
42560
|
+
identity,
|
|
42561
|
+
detailRef: buildDetailRef(identity),
|
|
42562
|
+
query,
|
|
42563
|
+
operations,
|
|
42564
|
+
relations,
|
|
42565
|
+
usageReports,
|
|
42566
|
+
usageSummary,
|
|
42567
|
+
contentDescriptors,
|
|
42568
|
+
observation
|
|
42569
|
+
};
|
|
42570
|
+
}
|
|
42571
|
+
|
|
42572
|
+
// src/utils/otlpScanner.ts
|
|
42573
|
+
var import_node_path12 = __toESM(require("node:path"));
|
|
42574
|
+
var import_node_crypto3 = require("node:crypto");
|
|
42575
|
+
var import_promises20 = require("node:fs/promises");
|
|
42576
|
+
|
|
42577
|
+
// src/commands/runs/types.ts
|
|
42578
|
+
var OTLP_LOG_FILES = {
|
|
42579
|
+
logs: "agent-otlp-logs.log",
|
|
42580
|
+
traces: "agent-oltp-traces.log"
|
|
42581
|
+
};
|
|
42582
|
+
var LOGS_ROOT = ".linkque/logs";
|
|
42583
|
+
var advanceStartedAt = (fact) => fact.name === "harness.advance.started" || fact.kind === "span" && (fact.name === "harness.advance" || fact.name?.startsWith("invoke_agent ")) ? fact.startedAt : void 0;
|
|
42584
|
+
var parseDetailRef = (ref) => {
|
|
42585
|
+
try {
|
|
42586
|
+
const decoded = JSON.parse(
|
|
42587
|
+
Buffer.from(ref, "base64").toString("utf8")
|
|
42588
|
+
);
|
|
42589
|
+
if (!decoded || typeof decoded !== "object" || typeof decoded.advanceId !== "string" || !decoded.advanceId)
|
|
42590
|
+
return void 0;
|
|
42591
|
+
if (decoded.threadId !== void 0 && typeof decoded.threadId !== "string")
|
|
42592
|
+
return void 0;
|
|
42593
|
+
if (decoded.runId !== void 0 && typeof decoded.runId !== "string")
|
|
42594
|
+
return void 0;
|
|
42595
|
+
if (decoded.readWindow !== void 0 && (!Array.isArray(decoded.readWindow) || decoded.readWindow.length > 8 || decoded.readWindow.some((entry) => !entry || !["logs", "traces"].includes(entry.source) || !Number.isSafeInteger(entry.bytes) || entry.bytes < 0 || !/^[a-f0-9]{64}$/.test(entry.digest)))) return void 0;
|
|
42596
|
+
return {
|
|
42597
|
+
readWindow: decoded.readWindow,
|
|
42598
|
+
advanceId: decoded.advanceId,
|
|
42599
|
+
threadId: decoded.threadId,
|
|
42600
|
+
runId: decoded.runId
|
|
42601
|
+
};
|
|
42602
|
+
} catch {
|
|
42603
|
+
return void 0;
|
|
42604
|
+
}
|
|
42605
|
+
};
|
|
42606
|
+
|
|
42607
|
+
// src/utils/otlpScanner.ts
|
|
42608
|
+
var scanFile = (content, source) => {
|
|
42609
|
+
if (!content) return { facts: [], warnings: [] };
|
|
42610
|
+
const facts = [];
|
|
42611
|
+
const warnings = [];
|
|
42612
|
+
const lines = content.split("\n");
|
|
42613
|
+
if (lines.pop()) warnings.push("incomplete_tail");
|
|
42614
|
+
for (const line of lines) {
|
|
42615
|
+
if (!line) continue;
|
|
42616
|
+
const { facts: lineFacts, warnings: lineWarnings } = decodeOtlpLine(
|
|
42617
|
+
line,
|
|
42618
|
+
source
|
|
42619
|
+
);
|
|
42620
|
+
for (const fact of lineFacts) facts.push(fact);
|
|
42621
|
+
for (const w2 of lineWarnings) warnings.push(w2);
|
|
42622
|
+
}
|
|
42623
|
+
return { facts, warnings };
|
|
42624
|
+
};
|
|
42625
|
+
async function scanRetainedLogs(cwd, pinned) {
|
|
42626
|
+
const dir = import_node_path12.default.join(cwd, LOGS_ROOT);
|
|
42627
|
+
let files;
|
|
42628
|
+
try {
|
|
42629
|
+
files = await (0, import_promises20.readdir)(dir);
|
|
42630
|
+
} catch (error2) {
|
|
42631
|
+
if (isNodeError(error2, "ENOENT"))
|
|
42632
|
+
return { facts: [], warnings: ["source_unavailable"], readWindow: [] };
|
|
42633
|
+
throw error2;
|
|
42634
|
+
}
|
|
42635
|
+
const facts = [];
|
|
42636
|
+
const warnings = [];
|
|
42637
|
+
const readWindow = [];
|
|
42638
|
+
const remaining = new Set(pinned);
|
|
42639
|
+
const retainedFiles = /* @__PURE__ */ new Map();
|
|
42640
|
+
for (const [source, file] of Object.entries(OTLP_LOG_FILES)) {
|
|
42641
|
+
for (let index = 0; index <= 3; index++) {
|
|
42642
|
+
retainedFiles.set(index ? `${file}.${index}` : file, source);
|
|
42643
|
+
}
|
|
42644
|
+
}
|
|
42645
|
+
const selected = files.filter((file) => retainedFiles.has(file)).toSorted();
|
|
42646
|
+
for (const file of selected) {
|
|
42647
|
+
try {
|
|
42648
|
+
const source = retainedFiles.get(file);
|
|
42649
|
+
const filePath = import_node_path12.default.join(dir, file);
|
|
42650
|
+
const before = await (0, import_promises20.stat)(filePath);
|
|
42651
|
+
const content = await (0, import_promises20.readFile)(filePath);
|
|
42652
|
+
const after = await (0, import_promises20.stat)(filePath);
|
|
42653
|
+
if (before.ino !== after.ino || after.size < before.size) {
|
|
42654
|
+
warnings.push("log_rotated_during_read");
|
|
42655
|
+
continue;
|
|
42656
|
+
}
|
|
42657
|
+
let complete = content.subarray(0, content.lastIndexOf(10) + 1);
|
|
42658
|
+
let window;
|
|
42659
|
+
if (pinned) {
|
|
42660
|
+
window = [...remaining].find((entry) => entry.source === source && content.length >= entry.bytes && (0, import_node_crypto3.createHash)("sha256").update(content.subarray(0, entry.bytes)).digest("hex") === entry.digest);
|
|
42661
|
+
if (!window) continue;
|
|
42662
|
+
remaining.delete(window);
|
|
42663
|
+
complete = content.subarray(0, window.bytes);
|
|
42664
|
+
} else {
|
|
42665
|
+
if (complete.length !== content.length) warnings.push("incomplete_tail");
|
|
42666
|
+
window = { source, bytes: complete.length, digest: (0, import_node_crypto3.createHash)("sha256").update(complete).digest("hex") };
|
|
42667
|
+
}
|
|
42668
|
+
readWindow.push(window);
|
|
42669
|
+
const decoded = scanFile(complete.toString("utf8"), source);
|
|
42670
|
+
for (const fact of decoded.facts) facts.push(fact);
|
|
42671
|
+
for (const warning of decoded.warnings) warnings.push(warning);
|
|
42672
|
+
} catch (error2) {
|
|
42673
|
+
if (!isNodeError(error2, "ENOENT")) throw error2;
|
|
42674
|
+
warnings.push("log_rotated_during_read");
|
|
42675
|
+
}
|
|
42676
|
+
}
|
|
42677
|
+
if (!selected.some((file) => retainedFiles.get(file) === "logs") || !selected.some((file) => retainedFiles.get(file) === "traces"))
|
|
42678
|
+
warnings.push("signal_unavailable");
|
|
42679
|
+
if (pinned && remaining.size) warnings.push("read_window_expired");
|
|
42680
|
+
return { facts, warnings: [...new Set(warnings)], readWindow };
|
|
42681
|
+
}
|
|
42682
|
+
|
|
42683
|
+
// src/commands/runs/listScanner.ts
|
|
42684
|
+
var isContentRecord = (fact) => fact.name === ETelemetryEventName.CONTENT_RECORDED;
|
|
42685
|
+
var decodeContentBody = (fact) => {
|
|
42686
|
+
const body = fact.body;
|
|
42687
|
+
return body ?? {};
|
|
42688
|
+
};
|
|
42689
|
+
var aggregate = (facts) => {
|
|
42690
|
+
const byRun = /* @__PURE__ */ new Map();
|
|
42691
|
+
for (const fact of facts) {
|
|
42692
|
+
const { threadId, runId } = fact.identity;
|
|
42693
|
+
if (!runId) continue;
|
|
42694
|
+
const key = `${threadId ?? ""}
|
|
42695
|
+
${runId}`;
|
|
42696
|
+
let item = byRun.get(key);
|
|
42697
|
+
if (!item) {
|
|
42698
|
+
item = {
|
|
42699
|
+
runId,
|
|
42700
|
+
...threadId ? { threadId } : {},
|
|
42701
|
+
query: { availability: "not_recorded" }
|
|
42702
|
+
};
|
|
42703
|
+
byRun.set(key, item);
|
|
42704
|
+
}
|
|
42705
|
+
const startedAt = advanceStartedAt(fact);
|
|
42706
|
+
if (startedAt !== void 0) {
|
|
42707
|
+
const cur = item.startedAt;
|
|
42708
|
+
if (cur === void 0 || startedAt < cur) {
|
|
42709
|
+
item.startedAt = startedAt;
|
|
42710
|
+
}
|
|
42711
|
+
}
|
|
42712
|
+
if (isContentRecord(fact)) {
|
|
42713
|
+
const body = decodeContentBody(fact);
|
|
42714
|
+
if (body.section === ETelemetryContentSection.QUERY_INPUT) {
|
|
42715
|
+
const text = typeof body.value === "string" && body.value ? body.value : void 0;
|
|
42716
|
+
byRun.set(key, {
|
|
42717
|
+
...item,
|
|
42718
|
+
query: {
|
|
42719
|
+
text,
|
|
42720
|
+
inputType: body.inputType === "card" ? "card" : void 0,
|
|
42721
|
+
displayText: typeof body.displayText === "string" && body.displayText ? body.displayText : void 0,
|
|
42722
|
+
availability: body.availability === "available" ? "available" : body.availability === "partial" ? "partial" : "not_recorded"
|
|
42723
|
+
}
|
|
42724
|
+
});
|
|
42725
|
+
}
|
|
42726
|
+
}
|
|
42727
|
+
}
|
|
42728
|
+
return [...byRun.values()];
|
|
42729
|
+
};
|
|
42730
|
+
var scanQueries = async (input) => {
|
|
42731
|
+
const { facts, warnings } = await scanRetainedLogs(input.cwd);
|
|
42732
|
+
let items = aggregate(facts);
|
|
42733
|
+
if (input.threadId)
|
|
42734
|
+
items = items.filter((item) => item.threadId === input.threadId);
|
|
42735
|
+
items.sort(
|
|
42736
|
+
(a, b3) => (b3.startedAt ?? 0) - (a.startedAt ?? 0) || a.runId.localeCompare(b3.runId) || (a.threadId ?? "").localeCompare(b3.threadId ?? "")
|
|
42737
|
+
);
|
|
42738
|
+
const limit = input.limit && input.limit > 0 ? input.limit : items.length;
|
|
42739
|
+
const startIdx = input.cursor ? Number(input.cursor) : 0;
|
|
42740
|
+
const safeStart = Number.isFinite(startIdx) && startIdx >= 0 ? startIdx : 0;
|
|
42741
|
+
const page = items.slice(safeStart, safeStart + limit);
|
|
42742
|
+
const observation = {
|
|
42743
|
+
terminalObserved: false,
|
|
42744
|
+
// 列表扫描完成不等于执行已结束
|
|
42745
|
+
sourceExhausted: true,
|
|
42746
|
+
coverage: facts.length === 0 ? "not_recorded" : warnings.length ? "partial" : "available",
|
|
42747
|
+
warnings
|
|
42748
|
+
};
|
|
42749
|
+
const nextIndex = safeStart + page.length;
|
|
42750
|
+
return {
|
|
42751
|
+
items: page,
|
|
42752
|
+
...nextIndex < items.length ? { nextCursor: String(nextIndex) } : {},
|
|
42753
|
+
observation
|
|
42754
|
+
};
|
|
42755
|
+
};
|
|
42756
|
+
|
|
42757
|
+
// src/commands/runs/showScanner.ts
|
|
42758
|
+
var selectLatestAdvance = (facts, threadId, runId) => {
|
|
42759
|
+
const byAdvance = /* @__PURE__ */ new Map();
|
|
42760
|
+
for (const fact of facts) {
|
|
42761
|
+
const { advanceId, threadId: fThreadId, runId: fRunId } = fact.identity;
|
|
42762
|
+
if (!advanceId) continue;
|
|
42763
|
+
if (runId && fRunId !== runId) continue;
|
|
42764
|
+
if (threadId && fThreadId !== threadId) continue;
|
|
42765
|
+
const key = advanceId;
|
|
42766
|
+
let group = byAdvance.get(key);
|
|
42767
|
+
if (!group) {
|
|
42768
|
+
group = {
|
|
42769
|
+
identity: {
|
|
42770
|
+
...fThreadId ? { threadId: fThreadId } : {},
|
|
42771
|
+
...fRunId ? { runId: fRunId } : {},
|
|
42772
|
+
advanceId
|
|
42773
|
+
},
|
|
42774
|
+
facts: []
|
|
42775
|
+
};
|
|
42776
|
+
byAdvance.set(key, group);
|
|
42777
|
+
}
|
|
42778
|
+
group.facts.push(fact);
|
|
42779
|
+
const startedAt = advanceStartedAt(fact);
|
|
42780
|
+
if (startedAt !== void 0 && (group.startedAt === void 0 || startedAt < group.startedAt)) {
|
|
42781
|
+
group.startedAt = startedAt;
|
|
42782
|
+
}
|
|
42783
|
+
}
|
|
42784
|
+
if (byAdvance.size === 0) return void 0;
|
|
42785
|
+
const byRun = /* @__PURE__ */ new Map();
|
|
42786
|
+
for (const group of byAdvance.values()) {
|
|
42787
|
+
const runKey = `${group.identity.threadId ?? ""}
|
|
42788
|
+
${group.identity.runId ?? ""}`;
|
|
42789
|
+
const existing = byRun.get(runKey);
|
|
42790
|
+
if (!existing || group.startedAt !== void 0 && (existing.startedAt === void 0 || group.startedAt < existing.startedAt)) {
|
|
42791
|
+
byRun.set(runKey, { runKey, startedAt: group.startedAt });
|
|
42792
|
+
}
|
|
42793
|
+
}
|
|
42794
|
+
const latestRun = [...byRun.values()].toSorted(
|
|
42795
|
+
(a, b3) => (b3.startedAt ?? -Infinity) - (a.startedAt ?? -Infinity) || a.runKey.localeCompare(b3.runKey)
|
|
42796
|
+
)[0];
|
|
42797
|
+
if (!latestRun) return void 0;
|
|
42798
|
+
const sorted = [...byAdvance.values()].filter(
|
|
42799
|
+
(g2) => `${g2.identity.threadId ?? ""}
|
|
42800
|
+
${g2.identity.runId ?? ""}` === latestRun.runKey
|
|
42801
|
+
).toSorted(
|
|
42802
|
+
(a, b3) => (b3.startedAt ?? -Infinity) - (a.startedAt ?? -Infinity) || (a.identity.advanceId ?? "").localeCompare(b3.identity.advanceId ?? "")
|
|
42803
|
+
);
|
|
42804
|
+
const latest = sorted[0];
|
|
42805
|
+
return latest ? { identity: latest.identity, facts: latest.facts } : void 0;
|
|
42806
|
+
};
|
|
42807
|
+
var scanExecution = async (input) => {
|
|
42808
|
+
const identity = input.detailRef === void 0 ? void 0 : parseDetailRef(input.detailRef);
|
|
42809
|
+
if (input.detailRef !== void 0 && !identity) return null;
|
|
42810
|
+
const { facts, warnings, readWindow } = await scanRetainedLogs(input.cwd, identity?.readWindow);
|
|
42811
|
+
if (warnings.includes("read_window_expired")) return null;
|
|
42812
|
+
if (identity) {
|
|
42813
|
+
const filtered = facts.filter(
|
|
42814
|
+
(f3) => (!identity.threadId || f3.identity.threadId === identity.threadId) && (!identity.advanceId || f3.identity.advanceId === identity.advanceId) && (!identity.runId || f3.identity.runId === identity.runId)
|
|
42815
|
+
);
|
|
42816
|
+
if (!filtered.length) return null;
|
|
42817
|
+
const { readWindow: _window, ...executionIdentity } = identity;
|
|
42818
|
+
const snapshot2 = summarize({ identity: executionIdentity, facts: filtered, observation: { warnings } });
|
|
42819
|
+
return { ...snapshot2, detailRef: input.detailRef };
|
|
42820
|
+
}
|
|
42821
|
+
const selected = selectLatestAdvance(facts, input.threadId, input.runId);
|
|
42822
|
+
if (!selected) return null;
|
|
42823
|
+
const snapshot = summarize({ ...selected, observation: { warnings } });
|
|
42824
|
+
return { ...snapshot, detailRef: Buffer.from(JSON.stringify({ ...selected.identity, readWindow })).toString("base64") };
|
|
42825
|
+
};
|
|
42826
|
+
|
|
42827
|
+
// src/commands/runs/contentScanner.ts
|
|
42828
|
+
var matchContentRef = (fact, ref) => {
|
|
42829
|
+
const { advanceId, operationId, recordId, section } = ref;
|
|
42830
|
+
if (advanceId && fact.identity.advanceId !== advanceId) return false;
|
|
42831
|
+
if (operationId && fact.identity.operationId !== operationId) return false;
|
|
42832
|
+
if (recordId && fact.identity.recordId !== recordId) return false;
|
|
42833
|
+
const body = fact.body;
|
|
42834
|
+
return body?.section === section;
|
|
42835
|
+
};
|
|
42836
|
+
var scanContent = async (input) => {
|
|
42837
|
+
const identity = parseDetailRef(input.detailRef);
|
|
42838
|
+
if (!identity) return null;
|
|
42839
|
+
let contentRef;
|
|
42840
|
+
try {
|
|
42841
|
+
contentRef = JSON.parse(
|
|
42842
|
+
Buffer.from(input.contentRef, "base64").toString("utf8")
|
|
42843
|
+
);
|
|
42844
|
+
} catch {
|
|
42845
|
+
return null;
|
|
42846
|
+
}
|
|
42847
|
+
if (!contentRef || typeof contentRef !== "object" || typeof contentRef.section !== "string" || !contentRef.section)
|
|
42848
|
+
return null;
|
|
42849
|
+
for (const value of [
|
|
42850
|
+
contentRef.advanceId,
|
|
42851
|
+
contentRef.operationId,
|
|
42852
|
+
contentRef.recordId
|
|
42853
|
+
]) {
|
|
42854
|
+
if (value !== void 0 && (typeof value !== "string" || !value))
|
|
42855
|
+
return null;
|
|
42856
|
+
}
|
|
42857
|
+
if (contentRef.recordIds !== void 0 && (!Array.isArray(contentRef.recordIds) || !contentRef.recordIds.length || contentRef.recordIds.length > 128 || contentRef.recordIds.some((id) => typeof id !== "string" || !id))) return null;
|
|
42858
|
+
if (input.cursor !== void 0 && !/^(0|[1-9][0-9]*)$/.test(input.cursor))
|
|
42859
|
+
return null;
|
|
42860
|
+
if (input.maxBytes !== void 0 && (!Number.isSafeInteger(input.maxBytes) || input.maxBytes < 1))
|
|
42861
|
+
return null;
|
|
42862
|
+
const { facts, warnings } = await scanRetainedLogs(input.cwd, identity.readWindow);
|
|
42863
|
+
if (warnings.includes("read_window_expired")) return { availability: "unavailable" };
|
|
42864
|
+
let matched = facts.find(
|
|
42865
|
+
(f3) => f3.name === ETelemetryEventName.CONTENT_RECORDED && (!identity.threadId || f3.identity.threadId === identity.threadId) && (!identity.advanceId || f3.identity.advanceId === identity.advanceId) && (!identity.runId || f3.identity.runId === identity.runId) && matchContentRef(f3, contentRef)
|
|
42866
|
+
);
|
|
42867
|
+
if (contentRef.recordIds) {
|
|
42868
|
+
const byRecord = new Map(facts.filter((f3) => f3.name === ETelemetryEventName.CONTENT_RECORDED && f3.identity.advanceId === identity.advanceId && (!identity.threadId || f3.identity.threadId === identity.threadId) && (!identity.runId || f3.identity.runId === identity.runId) && f3.identity.operationId === contentRef.operationId).map((f3) => [f3.identity.recordId, f3]));
|
|
42869
|
+
const chunks = contentRef.recordIds.map((id) => byRecord.get(id));
|
|
42870
|
+
if (chunks.some((chunk) => !chunk)) return { availability: "unavailable" };
|
|
42871
|
+
const values = chunks.map((chunk) => chunk.body);
|
|
42872
|
+
if (values.some((value) => value.section !== "model.output" || typeof value.value !== "string")) return null;
|
|
42873
|
+
const prefix = [];
|
|
42874
|
+
for (const value of values) {
|
|
42875
|
+
if (value.chunkIndex !== prefix.length) break;
|
|
42876
|
+
prefix.push(value);
|
|
42877
|
+
}
|
|
42878
|
+
if (!prefix.length) return { availability: "unavailable" };
|
|
42879
|
+
const complete = prefix.length === values.length && prefix.at(-1)?.final && prefix.at(-1)?.availability === "available";
|
|
42880
|
+
matched = { ...chunks[0], body: { value: prefix.map((value) => value.value).join(""), availability: complete ? "available" : "partial" } };
|
|
42881
|
+
}
|
|
42882
|
+
if (!matched) {
|
|
42883
|
+
return { availability: "unavailable" };
|
|
42884
|
+
}
|
|
42885
|
+
const body = matched.body;
|
|
42886
|
+
const availability = body.availability === "available" ? "available" : body.availability === "partial" ? "partial" : body.availability === "unavailable" ? "unavailable" : "available";
|
|
42887
|
+
const maxBytes = input.maxBytes ?? 1024 * 1024;
|
|
42888
|
+
if (body.value === void 0) return { availability: "not_recorded" };
|
|
42889
|
+
const serialized = JSON.stringify(body.value);
|
|
42890
|
+
const buf = Buffer.from(serialized, "utf8");
|
|
42891
|
+
const totalBytes = buf.length;
|
|
42892
|
+
const offset = input.cursor === void 0 ? 0 : Number(input.cursor);
|
|
42893
|
+
if (!Number.isSafeInteger(offset) || offset < 0 || offset < totalBytes && (buf[offset] & 192) === 128)
|
|
42894
|
+
return null;
|
|
42895
|
+
if (offset >= totalBytes) {
|
|
42896
|
+
return { availability: "available" };
|
|
42897
|
+
}
|
|
42898
|
+
const remaining = totalBytes - offset;
|
|
42899
|
+
const pageBytes = Math.min(maxBytes, remaining);
|
|
42900
|
+
const isFullContent = offset === 0 && totalBytes <= maxBytes;
|
|
42901
|
+
const titles = body.fieldTitles;
|
|
42902
|
+
const fieldTitles = titles && typeof titles === "object" && !Array.isArray(titles) ? Object.fromEntries(
|
|
42903
|
+
Object.entries(titles).filter(
|
|
42904
|
+
([path24, title]) => path24.startsWith("/") && typeof title === "string"
|
|
42905
|
+
)
|
|
42906
|
+
) : void 0;
|
|
42907
|
+
const evidence = {
|
|
42908
|
+
...body.originalBytes !== void 0 ? { originalBytes: body.originalBytes } : {},
|
|
42909
|
+
...body.storedBytes !== void 0 ? { storedBytes: body.storedBytes } : {},
|
|
42910
|
+
...fieldTitles && Object.keys(fieldTitles).length ? { fieldTitles } : {}
|
|
42911
|
+
};
|
|
42912
|
+
if (isFullContent) {
|
|
42913
|
+
return {
|
|
42914
|
+
content: body.value,
|
|
42915
|
+
contentType: body.contentType,
|
|
42916
|
+
encoding: body.encoding,
|
|
42917
|
+
availability,
|
|
42918
|
+
...Object.keys(evidence).length ? { evidence } : {}
|
|
42919
|
+
};
|
|
42920
|
+
}
|
|
42921
|
+
let end = offset + pageBytes;
|
|
42922
|
+
while (end > offset && end < totalBytes && (buf[end] & 192) === 128) {
|
|
42923
|
+
end--;
|
|
42924
|
+
}
|
|
42925
|
+
if (end === offset) {
|
|
42926
|
+
end = Math.min(offset + 1, totalBytes);
|
|
42927
|
+
while (end < totalBytes && (buf[end] & 192) === 128) end++;
|
|
42928
|
+
}
|
|
42929
|
+
const pageContent = buf.subarray(offset, end).toString("utf8");
|
|
42930
|
+
const nextOffset = end;
|
|
42931
|
+
const hasNext = nextOffset < totalBytes;
|
|
42932
|
+
return {
|
|
42933
|
+
content: pageContent,
|
|
42934
|
+
contentType: "application/json-fragment",
|
|
42935
|
+
encoding: body.encoding,
|
|
42936
|
+
availability: hasNext ? "partial" : availability,
|
|
42937
|
+
nextCursor: hasNext ? String(nextOffset) : void 0,
|
|
42938
|
+
...Object.keys(evidence).length ? { evidence } : {}
|
|
42939
|
+
};
|
|
42940
|
+
};
|
|
42941
|
+
|
|
42942
|
+
// src/commands/runs/index.ts
|
|
42943
|
+
var parseLimit = (value) => {
|
|
42944
|
+
const num = Number(value);
|
|
42945
|
+
if (!Number.isInteger(num) || num < 1 || num > 1e4) {
|
|
42946
|
+
throw new InvalidArgumentError("--limit \u5FC5\u987B\u4E3A 1~10000 \u4E4B\u95F4\u7684\u6574\u6570");
|
|
42947
|
+
}
|
|
42948
|
+
return num;
|
|
42949
|
+
};
|
|
42950
|
+
var parseMaxBytes = (value) => {
|
|
42951
|
+
const num = Number(value);
|
|
42952
|
+
if (!Number.isInteger(num) || num < 1 || num > 16 * 1024 * 1024) {
|
|
42953
|
+
throw new InvalidArgumentError("--max-bytes \u5FC5\u987B\u4E3A 1~16MiB \u4E4B\u95F4\u7684\u6574\u6570");
|
|
42954
|
+
}
|
|
42955
|
+
return num;
|
|
42956
|
+
};
|
|
42957
|
+
var runsList = {
|
|
42958
|
+
name: "runs.list",
|
|
42959
|
+
description: "\u67E5\u770B\u5F53\u524D\u6C99\u7BB1\u4FDD\u7559\u65E5\u5FD7\u4E2D\u7684\u6700\u8FD1\u6267\u884C\u8BB0\u5F55",
|
|
42960
|
+
options: [
|
|
42961
|
+
{
|
|
42962
|
+
flags: "--thread-id <threadId>",
|
|
42963
|
+
description: "\u6309\u4F1A\u8BDD threadId \u8FC7\u6EE4",
|
|
42964
|
+
key: "threadId"
|
|
42965
|
+
},
|
|
42966
|
+
{
|
|
42967
|
+
flags: "--cursor <cursor>",
|
|
42968
|
+
description: "\u5206\u9875\u6E38\u6807\uFF08\u4E0D\u900F\u660E\uFF0C\u975E\u6587\u4EF6\u504F\u79FB\uFF09",
|
|
42969
|
+
key: "cursor"
|
|
42970
|
+
},
|
|
42971
|
+
{
|
|
42972
|
+
flags: "--limit <limit>",
|
|
42973
|
+
description: "\u6700\u591A\u8FD4\u56DE\u7684\u6267\u884C\u8BB0\u5F55\u6570",
|
|
42974
|
+
key: "limit",
|
|
42975
|
+
parse: parseLimit
|
|
42976
|
+
}
|
|
42977
|
+
],
|
|
42978
|
+
summarize: ({ page }) => `\u5217\u51FA ${page.items.length} \u4E2A\u6267\u884C\u8BB0\u5F55${page.nextCursor ? "\uFF08\u8FD8\u6709\u66F4\u591A\uFF09" : ""}\u3002
|
|
42979
|
+
`,
|
|
42980
|
+
run: (cwd, options) => scanQueries({
|
|
42981
|
+
cwd,
|
|
42982
|
+
threadId: options.threadId,
|
|
42983
|
+
cursor: options.cursor,
|
|
42984
|
+
limit: options.limit
|
|
42985
|
+
}).then((page) => ({ page }))
|
|
42986
|
+
};
|
|
42987
|
+
var runsShow = {
|
|
42988
|
+
name: "runs.show",
|
|
42989
|
+
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",
|
|
42990
|
+
options: [
|
|
42991
|
+
{
|
|
42992
|
+
flags: "--thread-id <threadId>",
|
|
42993
|
+
description: "\u4F1A\u8BDD threadId\uFF08\u4E0E --run-id \u914D\u5BF9\u4F7F\u7528\uFF09",
|
|
42994
|
+
key: "threadId"
|
|
42995
|
+
},
|
|
42996
|
+
{
|
|
42997
|
+
flags: "--run-id <runId>",
|
|
42998
|
+
description: "\u6267\u884C runId\uFF08\u4E0E --thread-id \u914D\u5BF9\u4F7F\u7528\uFF09",
|
|
42999
|
+
key: "runId"
|
|
43000
|
+
},
|
|
43001
|
+
{
|
|
43002
|
+
flags: "--detail-ref <detailRef>",
|
|
43003
|
+
description: "\u56FA\u5B9A\u6267\u884C\u5F15\u7528\uFF08\u4E0E\u76EE\u6807\u7B5B\u9009\u4E92\u65A5\uFF09",
|
|
43004
|
+
key: "detailRef"
|
|
43005
|
+
}
|
|
43006
|
+
],
|
|
43007
|
+
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
|
|
43008
|
+
` : "\u672A\u627E\u5230\u5BF9\u5E94\u6267\u884C\u7684\u5FEB\u7167\u3002\n",
|
|
43009
|
+
run: async (cwd, options) => {
|
|
43010
|
+
const threadId = options.threadId?.trim();
|
|
43011
|
+
const runId = options.runId?.trim();
|
|
43012
|
+
const detailRef = options.detailRef?.trim();
|
|
43013
|
+
if (threadId === "" || runId === "" || detailRef === "")
|
|
43014
|
+
throw new InvalidArgumentError("\u6267\u884C\u8EAB\u4EFD\u548C\u56FA\u5B9A\u5F15\u7528\u4E0D\u80FD\u4E3A\u7A7A");
|
|
43015
|
+
if (threadId === void 0 !== (runId === void 0))
|
|
43016
|
+
throw new InvalidArgumentError("--thread-id \u548C --run-id \u5FC5\u987B\u914D\u5BF9\u4F7F\u7528");
|
|
43017
|
+
if (detailRef !== void 0 && threadId !== void 0)
|
|
43018
|
+
throw new InvalidArgumentError(
|
|
43019
|
+
"--detail-ref \u4E0E --thread-id/--run-id \u4E92\u65A5"
|
|
43020
|
+
);
|
|
43021
|
+
const snapshot = await scanExecution({ cwd, threadId, runId, detailRef });
|
|
43022
|
+
return { snapshot };
|
|
43023
|
+
}
|
|
43024
|
+
};
|
|
43025
|
+
var runsContent = {
|
|
43026
|
+
name: "runs.content",
|
|
43027
|
+
description: "\u8BFB\u53D6\u6307\u5B9A\u6267\u884C\u7684\u6B63\u6587\u6BB5\u843D",
|
|
43028
|
+
options: [
|
|
43029
|
+
{
|
|
43030
|
+
flags: "--detail-ref <detailRef>",
|
|
43031
|
+
description: "\u56FA\u5B9A\u6267\u884C\u5F15\u7528",
|
|
43032
|
+
key: "detailRef"
|
|
43033
|
+
},
|
|
43034
|
+
{
|
|
43035
|
+
flags: "--content-ref <contentRef>",
|
|
43036
|
+
description: "\u6267\u884C\u8BE6\u60C5\u4E2D\u7684\u6B63\u6587\u5F15\u7528",
|
|
43037
|
+
key: "contentRef"
|
|
43038
|
+
},
|
|
43039
|
+
{ flags: "--cursor <cursor>", description: "\u6B63\u6587\u5206\u9875\u6E38\u6807", key: "cursor" },
|
|
43040
|
+
{
|
|
43041
|
+
flags: "--max-bytes <maxBytes>",
|
|
43042
|
+
description: "\u6BCF\u9875\u6700\u5927\u54CD\u5E94\u5B57\u8282\u6570",
|
|
43043
|
+
key: "maxBytes",
|
|
43044
|
+
parse: parseMaxBytes
|
|
43045
|
+
}
|
|
43046
|
+
],
|
|
43047
|
+
summarize: ({ content }) => content ? `\u6B63\u6587\u6BB5\u843D ${content.availability}${content.nextCursor ? "\uFF08\u5206\u9875\u4E2D\uFF09" : ""}\u3002
|
|
43048
|
+
` : "\u672A\u627E\u5230\u5BF9\u5E94\u6B63\u6587\u3002\n",
|
|
43049
|
+
run: async (cwd, options) => {
|
|
43050
|
+
if (!options.detailRef || !options.contentRef)
|
|
43051
|
+
throw new InvalidArgumentError("--detail-ref \u548C --content-ref \u5747\u4E3A\u5FC5\u586B");
|
|
43052
|
+
const content = await scanContent({
|
|
43053
|
+
cwd,
|
|
43054
|
+
detailRef: options.detailRef,
|
|
43055
|
+
contentRef: options.contentRef,
|
|
43056
|
+
cursor: options.cursor,
|
|
43057
|
+
maxBytes: options.maxBytes
|
|
43058
|
+
});
|
|
43059
|
+
return { content };
|
|
43060
|
+
}
|
|
43061
|
+
};
|
|
43062
|
+
|
|
42135
43063
|
// src/commands/registry.ts
|
|
42136
43064
|
var parsePort = (value) => {
|
|
42137
43065
|
const port = Number(value);
|
|
@@ -42513,6 +43441,10 @@ var agentdevStart = {
|
|
|
42513
43441
|
{
|
|
42514
43442
|
name: "LINKQUE_TELEMETRY_ENVIRONMENT",
|
|
42515
43443
|
description: "\u5BBF\u4E3B\u9065\u6D4B\u73AF\u5883\u6807\u8BC6\uFF0C\u9ED8\u8BA4 agentdev"
|
|
43444
|
+
},
|
|
43445
|
+
{
|
|
43446
|
+
name: "LOG_LEVEL",
|
|
43447
|
+
description: "\u65E5\u5FD7\u7EA7\u522B\uFF0C\u9ED8\u8BA4 DEBUG, \u5F00\u542F PI_EVENT/HTTP/MCP/SKILL \u8BE6\u7EC6\u65E5\u5FD7\uFF0C\u5FFD\u7565\u5927\u5C0F\u5199"
|
|
42516
43448
|
}
|
|
42517
43449
|
],
|
|
42518
43450
|
summarize: ({ port, reused }) => `Agent server ${reused ? "reused" : "started"} on port ${port}.
|
|
@@ -42772,6 +43704,9 @@ var COMMANDS = [
|
|
|
42772
43704
|
platformSdkApplyCommand,
|
|
42773
43705
|
agentBuildCommand,
|
|
42774
43706
|
agentDeployCommand,
|
|
43707
|
+
runsList,
|
|
43708
|
+
runsShow,
|
|
43709
|
+
runsContent,
|
|
42775
43710
|
version2
|
|
42776
43711
|
];
|
|
42777
43712
|
|
|
@@ -42789,7 +43724,8 @@ var GROUP_DESCRIPTIONS = {
|
|
|
42789
43724
|
build: "build archives from the workspace",
|
|
42790
43725
|
card: "inspect A2UI card drafts in the workspace",
|
|
42791
43726
|
inspector: "apply Inspector edits to the workspace",
|
|
42792
|
-
"platform-sdk": "apply platform-managed SDK bundles"
|
|
43727
|
+
"platform-sdk": "apply platform-managed SDK bundles",
|
|
43728
|
+
runs: "query recent Query runs from retained sandbox logs"
|
|
42793
43729
|
};
|
|
42794
43730
|
var collectOptions = (target, definitions, values) => {
|
|
42795
43731
|
for (const { flags, key } of definitions) {
|
|
@@ -42886,6 +43822,7 @@ function parseCliInvocation(argv, output) {
|
|
|
42886
43822
|
bindCommandGroup(program2, "card", state);
|
|
42887
43823
|
bindCommandGroup(program2, "inspector", state);
|
|
42888
43824
|
bindCommandGroup(program2, "platform-sdk", state);
|
|
43825
|
+
bindCommandGroup(program2, "runs", state);
|
|
42889
43826
|
program2.exitOverride();
|
|
42890
43827
|
for (const child of program2.commands) exitOverrideDeep(child);
|
|
42891
43828
|
program2.parse(argv, { from: "user" });
|