linkque-cli-v2 1.3.8-beta.1 → 1.4.0

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