linkque-cli-v2 1.4.3 → 1.4.4

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