linkque-cli-v2 1.2.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/linkquejs.js CHANGED
@@ -1196,7 +1196,7 @@ var require_command = __commonJS({
1196
1196
  "../../node_modules/commander/lib/command.js"(exports2) {
1197
1197
  var EventEmitter = require("node:events").EventEmitter;
1198
1198
  var childProcess = require("node:child_process");
1199
- var path22 = 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 = path22.resolve(baseDir, baseName);
2212
+ const localBin = path23.resolve(baseDir, baseName);
2213
2213
  if (fs2.existsSync(localBin)) return localBin;
2214
- if (sourceExt.includes(path22.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 = path22.resolve(
2233
- path22.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 = path22.basename(
2240
+ const legacyName = path23.basename(
2241
2241
  this._scriptPath,
2242
- path22.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(path22.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 = path22.basename(filename, path22.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(path23) {
3183
- if (path23 === void 0) return this._executableDir;
3184
- this._executableDir = path23;
3182
+ executableDir(path24) {
3183
+ if (path24 === void 0) return this._executableDir;
3184
+ this._executableDir = path24;
3185
3185
  return this;
3186
3186
  }
3187
3187
  /**
@@ -6261,6 +6261,7 @@ __export(zip_reader_exports, {
6261
6261
  WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD: () => WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD,
6262
6262
  WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES: () => WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES,
6263
6263
  WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY: () => WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY,
6264
+ WARNING_PREPENDED_CENTRAL_DIRECTORY: () => WARNING_PREPENDED_CENTRAL_DIRECTORY,
6264
6265
  WARNING_PREPENDED_DATA: () => WARNING_PREPENDED_DATA,
6265
6266
  WARNING_TRAILING_CENTRAL_DIRECTORY_DATA: () => WARNING_TRAILING_CENTRAL_DIRECTORY_DATA,
6266
6267
  WARNING_UNKNOWN_VERSION: () => WARNING_UNKNOWN_VERSION,
@@ -6942,7 +6943,7 @@ function getBigUint64(view, offset) {
6942
6943
  }
6943
6944
  return Number(value);
6944
6945
  }
6945
- var ERR_BAD_FORMAT, ERR_EOCDR_NOT_FOUND, ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_LOCAL_FILE_HEADER_NOT_FOUND, ERR_EXTRAFIELD_ZIP64_NOT_FOUND, ERR_ENCRYPTED, ERR_UNSUPPORTED_ENCRYPTION, ERR_UNSUPPORTED_COMPRESSION2, ERR_SPLIT_ZIP_FILE, ERR_OVERLAPPING_ENTRY, ERR_ENTRY_DATA_OUT_OF_BOUNDS, ERR_AMBIGUOUS_ARCHIVE, ERR_ENCRYPTED_CENTRAL_DIRECTORY, ERR_UNSAFE_FILENAME, ERR_INVALID_STRICTNESS, ERR_INVALID_FILENAME_VALIDATION, ERR_INVALID_MAX_APPENDED_DATA_SIZE, ERR_UNSUPPORTED_UINT64, WARNING_UNSORTED_CENTRAL_DIRECTORY, WARNING_UNKNOWN_VERSION, WARNING_COMPRESSED_PATCHED_DATA, WARNING_MALFORMED_EXTRA_FIELD, WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA, WARNING_WRAPPED_ENTRIES_COUNT, WARNING_APPENDED_DATA, WARNING_PREPENDED_DATA, WARNING_TRAILING_CENTRAL_DIRECTORY_DATA, WARNING_DUPLICATE_FILENAME, WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY, WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG, WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD, WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES, MAX_KNOWN_VERSION, DRIVE_LETTER_REGEXP, CHARSET_UTF8, PROPERTY_NAME_UTF8_SUFFIX, CHARSET_CP437, BITFLAG_AMBIGUITY_MASK, VENDOR_VERSION_AE_1, ZIP64_PROPERTIES, ZIP64_EXTRACTION, MAX_SAFE_UINT64, MAX_END_OF_CENTRAL_DIR_PROBES, MAX_DEFLATE_EXPANSION_RATIO, CENTRAL_DIRECTORY_UNREACHABLE, CENTRAL_DIRECTORY_PLAUSIBLE, CENTRAL_DIRECTORY_REACHABLE, ZipReader, ZipReaderStream, ZipEntry;
6946
+ var ERR_BAD_FORMAT, ERR_EOCDR_NOT_FOUND, ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_LOCAL_FILE_HEADER_NOT_FOUND, ERR_EXTRAFIELD_ZIP64_NOT_FOUND, ERR_ENCRYPTED, ERR_UNSUPPORTED_ENCRYPTION, ERR_UNSUPPORTED_COMPRESSION2, ERR_SPLIT_ZIP_FILE, ERR_OVERLAPPING_ENTRY, ERR_ENTRY_DATA_OUT_OF_BOUNDS, ERR_AMBIGUOUS_ARCHIVE, ERR_ENCRYPTED_CENTRAL_DIRECTORY, ERR_UNSAFE_FILENAME, ERR_INVALID_STRICTNESS, ERR_INVALID_FILENAME_VALIDATION, ERR_INVALID_MAX_APPENDED_DATA_SIZE, ERR_UNSUPPORTED_UINT64, WARNING_UNSORTED_CENTRAL_DIRECTORY, WARNING_UNKNOWN_VERSION, WARNING_COMPRESSED_PATCHED_DATA, WARNING_MALFORMED_EXTRA_FIELD, WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA, WARNING_WRAPPED_ENTRIES_COUNT, WARNING_APPENDED_DATA, WARNING_PREPENDED_DATA, WARNING_PREPENDED_CENTRAL_DIRECTORY, WARNING_TRAILING_CENTRAL_DIRECTORY_DATA, WARNING_DUPLICATE_FILENAME, WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY, WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG, WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD, WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES, MAX_KNOWN_VERSION, DRIVE_LETTER_REGEXP, CHARSET_UTF8, PROPERTY_NAME_UTF8_SUFFIX, CHARSET_CP437, BITFLAG_AMBIGUITY_MASK, VENDOR_VERSION_AE_1, ZIP64_PROPERTIES, ZIP64_EXTRACTION, MAX_SAFE_UINT64, MAX_END_OF_CENTRAL_DIR_PROBES, MAX_DEFLATE_EXPANSION_RATIO, CENTRAL_DIRECTORY_UNREACHABLE, CENTRAL_DIRECTORY_PLAUSIBLE, CENTRAL_DIRECTORY_REACHABLE, ZipReader, ZipReaderStream, ZipEntry;
6946
6947
  var init_zip_reader = __esm({
6947
6948
  "../../node_modules/@zip.js/zip.js/lib/core/zip-reader.js"() {
6948
6949
  init_constants();
@@ -6983,6 +6984,7 @@ var init_zip_reader = __esm({
6983
6984
  WARNING_WRAPPED_ENTRIES_COUNT = "wrapped entries count";
6984
6985
  WARNING_APPENDED_DATA = "appended data";
6985
6986
  WARNING_PREPENDED_DATA = "prepended data";
6987
+ WARNING_PREPENDED_CENTRAL_DIRECTORY = "prepended central directory";
6986
6988
  WARNING_TRAILING_CENTRAL_DIRECTORY_DATA = "trailing central directory data";
6987
6989
  WARNING_DUPLICATE_FILENAME = "duplicate filename";
6988
6990
  WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY = "mismatched zip64 end of central directory record";
@@ -7073,6 +7075,7 @@ var init_zip_reader = __esm({
7073
7075
  let diskNumber = getUint16(endOfDirectoryView, 6);
7074
7076
  let filesLength = getUint16(endOfDirectoryView, 10);
7075
7077
  let prependedDataLength = 0;
7078
+ let prependedCentralDirectory;
7076
7079
  let startOffset;
7077
7080
  let zip64EndOfDirectory;
7078
7081
  let zip64EndOfDirectoryVersion2;
@@ -7170,6 +7173,7 @@ var init_zip_reader = __esm({
7170
7173
  directoryDataOffset = expectedDirectoryDataOffset;
7171
7174
  if (directoryDataOffset > originalDirectoryDataOffset) {
7172
7175
  prependedDataLength += directoryDataOffset - originalDirectoryDataOffset;
7176
+ prependedCentralDirectory = storedPointsAtDirectory;
7173
7177
  }
7174
7178
  directoryArray = await readUint8Array(reader, directoryDataOffset, directoryDataLength);
7175
7179
  directoryView = getDataView(directoryArray);
@@ -7389,6 +7393,9 @@ var init_zip_reader = __esm({
7389
7393
  if (prependedDataLength || filesLength && startOffset > SPLIT_ZIP_FILE_SIGNATURE_LENGTH) {
7390
7394
  addWarning(warnings, WARNING_PREPENDED_DATA);
7391
7395
  }
7396
+ if (prependedCentralDirectory) {
7397
+ addWarning(warnings, WARNING_PREPENDED_CENTRAL_DIRECTORY);
7398
+ }
7392
7399
  if (extractPrependedData) {
7393
7400
  zipReader.prependedData = startOffset > splitZipSignatureLength ? await readUint8Array(reader, splitZipSignatureLength, startOffset - splitZipSignatureLength) : EMPTY_UINT8_ARRAY;
7394
7401
  }
@@ -10887,8 +10894,8 @@ var require_utils = __commonJS({
10887
10894
  }
10888
10895
  return ind;
10889
10896
  }
10890
- function removeDotSegments(path22) {
10891
- let input = path22;
10897
+ function removeDotSegments(path23) {
10898
+ let input = path23;
10892
10899
  const output = [];
10893
10900
  let nextSlash = -1;
10894
10901
  let len = 0;
@@ -11293,8 +11300,8 @@ var require_schemes = __commonJS({
11293
11300
  }
11294
11301
  if (wsComponent.resourceName) {
11295
11302
  const queryIndex = wsComponent.resourceName.indexOf("?");
11296
- const path22 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
11297
- wsComponent.path = path22 && path22 !== "/" ? path22 : void 0;
11303
+ const path23 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
11304
+ wsComponent.path = path23 && path23 !== "/" ? path23 : void 0;
11298
11305
  wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
11299
11306
  wsComponent.resourceName = void 0;
11300
11307
  }
@@ -16075,6 +16082,9 @@ var ERROR_CATALOG = {
16075
16082
  BUILD_ARCHIVE_FAILED: { retryable: true, exitCode: 1 },
16076
16083
  // snapshot
16077
16084
  SNAPSHOT_FAILED: { retryable: true, exitCode: 1 },
16085
+ // unzip
16086
+ UNZIP_INPUT_INVALID: { retryable: false, exitCode: 1 },
16087
+ UNZIP_FAILED: { retryable: true, exitCode: 1 },
16078
16088
  // platform-sdk
16079
16089
  PLATFORM_SDK_MANIFEST_INVALID: { retryable: false, exitCode: 1 },
16080
16090
  PLATFORM_SDK_ARCHIVE_INVALID: { retryable: false, exitCode: 1 },
@@ -19553,7 +19563,16 @@ var CLIENT_CAPABILITY_TABLE_ID = "linkque_client_cap_invocations";
19553
19563
  var A2UI_ACTION_DATABASE_ID = "linkque";
19554
19564
  var A2UI_ACTION_TABLE_ID = "linkque_a2ui_action_invocations";
19555
19565
  var A2UI_ACTION_TABLE_COLUMNS = [
19556
- ...["ownerId", "agentId", "threadId", "actionId", "cardRef", "cardRevision", "surfaceId", "componentId"].map((key) => ({
19566
+ ...[
19567
+ "ownerId",
19568
+ "agentId",
19569
+ "threadId",
19570
+ "actionId",
19571
+ "cardRef",
19572
+ "cardRevision",
19573
+ "surfaceId",
19574
+ "componentId"
19575
+ ].map((key) => ({
19557
19576
  key,
19558
19577
  type: "varchar",
19559
19578
  required: true,
@@ -19561,17 +19580,78 @@ var A2UI_ACTION_TABLE_COLUMNS = [
19561
19580
  size: 128,
19562
19581
  default: null
19563
19582
  })),
19564
- { key: "cardInstanceId", type: "varchar", required: true, array: false, size: 256, default: null },
19565
- { key: "status", type: "varchar", required: true, array: false, size: 32, default: null },
19566
- { key: "actionContext", type: "text", required: true, array: false, size: 0, default: null },
19567
- { key: "tradeNO", type: "varchar", required: false, array: false, size: 64, default: null },
19568
- { key: "callback", type: "text", required: false, array: false, size: 0, default: null },
19569
- { key: "verification", type: "text", required: false, array: false, size: 0, default: null },
19570
- { key: "createdAt", type: "varchar", required: true, array: false, size: 32, default: null },
19571
- { key: "expiresAt", type: "varchar", required: true, array: false, size: 32, default: null }
19583
+ {
19584
+ key: "cardInstanceId",
19585
+ type: "varchar",
19586
+ required: true,
19587
+ array: false,
19588
+ size: 256,
19589
+ default: null
19590
+ },
19591
+ {
19592
+ key: "status",
19593
+ type: "varchar",
19594
+ required: true,
19595
+ array: false,
19596
+ size: 32,
19597
+ default: null
19598
+ },
19599
+ {
19600
+ key: "actionContext",
19601
+ type: "text",
19602
+ required: true,
19603
+ array: false,
19604
+ size: 0,
19605
+ default: null
19606
+ },
19607
+ {
19608
+ key: "tradeNO",
19609
+ type: "varchar",
19610
+ required: false,
19611
+ array: false,
19612
+ size: 64,
19613
+ default: null
19614
+ },
19615
+ {
19616
+ key: "callback",
19617
+ type: "text",
19618
+ required: false,
19619
+ array: false,
19620
+ size: 0,
19621
+ default: null
19622
+ },
19623
+ {
19624
+ key: "verification",
19625
+ type: "text",
19626
+ required: false,
19627
+ array: false,
19628
+ size: 0,
19629
+ default: null
19630
+ },
19631
+ {
19632
+ key: "createdAt",
19633
+ type: "varchar",
19634
+ required: true,
19635
+ array: false,
19636
+ size: 32,
19637
+ default: null
19638
+ },
19639
+ {
19640
+ key: "expiresAt",
19641
+ type: "varchar",
19642
+ required: true,
19643
+ array: false,
19644
+ size: 32,
19645
+ default: null
19646
+ }
19572
19647
  ];
19573
19648
  var A2UI_ACTION_TABLE_INDEXES = [
19574
- { key: "thread_status", type: "key", columns: ["threadId", "status"], orders: ["asc", "asc"] },
19649
+ {
19650
+ key: "thread_status",
19651
+ type: "key",
19652
+ columns: ["threadId", "status"],
19653
+ orders: ["asc", "asc"]
19654
+ },
19575
19655
  { key: "expires_at", type: "key", columns: ["expiresAt"], orders: ["asc"] }
19576
19656
  ];
19577
19657
  var CLIENT_CAPABILITY_TABLE_COLUMNS = [
@@ -19952,6 +20032,15 @@ var RUN_INDEX_TABLE_COLUMNS = [
19952
20032
  size: 0,
19953
20033
  default: null
19954
20034
  },
20035
+ {
20036
+ // 首次已读时间;datetime 使用 ISO 8601,optional + null 兼容补列前的历史 run。
20037
+ key: "readAt",
20038
+ type: "datetime",
20039
+ required: false,
20040
+ array: false,
20041
+ size: 0,
20042
+ default: null
20043
+ },
19955
20044
  {
19956
20045
  key: "followUpQuestionsJson",
19957
20046
  type: "text",
@@ -21489,8 +21578,8 @@ var stopAgentServer = async (cwd) => {
21489
21578
  };
21490
21579
 
21491
21580
  // src/commands/build/dist.ts
21492
- var import_crypto6 = require("crypto");
21493
- var import_promises14 = require("fs/promises");
21581
+ var import_crypto7 = require("crypto");
21582
+ var import_promises13 = require("fs/promises");
21494
21583
  var import_path20 = __toESM(require("path"));
21495
21584
 
21496
21585
  // src/utils/spawn.ts
@@ -21894,12 +21983,11 @@ var inspectWorkspaceStatus = async (cwd) => {
21894
21983
  };
21895
21984
 
21896
21985
  // src/commands/build/archive.ts
21897
- var import_crypto5 = require("crypto");
21986
+ var import_crypto6 = require("crypto");
21898
21987
  var import_promises11 = require("fs/promises");
21899
- var import_promises12 = require("fs/promises");
21900
21988
  var import_path19 = __toESM(require("path"));
21901
21989
  var import_stream = require("stream");
21902
- var import_promises13 = require("stream/promises");
21990
+ var import_promises12 = require("stream/promises");
21903
21991
 
21904
21992
  // ../../node_modules/@zip.js/zip.js/lib/zip-fs-wasm.js
21905
21993
  init_configuration();
@@ -22635,6 +22723,13 @@ async function addFile(zipWriter, name, reader, options) {
22635
22723
  const { comment } = metadataInfo;
22636
22724
  const extraField = options[PROPERTY_NAME_EXTRA_FIELD];
22637
22725
  zipWriter.fileEntries.set(name, UNDEFINED_VALUE);
22726
+ const previousFileEntry = zipWriter.lastFileEntry;
22727
+ const pendingFileEntry = {};
22728
+ let releaseLockFileEntry;
22729
+ if (metadataInfo.resolvedOptions.keepOrder) {
22730
+ pendingFileEntry.lockFileEntry = new Promise((resolve2) => releaseLockFileEntry = resolve2);
22731
+ }
22732
+ zipWriter.lastFileEntry = pendingFileEntry;
22638
22733
  let fileEntry;
22639
22734
  try {
22640
22735
  const { resolvedOptions } = metadataInfo;
@@ -22655,10 +22750,21 @@ async function addFile(zipWriter, name, reader, options) {
22655
22750
  const headerInfo = getHeaderInfo(options);
22656
22751
  const dataDescriptorInfo = getDataDescriptorInfo(options);
22657
22752
  const metadataSize = getLength(headerInfo.localHeaderArray, dataDescriptorInfo.dataDescriptorArray);
22658
- fileEntry = await getFileEntry(zipWriter, name, reader, { headerInfo, dataDescriptorInfo, metadataSize }, options);
22753
+ fileEntry = await getFileEntry(zipWriter, name, reader, {
22754
+ headerInfo,
22755
+ dataDescriptorInfo,
22756
+ metadataSize,
22757
+ fileEntry: pendingFileEntry,
22758
+ previousFileEntry,
22759
+ releaseLockFileEntry
22760
+ }, options);
22659
22761
  } catch (error) {
22660
22762
  zipWriter.fileEntries.delete(name);
22661
22763
  throw error;
22764
+ } finally {
22765
+ if (releaseLockFileEntry) {
22766
+ releaseLockFileEntry(previousFileEntry && previousFileEntry.lockFileEntry);
22767
+ }
22662
22768
  }
22663
22769
  Object.assign(fileEntry, {
22664
22770
  name,
@@ -23035,27 +23141,23 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
23035
23141
  signal
23036
23142
  } = options;
23037
23143
  const {
23038
- headerInfo
23144
+ headerInfo,
23145
+ fileEntry: pendingFileEntry,
23146
+ previousFileEntry,
23147
+ releaseLockFileEntry
23039
23148
  } = entryInfo;
23040
23149
  const usdz = zipWriter.options[OPTION_USDZ];
23041
- const previousFileEntry = zipWriter.lastFileEntry;
23042
- let fileEntry = {};
23150
+ let fileEntry = pendingFileEntry;
23043
23151
  let bufferedWrite;
23044
23152
  let releaseLockWriter;
23045
- let releaseLockCurrentFileEntry;
23046
23153
  let writingBufferedEntryData;
23047
23154
  let writingEntryData;
23048
23155
  let writerSizeBeforeEntry;
23049
23156
  let flushedBufferedSize = 0;
23050
23157
  let fileWriter;
23158
+ const lockPreviousFileEntry = keepOrder && previousFileEntry ? previousFileEntry.lockFileEntry : UNDEFINED_VALUE;
23051
23159
  fileEntries.set(name, fileEntry);
23052
- zipWriter.lastFileEntry = fileEntry;
23053
23160
  try {
23054
- let lockPreviousFileEntry;
23055
- if (keepOrder) {
23056
- lockPreviousFileEntry = previousFileEntry && previousFileEntry.lockFileEntry;
23057
- requestLockCurrentFileEntry();
23058
- }
23059
23161
  if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || !dataDescriptor && !emptyEntry) {
23060
23162
  bufferedWrite = true;
23061
23163
  zipWriter.bufferedWrites++;
@@ -23068,6 +23170,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
23068
23170
  await initStream(writer);
23069
23171
  } else {
23070
23172
  fileWriter = writer;
23173
+ await lockPreviousFileEntry;
23071
23174
  await requestLockWriter();
23072
23175
  }
23073
23176
  await initStream(fileWriter);
@@ -23080,7 +23183,6 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
23080
23183
  }
23081
23184
  const { localHeaderArray } = headerInfo;
23082
23185
  if (!bufferedWrite) {
23083
- await lockPreviousFileEntry;
23084
23186
  await skipDiskIfNeeded();
23085
23187
  }
23086
23188
  const diskNumberStart = getDiskNumber(writer);
@@ -23144,8 +23246,8 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
23144
23246
  if (bufferedWrite) {
23145
23247
  zipWriter.bufferedWrites--;
23146
23248
  }
23147
- if (releaseLockCurrentFileEntry) {
23148
- releaseLockCurrentFileEntry();
23249
+ if (releaseLockFileEntry) {
23250
+ releaseLockFileEntry(lockPreviousFileEntry);
23149
23251
  }
23150
23252
  if (releaseLockWriter) {
23151
23253
  releaseLockWriter();
@@ -23157,9 +23259,6 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
23157
23259
  }
23158
23260
  }
23159
23261
  }
23160
- function requestLockCurrentFileEntry() {
23161
- fileEntry.lockFileEntry = new Promise((resolve2) => releaseLockCurrentFileEntry = resolve2);
23162
- }
23163
23262
  async function requestLockWriter() {
23164
23263
  zipWriter.writerLocked = true;
23165
23264
  const { lockWriter } = zipWriter;
@@ -24738,13 +24837,35 @@ init_compatible_streams();
24738
24837
  // ../../node_modules/@zip.js/zip.js/lib/zip-fs-wasm.js
24739
24838
  n(setDefaultConfiguration);
24740
24839
 
24840
+ // src/commands/sourceChecksum.ts
24841
+ var import_crypto5 = require("crypto");
24842
+ var SourceChecksumWriter = class {
24843
+ hash = (0, import_crypto5.createHash)("sha256");
24844
+ bytes = 0;
24845
+ appendFileHeader(filename, contentLength) {
24846
+ const pathBytes = Buffer.from(filename, "utf8");
24847
+ const lengths = Buffer.allocUnsafe(12);
24848
+ lengths.writeUInt32BE(pathBytes.byteLength, 0);
24849
+ lengths.writeBigUInt64BE(BigInt(contentLength), 4);
24850
+ this.hash.update(lengths);
24851
+ this.hash.update(pathBytes);
24852
+ }
24853
+ appendFileContent(content) {
24854
+ this.hash.update(content);
24855
+ this.bytes += content.byteLength;
24856
+ }
24857
+ digest() {
24858
+ return { checksum: this.hash.digest("hex"), bytes: this.bytes };
24859
+ }
24860
+ };
24861
+
24741
24862
  // src/commands/build/archive.ts
24742
24863
  var compareArchivePath = (left, right) => left < right ? -1 : left > right ? 1 : 0;
24743
24864
  var walkFiles = async (root, exclude = /* @__PURE__ */ new Set()) => {
24744
24865
  const visit = async (current) => {
24745
24866
  let entries;
24746
24867
  try {
24747
- entries = await (0, import_promises12.readdir)(current, { withFileTypes: true });
24868
+ entries = await (0, import_promises11.readdir)(current, { withFileTypes: true });
24748
24869
  } catch (error) {
24749
24870
  if (isNodeError(error, "ENOENT")) return [];
24750
24871
  throw error;
@@ -24773,11 +24894,11 @@ var HashingArchiveWriter = class extends import_stream.Writable {
24773
24894
  super();
24774
24895
  this.archivePath = archivePath;
24775
24896
  }
24776
- hash = (0, import_crypto5.createHash)("sha256");
24897
+ hash = (0, import_crypto6.createHash)("sha256");
24777
24898
  handle;
24778
24899
  size = 0;
24779
24900
  async initialize() {
24780
- this.handle = await (0, import_promises12.open)(this.archivePath, "wx");
24901
+ this.handle = await (0, import_promises11.open)(this.archivePath, "wx");
24781
24902
  }
24782
24903
  identity() {
24783
24904
  return { sha256: this.hash.digest("hex"), size: this.size };
@@ -24818,18 +24939,11 @@ var writeArchive = async (files, tempPath, options = {}, frozenContents = /* @__
24818
24939
  import_stream.Writable.toWeb(output),
24819
24940
  { useWebWorkers: false }
24820
24941
  );
24821
- const sourceHash = (0, import_crypto5.createHash)("sha256");
24822
- let sourceBytes = 0;
24942
+ const sourceChecksum = new SourceChecksumWriter();
24823
24943
  const zipOptions = options.lastModDate ? { extendedTimestamp: false, lastModDate: options.lastModDate } : void 0;
24824
24944
  const appendFile = async (archivePath, content) => {
24825
- const pathBytes = Buffer.from(archivePath, "utf8");
24826
- const lengths = Buffer.allocUnsafe(12);
24827
- lengths.writeUInt32BE(pathBytes.byteLength, 0);
24828
- lengths.writeBigUInt64BE(BigInt(content.byteLength), 4);
24829
- sourceHash.update(lengths);
24830
- sourceHash.update(pathBytes);
24831
- sourceHash.update(content);
24832
- sourceBytes += content.byteLength;
24945
+ sourceChecksum.appendFileHeader(archivePath, content.byteLength);
24946
+ sourceChecksum.appendFileContent(content);
24833
24947
  const bytes = new Uint8Array(
24834
24948
  content.buffer,
24835
24949
  content.byteOffset,
@@ -24851,15 +24965,16 @@ var writeArchive = async (files, tempPath, options = {}, frozenContents = /* @__
24851
24965
  }
24852
24966
  await zip.close();
24853
24967
  const identity = output.identity();
24968
+ const sourceIdentity = sourceChecksum.digest();
24854
24969
  return {
24855
24970
  sha256: identity.sha256,
24856
24971
  size: identity.size,
24857
- sourceChecksum: sourceHash.digest("hex"),
24858
- sourceBytes
24972
+ sourceChecksum: sourceIdentity.checksum,
24973
+ sourceBytes: sourceIdentity.bytes
24859
24974
  };
24860
24975
  } catch (error) {
24861
24976
  output.destroy();
24862
- await (0, import_promises13.finished)(output).catch(() => void 0);
24977
+ await (0, import_promises12.finished)(output).catch(() => void 0);
24863
24978
  if (error instanceof LinkqueCliError) throw error;
24864
24979
  throw new LinkqueCliError(
24865
24980
  "BUILD_ARCHIVE_FAILED",
@@ -24889,7 +25004,7 @@ var runBuild = async (cwd) => {
24889
25004
  };
24890
25005
  var assertBuildCommand = async (cwd) => {
24891
25006
  const packageJson = parseJsonObject(
24892
- await (0, import_promises14.readFile)(import_path20.default.join(cwd, "package.json"), "utf8").catch((error) => {
25007
+ await (0, import_promises13.readFile)(import_path20.default.join(cwd, "package.json"), "utf8").catch((error) => {
24893
25008
  throw new LinkqueCliError(
24894
25009
  "BUILD_COMMAND_NOT_FOUND",
24895
25010
  "workspace package.json must contain a build script",
@@ -24921,8 +25036,8 @@ var assertBuildOutput = (files) => {
24921
25036
  var buildDistWhileLocked = async (cwd) => {
24922
25037
  const outputPath = import_path20.default.join(cwd, OUTPUT_DIR);
24923
25038
  const finalPath = import_path20.default.join(cwd, ARCHIVE_PATH);
24924
- const tempPath = `${finalPath}.${process.pid}.${(0, import_crypto6.randomUUID)()}.tmp`;
24925
- await (0, import_promises14.rm)(finalPath, { force: true }).catch((error) => {
25039
+ const tempPath = `${finalPath}.${process.pid}.${(0, import_crypto7.randomUUID)()}.tmp`;
25040
+ await (0, import_promises13.rm)(finalPath, { force: true }).catch((error) => {
24926
25041
  throw new LinkqueCliError(
24927
25042
  "BUILD_ARCHIVE_FAILED",
24928
25043
  "stale build archive could not be removed",
@@ -24947,7 +25062,7 @@ var buildDistWhileLocked = async (cwd) => {
24947
25062
  );
24948
25063
  }
24949
25064
  await assertBuildCommand(cwd);
24950
- await (0, import_promises14.rm)(outputPath, { force: true, recursive: true }).catch(
25065
+ await (0, import_promises13.rm)(outputPath, { force: true, recursive: true }).catch(
24951
25066
  (error) => {
24952
25067
  throw new LinkqueCliError(
24953
25068
  "BUILD_FAILED",
@@ -24982,7 +25097,7 @@ var buildDistWhileLocked = async (cwd) => {
24982
25097
  );
24983
25098
  }
24984
25099
  );
24985
- await (0, import_promises14.rename)(tempPath, finalPath).catch((error) => {
25100
+ await (0, import_promises13.rename)(tempPath, finalPath).catch((error) => {
24986
25101
  throw new LinkqueCliError(
24987
25102
  "BUILD_ARCHIVE_FAILED",
24988
25103
  "build archive could not be finalized",
@@ -24999,8 +25114,8 @@ var buildDistWhileLocked = async (cwd) => {
24999
25114
  } catch (error) {
25000
25115
  try {
25001
25116
  await Promise.all([
25002
- (0, import_promises14.rm)(finalPath, { force: true }),
25003
- (0, import_promises14.rm)(tempPath, { force: true })
25117
+ (0, import_promises13.rm)(finalPath, { force: true }),
25118
+ (0, import_promises13.rm)(tempPath, { force: true })
25004
25119
  ]);
25005
25120
  } catch (cleanupError) {
25006
25121
  throw preservePrimaryFailure(error, cleanupError);
@@ -25016,14 +25131,14 @@ var buildDist = async (cwd) => withWorkspaceLock(
25016
25131
  releaseErrorCode: "BUILD_ARCHIVE_FAILED",
25017
25132
  retryMs: LOCK_RETRY_MS3,
25018
25133
  timeoutMs: LOCK_TIMEOUT_MS4,
25019
- onReleaseFailure: () => (0, import_promises14.rm)(import_path20.default.join(cwd, ARCHIVE_PATH), { force: true })
25134
+ onReleaseFailure: () => (0, import_promises13.rm)(import_path20.default.join(cwd, ARCHIVE_PATH), { force: true })
25020
25135
  },
25021
25136
  () => buildDistWhileLocked(cwd)
25022
25137
  );
25023
25138
 
25024
25139
  // src/commands/build/snapshot.ts
25025
- var import_crypto7 = require("crypto");
25026
- var import_promises15 = require("fs/promises");
25140
+ var import_crypto8 = require("crypto");
25141
+ var import_promises14 = require("fs/promises");
25027
25142
  var import_path21 = __toESM(require("path"));
25028
25143
  var ARTIFACTS_DIR = ".linkque/artifacts";
25029
25144
  var AGENT_CONFIG_SOURCE_PATH = "agent_config.json";
@@ -25044,7 +25159,7 @@ var snapshotFailure = (message, cause) => cause instanceof LinkqueCliError ? cau
25044
25159
  var readTemplateVersion = async (cwd) => {
25045
25160
  let content;
25046
25161
  try {
25047
- content = await (0, import_promises15.readFile)(
25162
+ content = await (0, import_promises14.readFile)(
25048
25163
  import_path21.default.join(cwd, TEMPLATE_ARTIFACT_SOURCE_PATH),
25049
25164
  "utf8"
25050
25165
  );
@@ -25064,25 +25179,16 @@ var readTemplateVersion = async (cwd) => {
25064
25179
  }
25065
25180
  };
25066
25181
  var buildSnapshotWhileLocked = async (cwd, options) => {
25067
- const snapshotDir = `snapshot-${(0, import_crypto7.randomUUID)()}`;
25182
+ const snapshotDir = `snapshot-${(0, import_crypto8.randomUUID)()}`;
25068
25183
  const relDir = import_path21.default.join(ARTIFACTS_DIR, snapshotDir);
25069
25184
  const dirPath = import_path21.default.join(cwd, relDir);
25070
25185
  const archiveRel = import_path21.default.join(relDir, "source.zip");
25071
25186
  const finalPath = import_path21.default.join(cwd, archiveRel);
25072
25187
  const tempPath = `${finalPath}.${process.pid}.tmp`;
25073
- await (0, import_promises15.rm)(dirPath, { force: true, recursive: true }).catch(
25074
- (error) => {
25075
- throw new LinkqueCliError(
25076
- "SNAPSHOT_FAILED",
25077
- "stale snapshot directory could not be removed",
25078
- { cause: error }
25079
- );
25080
- }
25081
- );
25082
25188
  try {
25083
25189
  let rootStat;
25084
25190
  try {
25085
- rootStat = await (0, import_promises15.lstat)(cwd, { bigint: true });
25191
+ rootStat = await (0, import_promises14.lstat)(cwd, { bigint: true });
25086
25192
  } catch (error) {
25087
25193
  throw snapshotFailure("workspace source could not be inspected", error);
25088
25194
  }
@@ -25099,7 +25205,7 @@ var buildSnapshotWhileLocked = async (cwd, options) => {
25099
25205
  throw snapshotFailure("workspace source could not be inspected", error);
25100
25206
  }
25101
25207
  );
25102
- const agentConfigContent = await (0, import_promises15.readFile)(
25208
+ const agentConfigContent = await (0, import_promises14.readFile)(
25103
25209
  import_path21.default.join(cwd, AGENT_CONFIG_SOURCE_PATH)
25104
25210
  ).catch((error) => {
25105
25211
  if (isNodeError(error, "ENOENT")) {
@@ -25133,7 +25239,7 @@ var buildSnapshotWhileLocked = async (cwd, options) => {
25133
25239
  error
25134
25240
  );
25135
25241
  });
25136
- await (0, import_promises15.rename)(tempPath, finalPath).catch((error) => {
25242
+ await (0, import_promises14.rename)(tempPath, finalPath).catch((error) => {
25137
25243
  throw new LinkqueCliError(
25138
25244
  "SNAPSHOT_FAILED",
25139
25245
  "source archive could not be finalized",
@@ -25152,8 +25258,7 @@ var buildSnapshotWhileLocked = async (cwd, options) => {
25152
25258
  };
25153
25259
  } catch (error) {
25154
25260
  try {
25155
- await (0, import_promises15.rm)(dirPath, { force: true, recursive: true });
25156
- await (0, import_promises15.rm)(tempPath, { force: true });
25261
+ await (0, import_promises14.rm)(dirPath, { force: true, recursive: true });
25157
25262
  } catch (cleanupError) {
25158
25263
  throw preservePrimaryFailure(error, cleanupError);
25159
25264
  }
@@ -25168,16 +25273,14 @@ var buildSnapshot = async (cwd, options = {}) => withWorkspaceLock(
25168
25273
  releaseErrorCode: "SNAPSHOT_FAILED",
25169
25274
  retryMs: LOCK_RETRY_MS4,
25170
25275
  timeoutMs: LOCK_TIMEOUT_MS5
25171
- // 产物在唯一目录 snapshot-<uuid>/ 下,release 失败不污染下次(下次用新 uuid);
25172
- // 本次 snapshot 若已写完产物,release 失败不应删它。残留目录由 manager 读后清理
25173
- // 或 best-effort 泄漏,不在此处理。
25276
+ // 本次 snapshot 若已写完产物,release 失败不应删它;下次用新 uuid,不污染后续 snapshot。
25174
25277
  },
25175
25278
  () => buildSnapshotWhileLocked(cwd, options)
25176
25279
  );
25177
25280
 
25178
25281
  // src/commands/card/index.ts
25179
- var import_crypto8 = require("crypto");
25180
- var import_promises16 = require("fs/promises");
25282
+ var import_crypto9 = require("crypto");
25283
+ var import_promises15 = require("fs/promises");
25181
25284
  var import_path22 = __toESM(require("path"));
25182
25285
 
25183
25286
  // ../agent-a2ui-card-contract/dist/esm/types.js
@@ -25278,10 +25381,10 @@ function canonicalizeBindingPath(rawPath, listRoot) {
25278
25381
  }
25279
25382
  return isSafeJsonPointer(candidate, true) ? candidate : void 0;
25280
25383
  }
25281
- function issue2(path22, code, message) {
25282
- return { path: path22, code, message };
25384
+ function issue2(path23, code, message) {
25385
+ return { path: path23, code, message };
25283
25386
  }
25284
- function exactKeys(value, allowed, path22, issues) {
25387
+ function exactKeys(value, allowed, path23, issues) {
25285
25388
  }
25286
25389
 
25287
25390
  // ../agent-a2ui-card-contract/dist/esm/binding-analyzer.js
@@ -25505,9 +25608,9 @@ var SCHEMA_TYPES = /* @__PURE__ */ new Set([
25505
25608
  "object",
25506
25609
  "string"
25507
25610
  ]);
25508
- function getJsonSchemaIssues(value, path22 = "schema", options = {}) {
25611
+ function getJsonSchemaIssues(value, path23 = "schema", options = {}) {
25509
25612
  const issues = [];
25510
- validateSchemaNode(value, path22, issues, options);
25613
+ validateSchemaNode(value, path23, issues, options);
25511
25614
  return issues;
25512
25615
  }
25513
25616
  var OPAQUE_OBJECT_SCHEMA = {
@@ -25529,9 +25632,9 @@ function normalizeTargetJsonSchema(schema) {
25529
25632
  normalizeObjectDefaults(cloned);
25530
25633
  return cloned;
25531
25634
  }
25532
- function validateJsonSchemaValue2(schema, value, path22 = "$") {
25635
+ function validateJsonSchemaValue2(schema, value, path23 = "$") {
25533
25636
  const issues = [];
25534
- validateValue(schema, value, path22, issues);
25637
+ validateValue(schema, value, path23, issues);
25535
25638
  return issues;
25536
25639
  }
25537
25640
  function generateJsonSchemaSample(schema) {
@@ -25608,9 +25711,9 @@ function getJsonSchemaAtDataPointer(schema, pointer) {
25608
25711
  return schema;
25609
25712
  return getJsonSchemaAtPath(schema, pointer.slice(1).split("/").map(decodePointerSegment));
25610
25713
  }
25611
- function getJsonSchemaAtPath(schema, path22) {
25714
+ function getJsonSchemaAtPath(schema, path23) {
25612
25715
  let current = schema;
25613
- for (const segment of path22) {
25716
+ for (const segment of path23) {
25614
25717
  if (!current)
25615
25718
  return void 0;
25616
25719
  if (segment === "*" || current.type === "array") {
@@ -25628,56 +25731,56 @@ function getJsonSchemaAtPath(schema, path22) {
25628
25731
  }
25629
25732
  return current;
25630
25733
  }
25631
- function getJsonSchemaCompatibilityIssues(source, target, path22 = "$") {
25734
+ function getJsonSchemaCompatibilityIssues(source, target, path23 = "$") {
25632
25735
  const issues = [];
25633
- compareSchemas(source, target, path22, issues);
25736
+ compareSchemas(source, target, path23, issues);
25634
25737
  return issues;
25635
25738
  }
25636
25739
  function areJsonSchemaTypesCompatible(sourceType, targetType) {
25637
25740
  return sourceType === targetType || sourceType === "integer" && targetType === "number";
25638
25741
  }
25639
- function validateSchemaNode(value, path22, issues, options) {
25742
+ function validateSchemaNode(value, path23, issues, options) {
25640
25743
  if (!isPlainRecord(value) || !isJsonValue(value)) {
25641
- issues.push(issue2(path22, "INVALID_JSON_SCHEMA", `${path22} must be a JSON object`));
25744
+ issues.push(issue2(path23, "INVALID_JSON_SCHEMA", `${path23} must be a JSON object`));
25642
25745
  return false;
25643
25746
  }
25644
25747
  if (value.type === void 0 && options.allowMissingType) {
25645
25748
  return true;
25646
25749
  }
25647
25750
  if (typeof value.type !== "string" || !SCHEMA_TYPES.has(value.type)) {
25648
- issues.push(issue2(`${path22}.type`, "INVALID_JSON_SCHEMA_TYPE", `${path22}.type must be a supported scalar, object or array type`));
25751
+ issues.push(issue2(`${path23}.type`, "INVALID_JSON_SCHEMA_TYPE", `${path23}.type must be a supported scalar, object or array type`));
25649
25752
  return false;
25650
25753
  }
25651
25754
  if (value.required !== void 0 && (!Array.isArray(value.required) || value.required.some((entry) => typeof entry !== "string"))) {
25652
- issues.push(issue2(`${path22}.required`, "INVALID_JSON_SCHEMA_REQUIRED", `${path22}.required must be a string array`));
25755
+ issues.push(issue2(`${path23}.required`, "INVALID_JSON_SCHEMA_REQUIRED", `${path23}.required must be a string array`));
25653
25756
  }
25654
25757
  if (value.type === "object") {
25655
25758
  if (!isPlainRecord(value.properties)) {
25656
25759
  if (options.requireCompleteStructures) {
25657
- issues.push(issue2(`${path22}.properties`, "INCOMPLETE_OBJECT_SCHEMA", "object schemas must declare properties"));
25760
+ issues.push(issue2(`${path23}.properties`, "INCOMPLETE_OBJECT_SCHEMA", "object schemas must declare properties"));
25658
25761
  }
25659
25762
  } else {
25660
25763
  for (const [name, child] of Object.entries(value.properties)) {
25661
- validateSchemaNode(child, `${path22}.properties.${name}`, issues, options);
25764
+ validateSchemaNode(child, `${path23}.properties.${name}`, issues, options);
25662
25765
  }
25663
25766
  const required = Array.isArray(value.required) ? value.required.filter((entry) => typeof entry === "string") : [];
25664
25767
  for (const name of required) {
25665
25768
  if (!(name in value.properties)) {
25666
- issues.push(issue2(`${path22}.required`, "UNKNOWN_REQUIRED_PROPERTY", `required property ${name} is not declared`));
25769
+ issues.push(issue2(`${path23}.required`, "UNKNOWN_REQUIRED_PROPERTY", `required property ${name} is not declared`));
25667
25770
  }
25668
25771
  }
25669
25772
  }
25670
25773
  if (value.additionalProperties !== void 0 && typeof value.additionalProperties !== "boolean" && !isPlainRecord(value.additionalProperties)) {
25671
- issues.push(issue2(`${path22}.additionalProperties`, "INVALID_ADDITIONAL_PROPERTIES", "additionalProperties must be a boolean or schema"));
25774
+ issues.push(issue2(`${path23}.additionalProperties`, "INVALID_ADDITIONAL_PROPERTIES", "additionalProperties must be a boolean or schema"));
25672
25775
  }
25673
25776
  }
25674
25777
  if (value.type === "array") {
25675
25778
  if (!isPlainRecord(value.items)) {
25676
25779
  if (options.requireCompleteStructures) {
25677
- issues.push(issue2(`${path22}.items`, "INCOMPLETE_ARRAY_SCHEMA", "array schemas must declare items"));
25780
+ issues.push(issue2(`${path23}.items`, "INCOMPLETE_ARRAY_SCHEMA", "array schemas must declare items"));
25678
25781
  }
25679
25782
  } else {
25680
- validateSchemaNode(value.items, `${path22}.items`, issues, options);
25783
+ validateSchemaNode(value.items, `${path23}.items`, issues, options);
25681
25784
  }
25682
25785
  }
25683
25786
  return true;
@@ -25697,53 +25800,53 @@ function normalizeObjectDefaults(schema) {
25697
25800
  normalizeObjectDefaults(schema.items);
25698
25801
  }
25699
25802
  }
25700
- function validateValue(schema, value, path22, issues) {
25803
+ function validateValue(schema, value, path23, issues) {
25701
25804
  if (typeof schema.type === "string" && !matchesType(schema.type, value)) {
25702
- issues.push(issue2(path22, "SCHEMA_TYPE_MISMATCH", `expected ${schema.type}, received ${valueType(value)}`));
25805
+ issues.push(issue2(path23, "SCHEMA_TYPE_MISMATCH", `expected ${schema.type}, received ${valueType(value)}`));
25703
25806
  return;
25704
25807
  }
25705
25808
  if (Array.isArray(schema.enum) && !schema.enum.some((entry) => Object.is(entry, value))) {
25706
- issues.push(issue2(path22, "SCHEMA_ENUM_MISMATCH", "value is not in the declared enum"));
25809
+ issues.push(issue2(path23, "SCHEMA_ENUM_MISMATCH", "value is not in the declared enum"));
25707
25810
  return;
25708
25811
  }
25709
25812
  if (schema.const !== void 0 && !Object.is(schema.const, value)) {
25710
- issues.push(issue2(path22, "SCHEMA_CONST_MISMATCH", "value does not match const"));
25813
+ issues.push(issue2(path23, "SCHEMA_CONST_MISMATCH", "value does not match const"));
25711
25814
  return;
25712
25815
  }
25713
25816
  if (schema.type === "object" && isPlainRecord(value)) {
25714
25817
  const required = Array.isArray(schema.required) ? schema.required.filter((entry) => typeof entry === "string") : [];
25715
25818
  for (const key of required) {
25716
25819
  if (!(key in value)) {
25717
- issues.push(issue2(`${path22}/${key}`, "SCHEMA_REQUIRED_MISSING", `required property ${key} is missing`));
25820
+ issues.push(issue2(`${path23}/${key}`, "SCHEMA_REQUIRED_MISSING", `required property ${key} is missing`));
25718
25821
  }
25719
25822
  }
25720
25823
  const properties = isPlainRecord(schema.properties) ? schema.properties : {};
25721
25824
  for (const [key, childSchema] of Object.entries(properties)) {
25722
25825
  if (!(key in value) || !isPlainRecord(childSchema))
25723
25826
  continue;
25724
- validateValue(childSchema, value[key], `${path22}/${key}`, issues);
25827
+ validateValue(childSchema, value[key], `${path23}/${key}`, issues);
25725
25828
  }
25726
25829
  if (schema.additionalProperties === false) {
25727
25830
  for (const key of Object.keys(value)) {
25728
25831
  if (!(key in properties)) {
25729
- issues.push(issue2(`${path22}/${key}`, "SCHEMA_ADDITIONAL_PROPERTY", `property ${key} is not allowed`));
25832
+ issues.push(issue2(`${path23}/${key}`, "SCHEMA_ADDITIONAL_PROPERTY", `property ${key} is not allowed`));
25730
25833
  }
25731
25834
  }
25732
25835
  }
25733
25836
  }
25734
25837
  if (schema.type === "array" && Array.isArray(value) && isPlainRecord(schema.items)) {
25735
25838
  value.forEach((entry, index) => {
25736
- validateValue(schema.items, entry, `${path22}/${index}`, issues);
25839
+ validateValue(schema.items, entry, `${path23}/${index}`, issues);
25737
25840
  });
25738
25841
  }
25739
25842
  }
25740
- function compareSchemas(source, target, path22, issues) {
25843
+ function compareSchemas(source, target, path23, issues) {
25741
25844
  if (!areJsonSchemaTypesCompatible(source.type, target.type)) {
25742
- issues.push(issue2(path22, "SCHEMA_TYPE_INCOMPATIBLE", `source type ${String(source.type)} cannot supply ${String(target.type)}`));
25845
+ issues.push(issue2(path23, "SCHEMA_TYPE_INCOMPATIBLE", `source type ${String(source.type)} cannot supply ${String(target.type)}`));
25743
25846
  return;
25744
25847
  }
25745
25848
  if (source.type === "array" && target.type === "array" && isPlainRecord(source.items) && isPlainRecord(target.items)) {
25746
- compareSchemas(source.items, target.items, `${path22}[*]`, issues);
25849
+ compareSchemas(source.items, target.items, `${path23}[*]`, issues);
25747
25850
  }
25748
25851
  if (source.type === "object" && target.type === "object" && isPlainRecord(source.properties) && isPlainRecord(target.properties)) {
25749
25852
  const required = Array.isArray(target.required) ? target.required.filter((entry) => typeof entry === "string") : [];
@@ -25751,10 +25854,10 @@ function compareSchemas(source, target, path22, issues) {
25751
25854
  const sourceChild = source.properties[name];
25752
25855
  const targetChild = target.properties[name];
25753
25856
  if (!isPlainRecord(sourceChild) || !isPlainRecord(targetChild)) {
25754
- issues.push(issue2(`${path22}.${name}`, "SCHEMA_REQUIRED_MISSING", `source does not provide required property ${name}`));
25857
+ issues.push(issue2(`${path23}.${name}`, "SCHEMA_REQUIRED_MISSING", `source does not provide required property ${name}`));
25755
25858
  continue;
25756
25859
  }
25757
- compareSchemas(sourceChild, targetChild, `${path22}.${name}`, issues);
25860
+ compareSchemas(sourceChild, targetChild, `${path23}.${name}`, issues);
25758
25861
  }
25759
25862
  }
25760
25863
  }
@@ -25841,37 +25944,37 @@ var A2UICardExpressionError = class extends Error {
25841
25944
  this.fieldId = fieldId;
25842
25945
  }
25843
25946
  };
25844
- function getA2UICardTransformIssues(value, path22 = "transform") {
25947
+ function getA2UICardTransformIssues(value, path23 = "transform") {
25845
25948
  if (!isPlainRecord(value)) {
25846
25949
  return [
25847
- issue2(path22, "CARD_EXPRESSION_INVALID", "transform must be an object")
25950
+ issue2(path23, "CARD_EXPRESSION_INVALID", "transform must be an object")
25848
25951
  ];
25849
25952
  }
25850
25953
  const issues = [];
25851
25954
  const allowedKeys = /* @__PURE__ */ new Set(["language", "profile", "expression"]);
25852
25955
  for (const key of Object.keys(value)) {
25853
25956
  if (!allowedKeys.has(key)) {
25854
- issues.push(issue2(`${path22}.${key}`, "CARD_EXPRESSION_INVALID", `${key} is not supported by transform`));
25957
+ issues.push(issue2(`${path23}.${key}`, "CARD_EXPRESSION_INVALID", `${key} is not supported by transform`));
25855
25958
  }
25856
25959
  }
25857
25960
  if (value.language !== A2UI_CARD_TRANSFORM_LANGUAGE) {
25858
- issues.push(issue2(`${path22}.language`, "CARD_EXPRESSION_INVALID", `language must be ${A2UI_CARD_TRANSFORM_LANGUAGE}`));
25961
+ issues.push(issue2(`${path23}.language`, "CARD_EXPRESSION_INVALID", `language must be ${A2UI_CARD_TRANSFORM_LANGUAGE}`));
25859
25962
  }
25860
25963
  if (value.profile !== A2UI_CARD_TRANSFORM_PROFILE) {
25861
- issues.push(issue2(`${path22}.profile`, "CARD_EXPRESSION_INVALID", `profile must be ${A2UI_CARD_TRANSFORM_PROFILE}`));
25964
+ issues.push(issue2(`${path23}.profile`, "CARD_EXPRESSION_INVALID", `profile must be ${A2UI_CARD_TRANSFORM_PROFILE}`));
25862
25965
  }
25863
25966
  if (typeof value.expression !== "string" || value.expression.trim().length === 0) {
25864
- issues.push(issue2(`${path22}.expression`, "CARD_EXPRESSION_INVALID", "expression must be a non-empty string"));
25967
+ issues.push(issue2(`${path23}.expression`, "CARD_EXPRESSION_INVALID", "expression must be a non-empty string"));
25865
25968
  return issues;
25866
25969
  }
25867
25970
  if (value.expression.length > A2UI_CARD_EXPRESSION_MAX_LENGTH) {
25868
- issues.push(issue2(`${path22}.expression`, "CARD_EXPRESSION_LIMIT_EXCEEDED", `expression exceeds ${A2UI_CARD_EXPRESSION_MAX_LENGTH} characters`));
25971
+ issues.push(issue2(`${path23}.expression`, "CARD_EXPRESSION_LIMIT_EXCEEDED", `expression exceeds ${A2UI_CARD_EXPRESSION_MAX_LENGTH} characters`));
25869
25972
  return issues;
25870
25973
  }
25871
25974
  try {
25872
25975
  validateAst((0, import_jmespath2.compile)(value.expression));
25873
25976
  } catch (error) {
25874
- issues.push(issue2(`${path22}.expression`, error instanceof A2UICardExpressionError ? error.code : "CARD_EXPRESSION_INVALID", error instanceof Error ? error.message : "expression is invalid"));
25977
+ issues.push(issue2(`${path23}.expression`, error instanceof A2UICardExpressionError ? error.code : "CARD_EXPRESSION_INVALID", error instanceof Error ? error.message : "expression is invalid"));
25875
25978
  }
25876
25979
  return issues;
25877
25980
  }
@@ -25980,11 +26083,11 @@ function parseA2UICardBindingContext(value) {
25980
26083
  issues: []
25981
26084
  };
25982
26085
  }
25983
- function getA2UICardBindingContextIssues(value, path22 = "bindingContext") {
26086
+ function getA2UICardBindingContextIssues(value, path23 = "bindingContext") {
25984
26087
  const issues = [];
25985
26088
  if (!isPlainRecord(value)) {
25986
26089
  return [
25987
- issue2(path22, "CARD_BINDING_CONTEXT_INVALID", "binding context must be an object")
26090
+ issue2(path23, "CARD_BINDING_CONTEXT_INVALID", "binding context must be an object")
25988
26091
  ];
25989
26092
  }
25990
26093
  exactKeys(value, [
@@ -25996,36 +26099,36 @@ function getA2UICardBindingContextIssues(value, path22 = "bindingContext") {
25996
26099
  "generatedAt",
25997
26100
  "candidates",
25998
26101
  "preferredTools"
25999
- ], path22, issues);
26102
+ ], path23, issues);
26000
26103
  if (value.schemaVersion !== "1") {
26001
- issues.push(issue2(`${path22}.schemaVersion`, "CARD_BINDING_CONTEXT_INVALID", "schemaVersion must be 1"));
26104
+ issues.push(issue2(`${path23}.schemaVersion`, "CARD_BINDING_CONTEXT_INVALID", "schemaVersion must be 1"));
26002
26105
  }
26003
26106
  for (const key of ["draftId", "resourceId"]) {
26004
26107
  if (!isSafeIdentifier(value[key])) {
26005
- issues.push(issue2(`${path22}.${key}`, "CARD_BINDING_CONTEXT_INVALID", `${key} is invalid`));
26108
+ issues.push(issue2(`${path23}.${key}`, "CARD_BINDING_CONTEXT_INVALID", `${key} is invalid`));
26006
26109
  }
26007
26110
  }
26008
26111
  for (const key of ["draftStructureChecksum", "mcpConfigChecksum"]) {
26009
26112
  if (typeof value[key] !== "string" || !/^[0-9a-f]{64}$/u.test(value[key])) {
26010
- issues.push(issue2(`${path22}.${key}`, "CARD_BINDING_CONTEXT_INVALID", `${key} must be a sha256 checksum`));
26113
+ issues.push(issue2(`${path23}.${key}`, "CARD_BINDING_CONTEXT_INVALID", `${key} must be a sha256 checksum`));
26011
26114
  }
26012
26115
  }
26013
26116
  if (typeof value.generatedAt !== "string" || !Number.isFinite(Date.parse(value.generatedAt))) {
26014
- issues.push(issue2(`${path22}.generatedAt`, "CARD_BINDING_CONTEXT_INVALID", "generatedAt must be an ISO timestamp"));
26117
+ issues.push(issue2(`${path23}.generatedAt`, "CARD_BINDING_CONTEXT_INVALID", "generatedAt must be an ISO timestamp"));
26015
26118
  }
26016
- validateCandidates(value.candidates, `${path22}.candidates`, issues);
26017
- validatePreferences(value.preferredTools, `${path22}.preferredTools`, issues);
26119
+ validateCandidates(value.candidates, `${path23}.candidates`, issues);
26120
+ validatePreferences(value.preferredTools, `${path23}.preferredTools`, issues);
26018
26121
  return issues;
26019
26122
  }
26020
- function getA2UICardBindingSelectionIssues(value, path22 = "bindings", fields) {
26123
+ function getA2UICardBindingSelectionIssues(value, path23 = "bindings", fields) {
26021
26124
  const issues = [];
26022
26125
  if (!Array.isArray(value)) {
26023
- return [issue2(path22, "CARD_BINDING_INVALID", "bindings must be an array")];
26126
+ return [issue2(path23, "CARD_BINDING_INVALID", "bindings must be an array")];
26024
26127
  }
26025
26128
  const fieldById = new Map(fields?.map((field) => [field.fieldId, field]) ?? []);
26026
26129
  const seen = /* @__PURE__ */ new Set();
26027
26130
  value.forEach((candidate, index) => {
26028
- const itemPath = `${path22}[${index}]`;
26131
+ const itemPath = `${path23}[${index}]`;
26029
26132
  if (!isPlainRecord(candidate)) {
26030
26133
  issues.push(issue2(itemPath, "CARD_BINDING_INVALID", "binding must be an object"));
26031
26134
  return;
@@ -26138,14 +26241,14 @@ function validateA2UICardBindings(input, options = {}) {
26138
26241
  validateConsistencyGroups(input.draft.manifest.fields, bindings, issues, selectedFields);
26139
26242
  return issues;
26140
26243
  }
26141
- function validateCandidates(value, path22, issues) {
26244
+ function validateCandidates(value, path23, issues) {
26142
26245
  if (!Array.isArray(value) || value.length > 200) {
26143
- issues.push(issue2(path22, "CARD_BINDING_CONTEXT_INVALID", "candidates must be an array with at most 200 items"));
26246
+ issues.push(issue2(path23, "CARD_BINDING_CONTEXT_INVALID", "candidates must be an array with at most 200 items"));
26144
26247
  return;
26145
26248
  }
26146
26249
  const candidateKeys = /* @__PURE__ */ new Set();
26147
26250
  value.forEach((candidate, index) => {
26148
- const itemPath = `${path22}[${index}]`;
26251
+ const itemPath = `${path23}[${index}]`;
26149
26252
  if (!isPlainRecord(candidate)) {
26150
26253
  issues.push(issue2(itemPath, "CARD_BINDING_CONTEXT_INVALID", "candidate must be an object"));
26151
26254
  return;
@@ -26186,9 +26289,9 @@ function validateCandidates(value, path22, issues) {
26186
26289
  }
26187
26290
  });
26188
26291
  }
26189
- function validateTool(value, path22, resourceId, issues) {
26292
+ function validateTool(value, path23, resourceId, issues) {
26190
26293
  if (!isPlainRecord(value)) {
26191
- issues.push(issue2(path22, "CARD_BINDING_CONTEXT_INVALID", "tool must be an object"));
26294
+ issues.push(issue2(path23, "CARD_BINDING_CONTEXT_INVALID", "tool must be an object"));
26192
26295
  return;
26193
26296
  }
26194
26297
  exactKeys(value, [
@@ -26199,16 +26302,16 @@ function validateTool(value, path22, resourceId, issues) {
26199
26302
  "outputSchema",
26200
26303
  "outputSchemaMode",
26201
26304
  "annotations"
26202
- ], path22, issues);
26305
+ ], path23, issues);
26203
26306
  if (value.resourceId !== resourceId) {
26204
- issues.push(issue2(`${path22}.resourceId`, "CARD_BINDING_CONTEXT_INVALID", "tool resourceId must match candidate"));
26307
+ issues.push(issue2(`${path23}.resourceId`, "CARD_BINDING_CONTEXT_INVALID", "tool resourceId must match candidate"));
26205
26308
  }
26206
26309
  if (typeof value.toolName !== "string" || !value.toolName.trim()) {
26207
- issues.push(issue2(`${path22}.toolName`, "CARD_BINDING_CONTEXT_INVALID", "toolName is required"));
26310
+ issues.push(issue2(`${path23}.toolName`, "CARD_BINDING_CONTEXT_INVALID", "toolName is required"));
26208
26311
  }
26209
- issues.push(...getJsonSchemaIssues(value.inputSchema, `${path22}.inputSchema`));
26312
+ issues.push(...getJsonSchemaIssues(value.inputSchema, `${path23}.inputSchema`));
26210
26313
  if (value.outputSchemaMode !== void 0 && value.outputSchemaMode !== "declared" && value.outputSchemaMode !== "opaque") {
26211
- issues.push(issue2(`${path22}.outputSchemaMode`, "CARD_BINDING_CONTEXT_INVALID", "outputSchemaMode must be declared or opaque"));
26314
+ issues.push(issue2(`${path23}.outputSchemaMode`, "CARD_BINDING_CONTEXT_INVALID", "outputSchemaMode must be declared or opaque"));
26212
26315
  }
26213
26316
  }
26214
26317
  function normalizeBindingContext(context) {
@@ -26229,16 +26332,16 @@ function normalizeBindingContext(context) {
26229
26332
  });
26230
26333
  return cloned;
26231
26334
  }
26232
- function validatePreferences(value, path22, issues) {
26335
+ function validatePreferences(value, path23, issues) {
26233
26336
  if (value === void 0)
26234
26337
  return;
26235
26338
  if (!Array.isArray(value) || value.length > 512) {
26236
- issues.push(issue2(path22, "CARD_BINDING_CONTEXT_INVALID", "preferredTools must be an array"));
26339
+ issues.push(issue2(path23, "CARD_BINDING_CONTEXT_INVALID", "preferredTools must be an array"));
26237
26340
  return;
26238
26341
  }
26239
26342
  const fields = /* @__PURE__ */ new Set();
26240
26343
  value.forEach((preference, index) => {
26241
- const itemPath = `${path22}[${index}]`;
26344
+ const itemPath = `${path23}[${index}]`;
26242
26345
  if (!isPlainRecord(preference)) {
26243
26346
  issues.push(issue2(itemPath, "CARD_BINDING_CONTEXT_INVALID", "preference must be an object"));
26244
26347
  return;
@@ -26258,14 +26361,14 @@ function validatePreferences(value, path22, issues) {
26258
26361
  fields.add(preference.fieldId);
26259
26362
  });
26260
26363
  }
26261
- function validateInputBindings(value, path22, issues) {
26364
+ function validateInputBindings(value, path23, issues) {
26262
26365
  if (!Array.isArray(value) || value.length > 64) {
26263
- issues.push(issue2(path22, "CARD_BINDING_INVALID", "inputBindings must be an array with at most 64 items"));
26366
+ issues.push(issue2(path23, "CARD_BINDING_INVALID", "inputBindings must be an array with at most 64 items"));
26264
26367
  return;
26265
26368
  }
26266
26369
  const inputs = /* @__PURE__ */ new Set();
26267
26370
  value.forEach((binding, index) => {
26268
- const itemPath = `${path22}[${index}]`;
26371
+ const itemPath = `${path23}[${index}]`;
26269
26372
  if (!isPlainRecord(binding)) {
26270
26373
  issues.push(issue2(itemPath, "CARD_BINDING_INVALID", "input binding must be an object"));
26271
26374
  return;
@@ -26296,18 +26399,18 @@ function validateInputBindings(value, path22, issues) {
26296
26399
  }
26297
26400
  });
26298
26401
  }
26299
- function validateRequiredToolInputs(toolSchema, presentationSchema, bindings, path22, issues) {
26402
+ function validateRequiredToolInputs(toolSchema, presentationSchema, bindings, path23, issues) {
26300
26403
  const byInput = new Map(bindings.map((binding) => [binding.inputPath, binding]));
26301
26404
  for (const input of requiredLeafInputs(toolSchema)) {
26302
26405
  const binding = byInput.get(input.path);
26303
26406
  if (!binding) {
26304
- issues.push(issue2(path22, "CARD_BINDING_INCOMPLETE", `required Tool input ${input.path} is not bound`));
26407
+ issues.push(issue2(path23, "CARD_BINDING_INCOMPLETE", `required Tool input ${input.path} is not bound`));
26305
26408
  continue;
26306
26409
  }
26307
26410
  if (binding.source.kind === "invocation") {
26308
26411
  const source = getJsonSchemaAtDataPointer(presentationSchema, binding.source.path);
26309
26412
  if (!source || !areJsonSchemaTypesCompatible(source.type, input.schema.type)) {
26310
- issues.push(issue2(path22, "CARD_BINDING_INVALID", `invocation source ${binding.source.path} is incompatible with ${input.path}`));
26413
+ issues.push(issue2(path23, "CARD_BINDING_INVALID", `invocation source ${binding.source.path} is incompatible with ${input.path}`));
26311
26414
  }
26312
26415
  }
26313
26416
  }
@@ -26319,11 +26422,11 @@ function requiredLeafInputs(schema, basePath = "", parentRequired = true) {
26319
26422
  return Object.entries(schema.properties).flatMap(([name, child]) => {
26320
26423
  if (!isPlainRecord(child))
26321
26424
  return [];
26322
- const path22 = `${basePath}/${name.replace(/~/gu, "~0").replace(/\//gu, "~1")}`;
26425
+ const path23 = `${basePath}/${name.replace(/~/gu, "~0").replace(/\//gu, "~1")}`;
26323
26426
  const isRequired = parentRequired && required.has(name);
26324
26427
  if (child.type === "object")
26325
- return requiredLeafInputs(child, path22, isRequired);
26326
- return isRequired ? [{ path: path22, schema: child }] : [];
26428
+ return requiredLeafInputs(child, path23, isRequired);
26429
+ return isRequired ? [{ path: path23, schema: child }] : [];
26327
26430
  });
26328
26431
  }
26329
26432
  function validateConsistencyGroups(fields, bindings, issues, selectedFields) {
@@ -26359,14 +26462,16 @@ function candidateKey(resourceId, toolName) {
26359
26462
  // ../agent-a2ui-card-contract/dist/esm/payment-action.js
26360
26463
  var A2UI_PAYMENT_ACTION_NAME = "payment.trade-pay";
26361
26464
  var A2UI_PAYMENT_CALLBACK_MAX_BYTES = 16 * 1024;
26362
- function getA2UICardActionBindingIssues(value, path22 = "actionBindings") {
26465
+ function getA2UICardActionBindingIssues(value, path23 = "actionBindings") {
26363
26466
  if (!Array.isArray(value)) {
26364
- return [issue2(path22, "INVALID_ACTION_BINDINGS", "actionBindings must be an array")];
26467
+ return [
26468
+ issue2(path23, "INVALID_ACTION_BINDINGS", "actionBindings must be an array")
26469
+ ];
26365
26470
  }
26366
26471
  const issues = [];
26367
26472
  const actionIds = /* @__PURE__ */ new Set();
26368
26473
  value.forEach((candidate, index) => {
26369
- const itemPath = `${path22}[${index}]`;
26474
+ const itemPath = `${path23}[${index}]`;
26370
26475
  if (!isPlainRecord(candidate)) {
26371
26476
  issues.push(issue2(itemPath, "INVALID_ACTION_BINDING", "action binding must be an object"));
26372
26477
  return;
@@ -26388,7 +26493,7 @@ function getA2UICardActionBindingIssues(value, path22 = "actionBindings") {
26388
26493
  });
26389
26494
  return issues;
26390
26495
  }
26391
- function getA2UIPaymentActionReferenceIssues(card, bindings, path22 = "a2uiTemplate.content") {
26496
+ function getA2UIPaymentActionReferenceIssues(card, bindings, path23 = "a2uiTemplate.content") {
26392
26497
  const issues = [];
26393
26498
  const bindingIds = new Set(bindings.map((binding) => binding.actionId));
26394
26499
  const referenced = /* @__PURE__ */ new Set();
@@ -26400,63 +26505,69 @@ function getA2UIPaymentActionReferenceIssues(card, bindings, path22 = "a2uiTempl
26400
26505
  components.forEach((component, componentIndex) => {
26401
26506
  if (!isPlainRecord(component))
26402
26507
  return;
26403
- collectPaymentActionReferences(component.action, `${path22}[${messageIndex}].datas[${instructionIndex}].updateComponents.components[${componentIndex}].action`, referenced, issues);
26508
+ collectPaymentActionReferences(component.action, `${path23}[${messageIndex}].datas[${instructionIndex}].updateComponents.components[${componentIndex}].action`, referenced, issues);
26404
26509
  });
26405
26510
  });
26406
26511
  });
26407
26512
  for (const actionId of referenced) {
26408
26513
  if (!bindingIds.has(actionId)) {
26409
- issues.push(issue2(path22, "PAYMENT_ACTION_BINDING_MISSING", `payment action ${actionId} has no action binding`));
26514
+ issues.push(issue2(path23, "PAYMENT_ACTION_BINDING_MISSING", `payment action ${actionId} has no action binding`));
26410
26515
  }
26411
26516
  }
26412
26517
  for (const actionId of bindingIds) {
26413
26518
  if (!referenced.has(actionId)) {
26414
- issues.push(issue2(path22, "PAYMENT_ACTION_UNUSED", `payment action binding ${actionId} is not referenced`));
26519
+ issues.push(issue2(path23, "PAYMENT_ACTION_UNUSED", `payment action binding ${actionId} is not referenced`));
26415
26520
  }
26416
26521
  }
26417
26522
  return issues;
26418
26523
  }
26419
- function validateToolBinding(value, path22, phase, issues) {
26524
+ function validateToolBinding(value, path23, phase, issues) {
26420
26525
  if (!isPlainRecord(value)) {
26421
- issues.push(issue2(path22, "INVALID_PAYMENT_TOOL", `${path22} must be an object`));
26526
+ issues.push(issue2(path23, "INVALID_PAYMENT_TOOL", `${path23} must be an object`));
26422
26527
  return;
26423
26528
  }
26424
- rejectExtraKeys(value, phase === "create" ? ["mcpResourceId", "toolName", "inputBindings", "tradeNoPath"] : ["mcpResourceId", "toolName", "inputBindings", "statusPath", "paidValues"], path22, issues);
26529
+ rejectExtraKeys(value, phase === "create" ? ["mcpResourceId", "toolName", "inputBindings", "tradeNoPath"] : [
26530
+ "mcpResourceId",
26531
+ "toolName",
26532
+ "inputBindings",
26533
+ "statusPath",
26534
+ "paidValues"
26535
+ ], path23, issues);
26425
26536
  if (!isSafeIdentifier(value.mcpResourceId)) {
26426
- issues.push(issue2(`${path22}.mcpResourceId`, "INVALID_MCP_RESOURCE_ID", "mcpResourceId is invalid"));
26537
+ issues.push(issue2(`${path23}.mcpResourceId`, "INVALID_MCP_RESOURCE_ID", "mcpResourceId is invalid"));
26427
26538
  }
26428
26539
  if (typeof value.toolName !== "string" || !value.toolName.trim()) {
26429
- issues.push(issue2(`${path22}.toolName`, "INVALID_TOOL_NAME", "toolName is required"));
26540
+ issues.push(issue2(`${path23}.toolName`, "INVALID_TOOL_NAME", "toolName is required"));
26430
26541
  }
26431
- validateInputBindings2(value.inputBindings, `${path22}.inputBindings`, phase, issues);
26542
+ validateInputBindings2(value.inputBindings, `${path23}.inputBindings`, phase, issues);
26432
26543
  if (phase === "create") {
26433
26544
  if (!isSafeJsonPointer(value.tradeNoPath)) {
26434
- issues.push(issue2(`${path22}.tradeNoPath`, "INVALID_TRADE_NO_PATH", "tradeNoPath must be an absolute JSON Pointer"));
26545
+ issues.push(issue2(`${path23}.tradeNoPath`, "INVALID_TRADE_NO_PATH", "tradeNoPath must be an absolute JSON Pointer"));
26435
26546
  }
26436
26547
  return;
26437
26548
  }
26438
26549
  if (!isSafeJsonPointer(value.statusPath)) {
26439
- issues.push(issue2(`${path22}.statusPath`, "INVALID_PAYMENT_STATUS_PATH", "statusPath must be an absolute JSON Pointer"));
26550
+ issues.push(issue2(`${path23}.statusPath`, "INVALID_PAYMENT_STATUS_PATH", "statusPath must be an absolute JSON Pointer"));
26440
26551
  }
26441
26552
  if (!Array.isArray(value.inputBindings) || !value.inputBindings.some((binding) => isPlainRecord(binding) && isPlainRecord(binding.source) && binding.source.kind === "trade-no")) {
26442
- issues.push(issue2(`${path22}.inputBindings`, "PAYMENT_TRADE_NO_BINDING_MISSING", "queryTrade must map tradeNO"));
26553
+ issues.push(issue2(`${path23}.inputBindings`, "PAYMENT_TRADE_NO_BINDING_MISSING", "queryTrade must map tradeNO"));
26443
26554
  }
26444
26555
  if (!Array.isArray(value.paidValues) || value.paidValues.length === 0 || value.paidValues.some((entry) => !isJsonPrimitive(entry))) {
26445
- issues.push(issue2(`${path22}.paidValues`, "INVALID_PAID_VALUES", "paidValues must contain JSON primitives"));
26556
+ issues.push(issue2(`${path23}.paidValues`, "INVALID_PAID_VALUES", "paidValues must contain JSON primitives"));
26446
26557
  }
26447
26558
  }
26448
- function collectPaymentActionReferences(value, path22, referenced, issues) {
26559
+ function collectPaymentActionReferences(value, path23, referenced, issues) {
26449
26560
  if (!isPlainRecord(value))
26450
26561
  return;
26451
26562
  if (isPlainRecord(value.client) && value.client.name === A2UI_PAYMENT_ACTION_NAME) {
26452
26563
  const context = value.client.context;
26453
26564
  if (!isPlainRecord(context) || !isSafeIdentifier(context.actionId)) {
26454
- issues.push(issue2(path22, "INVALID_PAYMENT_ACTION", "payment action requires a safe actionId"));
26565
+ issues.push(issue2(path23, "INVALID_PAYMENT_ACTION", "payment action requires a safe actionId"));
26455
26566
  return;
26456
26567
  }
26457
- rejectExtraKeys(context, ["actionId", "actionContext"], `${path22}.client.context`, issues);
26568
+ rejectExtraKeys(context, ["actionId", "actionContext"], `${path23}.client.context`, issues);
26458
26569
  if (!isPlainRecord(context.actionContext)) {
26459
- issues.push(issue2(path22, "INVALID_PAYMENT_ACTION", "payment action requires an object actionContext"));
26570
+ issues.push(issue2(path23, "INVALID_PAYMENT_ACTION", "payment action requires an object actionContext"));
26460
26571
  }
26461
26572
  referenced.add(context.actionId);
26462
26573
  return;
@@ -26466,20 +26577,20 @@ function collectPaymentActionReferences(value, path22, referenced, issues) {
26466
26577
  if (Array.isArray(value.select.cases)) {
26467
26578
  value.select.cases.forEach((entry, index) => {
26468
26579
  if (isPlainRecord(entry)) {
26469
- collectPaymentActionReferences(entry.action, `${path22}.select.cases[${index}].action`, referenced, issues);
26580
+ collectPaymentActionReferences(entry.action, `${path23}.select.cases[${index}].action`, referenced, issues);
26470
26581
  }
26471
26582
  });
26472
26583
  }
26473
- collectPaymentActionReferences(value.select.default, `${path22}.select.default`, referenced, issues);
26584
+ collectPaymentActionReferences(value.select.default, `${path23}.select.default`, referenced, issues);
26474
26585
  }
26475
- function validateInputBindings2(value, path22, phase, issues) {
26586
+ function validateInputBindings2(value, path23, phase, issues) {
26476
26587
  if (!Array.isArray(value) || value.length > 128) {
26477
- issues.push(issue2(path22, "INVALID_PAYMENT_INPUT_BINDINGS", "inputBindings must be an array of at most 128 entries"));
26588
+ issues.push(issue2(path23, "INVALID_PAYMENT_INPUT_BINDINGS", "inputBindings must be an array of at most 128 entries"));
26478
26589
  return;
26479
26590
  }
26480
26591
  const targets = /* @__PURE__ */ new Set();
26481
26592
  value.forEach((candidate, index) => {
26482
- const itemPath = `${path22}[${index}]`;
26593
+ const itemPath = `${path23}[${index}]`;
26483
26594
  if (!isPlainRecord(candidate) || !isSafeJsonPointer(candidate.inputPath)) {
26484
26595
  issues.push(issue2(itemPath, "INVALID_PAYMENT_INPUT_BINDING", "inputPath must be an absolute JSON Pointer"));
26485
26596
  return;
@@ -26492,57 +26603,62 @@ function validateInputBindings2(value, path22, phase, issues) {
26492
26603
  validateInputSource(candidate.source, `${itemPath}.source`, phase, issues);
26493
26604
  });
26494
26605
  }
26495
- function validateInputSource(value, path22, phase, issues) {
26606
+ function validateInputSource(value, path23, phase, issues) {
26496
26607
  if (!isPlainRecord(value) || typeof value.kind !== "string") {
26497
- issues.push(issue2(path22, "INVALID_PAYMENT_INPUT_SOURCE", "source must be an object"));
26608
+ issues.push(issue2(path23, "INVALID_PAYMENT_INPUT_SOURCE", "source must be an object"));
26498
26609
  return;
26499
26610
  }
26500
26611
  if (value.kind === "action-context") {
26501
- rejectExtraKeys(value, ["kind", "path"], path22, issues);
26612
+ rejectExtraKeys(value, ["kind", "path"], path23, issues);
26502
26613
  if (!isSafeJsonPointer(value.path, true)) {
26503
- issues.push(issue2(`${path22}.path`, "INVALID_PAYMENT_SOURCE_PATH", "action context path must be a JSON Pointer"));
26614
+ issues.push(issue2(`${path23}.path`, "INVALID_PAYMENT_SOURCE_PATH", "action context path must be a JSON Pointer"));
26504
26615
  }
26505
26616
  return;
26506
26617
  }
26507
26618
  if (value.kind === "runtime-context") {
26508
- rejectExtraKeys(value, ["kind", "key"], path22, issues);
26619
+ rejectExtraKeys(value, ["kind", "key"], path23, issues);
26509
26620
  if (!RUNTIME_CONTEXT_KEYS2.has(String(value.key))) {
26510
- issues.push(issue2(`${path22}.key`, "INVALID_RUNTIME_CONTEXT_KEY", "runtime context key is unsupported"));
26621
+ issues.push(issue2(`${path23}.key`, "INVALID_RUNTIME_CONTEXT_KEY", "runtime context key is unsupported"));
26511
26622
  }
26512
26623
  return;
26513
26624
  }
26514
26625
  if (value.kind === "literal") {
26515
- rejectExtraKeys(value, ["kind", "value"], path22, issues);
26626
+ rejectExtraKeys(value, ["kind", "value"], path23, issues);
26516
26627
  if (!isJsonValue(value.value)) {
26517
- issues.push(issue2(`${path22}.value`, "INVALID_PAYMENT_LITERAL", "literal must be JSON"));
26628
+ issues.push(issue2(`${path23}.value`, "INVALID_PAYMENT_LITERAL", "literal must be JSON"));
26518
26629
  }
26519
26630
  return;
26520
26631
  }
26521
26632
  if (phase === "query" && value.kind === "trade-no") {
26522
- rejectExtraKeys(value, ["kind"], path22, issues);
26633
+ rejectExtraKeys(value, ["kind"], path23, issues);
26523
26634
  return;
26524
26635
  }
26525
26636
  if (phase === "query" && value.kind === "callback") {
26526
- rejectExtraKeys(value, ["kind", "path"], path22, issues);
26637
+ rejectExtraKeys(value, ["kind", "path"], path23, issues);
26527
26638
  if (!isSafeJsonPointer(value.path, true)) {
26528
- issues.push(issue2(`${path22}.path`, "INVALID_PAYMENT_CALLBACK_PATH", "callback path must be a JSON Pointer"));
26639
+ issues.push(issue2(`${path23}.path`, "INVALID_PAYMENT_CALLBACK_PATH", "callback path must be a JSON Pointer"));
26529
26640
  }
26530
26641
  return;
26531
26642
  }
26532
- issues.push(issue2(path22, "INVALID_PAYMENT_INPUT_SOURCE", `${value.kind} is unavailable for ${phase}`));
26643
+ issues.push(issue2(path23, "INVALID_PAYMENT_INPUT_SOURCE", `${value.kind} is unavailable for ${phase}`));
26533
26644
  }
26534
- function rejectExtraKeys(value, allowed, path22, issues) {
26645
+ function rejectExtraKeys(value, allowed, path23, issues) {
26535
26646
  const allowedKeys = new Set(allowed);
26536
26647
  for (const key of Object.keys(value)) {
26537
26648
  if (!allowedKeys.has(key)) {
26538
- issues.push(issue2(`${path22}.${key}`, "UNEXPECTED_ACTION_BINDING_FIELD", `${key} is not allowed`));
26649
+ issues.push(issue2(`${path23}.${key}`, "UNEXPECTED_ACTION_BINDING_FIELD", `${key} is not allowed`));
26539
26650
  }
26540
26651
  }
26541
26652
  }
26542
26653
  function isJsonPrimitive(value) {
26543
26654
  return value === null || ["string", "number", "boolean"].includes(typeof value);
26544
26655
  }
26545
- var RUNTIME_CONTEXT_KEYS2 = /* @__PURE__ */ new Set(["agentId", "tenantId", "threadId", "userId"]);
26656
+ var RUNTIME_CONTEXT_KEYS2 = /* @__PURE__ */ new Set([
26657
+ "agentId",
26658
+ "tenantId",
26659
+ "threadId",
26660
+ "userId"
26661
+ ]);
26546
26662
 
26547
26663
  // ../agent-a2ui-card-contract/dist/esm/validation.js
26548
26664
  var FIELD_TYPES = [
@@ -26688,14 +26804,14 @@ function getA2UICardResourceConfigV3Issues(value) {
26688
26804
  }
26689
26805
  return issues;
26690
26806
  }
26691
- function validateDataSources(value, path22, issues, options = {}) {
26807
+ function validateDataSources(value, path23, issues, options = {}) {
26692
26808
  if (!Array.isArray(value)) {
26693
- issues.push(issue2(path22, "INVALID_DATA_SOURCES", "dataSources must be a non-empty array"));
26809
+ issues.push(issue2(path23, "INVALID_DATA_SOURCES", "dataSources must be a non-empty array"));
26694
26810
  return void 0;
26695
26811
  }
26696
26812
  const ids = /* @__PURE__ */ new Set();
26697
26813
  value.forEach((candidate, index) => {
26698
- const itemPath = `${path22}[${index}]`;
26814
+ const itemPath = `${path23}[${index}]`;
26699
26815
  if (!isPlainRecord(candidate)) {
26700
26816
  issues.push(issue2(itemPath, "INVALID_DATA_SOURCE", "data source must be an object"));
26701
26817
  return;
@@ -26733,7 +26849,7 @@ function validateDataSources(value, path22, issues, options = {}) {
26733
26849
  for (const [index, source] of value.entries()) {
26734
26850
  for (const dependency of source.dependsOn ?? []) {
26735
26851
  if (!ids.has(dependency) || dependency === source.sourceId) {
26736
- issues.push(issue2(`${path22}[${index}].dependsOn`, "UNKNOWN_SOURCE_DEPENDENCY", `Unknown dependency ${dependency}`));
26852
+ issues.push(issue2(`${path23}[${index}].dependsOn`, "UNKNOWN_SOURCE_DEPENDENCY", `Unknown dependency ${dependency}`));
26737
26853
  }
26738
26854
  }
26739
26855
  }
@@ -26752,18 +26868,18 @@ function validateDataSources(value, path22, issues, options = {}) {
26752
26868
  return cyclic;
26753
26869
  };
26754
26870
  if ([...byId.keys()].some(visit)) {
26755
- issues.push(issue2(path22, "CYCLIC_SOURCE_DEPENDENCY", "data source dependencies must be acyclic"));
26871
+ issues.push(issue2(path23, "CYCLIC_SOURCE_DEPENDENCY", "data source dependencies must be acyclic"));
26756
26872
  }
26757
26873
  return value;
26758
26874
  }
26759
- function validateV3OutputBindings(value, path22, issues) {
26875
+ function validateV3OutputBindings(value, path23, issues) {
26760
26876
  if (!Array.isArray(value)) {
26761
- issues.push(issue2(path22, "INVALID_OUTPUT_BINDINGS", "bindings must be an array"));
26877
+ issues.push(issue2(path23, "INVALID_OUTPUT_BINDINGS", "bindings must be an array"));
26762
26878
  return void 0;
26763
26879
  }
26764
26880
  const fields = /* @__PURE__ */ new Set();
26765
26881
  value.forEach((candidate, index) => {
26766
- const itemPath = `${path22}[${index}]`;
26882
+ const itemPath = `${path23}[${index}]`;
26767
26883
  if (!isPlainRecord(candidate)) {
26768
26884
  issues.push(issue2(itemPath, "INVALID_OUTPUT_BINDING", "binding must be an object"));
26769
26885
  return;
@@ -26806,9 +26922,9 @@ function validateV3Coverage(fields, dataSources, bindings, issues, options = {})
26806
26922
  }
26807
26923
  }
26808
26924
  }
26809
- function validateV3BindingSelections(value, path22, fields, issues) {
26925
+ function validateV3BindingSelections(value, path23, fields, issues) {
26810
26926
  if (!Array.isArray(value)) {
26811
- issues.push(issue2(path22, "INVALID_BINDINGS", "bindings must be an array"));
26927
+ issues.push(issue2(path23, "INVALID_BINDINGS", "bindings must be an array"));
26812
26928
  return;
26813
26929
  }
26814
26930
  if (value.length === 0)
@@ -26817,7 +26933,7 @@ function validateV3BindingSelections(value, path22, fields, issues) {
26817
26933
  const outputBindings = [];
26818
26934
  const dataSources = [];
26819
26935
  value.forEach((candidate, index) => {
26820
- const itemPath = `${path22}[${index}]`;
26936
+ const itemPath = `${path23}[${index}]`;
26821
26937
  if (!isPlainRecord(candidate)) {
26822
26938
  issues.push(issue2(itemPath, "INVALID_BINDING", "binding must be an object"));
26823
26939
  return;
@@ -26862,19 +26978,19 @@ function validateV3BindingSelections(value, path22, fields, issues) {
26862
26978
  });
26863
26979
  }
26864
26980
  });
26865
- validateDataSources(dataSources, `${path22}.dataSources`, issues, {
26981
+ validateDataSources(dataSources, `${path23}.dataSources`, issues, {
26866
26982
  validateOutputSchema: false
26867
26983
  });
26868
- validateV3OutputBindings(outputBindings, `${path22}.outputs`, issues);
26984
+ validateV3OutputBindings(outputBindings, `${path23}.outputs`, issues);
26869
26985
  if (fields) {
26870
26986
  validateV3Coverage(fields, dataSources, outputBindings, issues, {
26871
26987
  requireComplete: false
26872
26988
  });
26873
26989
  }
26874
26990
  }
26875
- function validateManifest(value, path22, issues) {
26991
+ function validateManifest(value, path23, issues) {
26876
26992
  if (!isPlainRecord(value)) {
26877
- issues.push(issue2(path22, "INVALID_MANIFEST", `${path22} must be an object`));
26993
+ issues.push(issue2(path23, "INVALID_MANIFEST", `${path23} must be an object`));
26878
26994
  return void 0;
26879
26995
  }
26880
26996
  if (value.schemaVersion === "3") {
@@ -26890,27 +27006,27 @@ function validateManifest(value, path22, issues) {
26890
27006
  "fields",
26891
27007
  "bindings",
26892
27008
  "actionBindings"
26893
- ], path22, issues);
27009
+ ], path23, issues);
26894
27010
  if (!isSafeIdentifier(value.draftId)) {
26895
- issues.push(issue2(`${path22}.draftId`, "INVALID_DRAFT_ID", "draftId is invalid"));
27011
+ issues.push(issue2(`${path23}.draftId`, "INVALID_DRAFT_ID", "draftId is invalid"));
26896
27012
  }
26897
27013
  if (!isSafeIdentifier(value.resourceId)) {
26898
- issues.push(issue2(`${path22}.resourceId`, "INVALID_RESOURCE_ID", "resourceId is invalid"));
26899
- }
26900
- optionalString(value.baseRevision, `${path22}.baseRevision`, issues);
26901
- requiredString(value.displayName, `${path22}.displayName`, issues);
26902
- requiredString(value.description, `${path22}.description`, issues);
26903
- requiredString(value.whenToUse, `${path22}.whenToUse`, issues);
26904
- optionalString(value.whenNotToUse, `${path22}.whenNotToUse`, issues);
26905
- const fields2 = validateFields(value.fields, `${path22}.fields`, issues);
27014
+ issues.push(issue2(`${path23}.resourceId`, "INVALID_RESOURCE_ID", "resourceId is invalid"));
27015
+ }
27016
+ optionalString(value.baseRevision, `${path23}.baseRevision`, issues);
27017
+ requiredString(value.displayName, `${path23}.displayName`, issues);
27018
+ requiredString(value.description, `${path23}.description`, issues);
27019
+ requiredString(value.whenToUse, `${path23}.whenToUse`, issues);
27020
+ optionalString(value.whenNotToUse, `${path23}.whenNotToUse`, issues);
27021
+ const fields2 = validateFields(value.fields, `${path23}.fields`, issues);
26906
27022
  if (fields2?.some((field) => field.source === "invocation")) {
26907
- issues.push(issue2(`${path22}.fields`, "INVOCATION_FIELD_UNSUPPORTED", "schema v3 does not support invocation fields"));
27023
+ issues.push(issue2(`${path23}.fields`, "INVOCATION_FIELD_UNSUPPORTED", "schema v3 does not support invocation fields"));
26908
27024
  }
26909
27025
  if (value.bindings !== void 0) {
26910
- validateV3BindingSelections(value.bindings, `${path22}.bindings`, fields2, issues);
27026
+ validateV3BindingSelections(value.bindings, `${path23}.bindings`, fields2, issues);
26911
27027
  }
26912
27028
  if (value.actionBindings !== void 0) {
26913
- issues.push(...getA2UICardActionBindingIssues(value.actionBindings, `${path22}.actionBindings`));
27029
+ issues.push(...getA2UICardActionBindingIssues(value.actionBindings, `${path23}.actionBindings`));
26914
27030
  }
26915
27031
  return fields2 ? value : void 0;
26916
27032
  }
@@ -26926,37 +27042,37 @@ function validateManifest(value, path22, issues) {
26926
27042
  "presentationInputSchema",
26927
27043
  "fields",
26928
27044
  "bindings"
26929
- ], path22, issues);
27045
+ ], path23, issues);
26930
27046
  if (value.schemaVersion !== "2") {
26931
- issues.push(issue2(`${path22}.schemaVersion`, "UNSUPPORTED_DRAFT_VERSION", "schemaVersion must be 2 or 3"));
27047
+ issues.push(issue2(`${path23}.schemaVersion`, "UNSUPPORTED_DRAFT_VERSION", "schemaVersion must be 2 or 3"));
26932
27048
  }
26933
27049
  if (!isSafeIdentifier(value.draftId)) {
26934
- issues.push(issue2(`${path22}.draftId`, "INVALID_DRAFT_ID", "draftId is invalid"));
27050
+ issues.push(issue2(`${path23}.draftId`, "INVALID_DRAFT_ID", "draftId is invalid"));
26935
27051
  }
26936
27052
  if (!isSafeIdentifier(value.resourceId)) {
26937
- issues.push(issue2(`${path22}.resourceId`, "INVALID_RESOURCE_ID", "resourceId is invalid"));
26938
- }
26939
- optionalString(value.baseRevision, `${path22}.baseRevision`, issues);
26940
- requiredString(value.displayName, `${path22}.displayName`, issues);
26941
- requiredString(value.description, `${path22}.description`, issues);
26942
- requiredString(value.whenToUse, `${path22}.whenToUse`, issues);
26943
- optionalString(value.whenNotToUse, `${path22}.whenNotToUse`, issues);
26944
- const schema = validateLooseJsonSchema(value.presentationInputSchema, `${path22}.presentationInputSchema`, issues);
26945
- const fields = validateFields(value.fields, `${path22}.fields`, issues);
27053
+ issues.push(issue2(`${path23}.resourceId`, "INVALID_RESOURCE_ID", "resourceId is invalid"));
27054
+ }
27055
+ optionalString(value.baseRevision, `${path23}.baseRevision`, issues);
27056
+ requiredString(value.displayName, `${path23}.displayName`, issues);
27057
+ requiredString(value.description, `${path23}.description`, issues);
27058
+ requiredString(value.whenToUse, `${path23}.whenToUse`, issues);
27059
+ optionalString(value.whenNotToUse, `${path23}.whenNotToUse`, issues);
27060
+ const schema = validateLooseJsonSchema(value.presentationInputSchema, `${path23}.presentationInputSchema`, issues);
27061
+ const fields = validateFields(value.fields, `${path23}.fields`, issues);
26946
27062
  if (value.bindings !== void 0) {
26947
- issues.push(...getA2UICardBindingSelectionIssues(value.bindings, `${path22}.bindings`, fields));
27063
+ issues.push(...getA2UICardBindingSelectionIssues(value.bindings, `${path23}.bindings`, fields));
26948
27064
  }
26949
27065
  return schema && fields ? value : void 0;
26950
27066
  }
26951
- function validateFields(value, path22, issues) {
27067
+ function validateFields(value, path23, issues) {
26952
27068
  if (!Array.isArray(value)) {
26953
- issues.push(issue2(path22, "INVALID_FIELDS", `${path22} must be an array`));
27069
+ issues.push(issue2(path23, "INVALID_FIELDS", `${path23} must be an array`));
26954
27070
  return void 0;
26955
27071
  }
26956
27072
  const ids = /* @__PURE__ */ new Set();
26957
27073
  const paths = /* @__PURE__ */ new Set();
26958
27074
  value.forEach((candidate, index) => {
26959
- const itemPath = `${path22}[${index}]`;
27075
+ const itemPath = `${path23}[${index}]`;
26960
27076
  if (!isPlainRecord(candidate)) {
26961
27077
  issues.push(issue2(itemPath, "INVALID_FIELD", `${itemPath} must be an object`));
26962
27078
  return;
@@ -26971,7 +27087,8 @@ function validateFields(value, path22, issues) {
26971
27087
  "valueSchema",
26972
27088
  "sourcePath",
26973
27089
  "runtimeContextKey",
26974
- "consistencyGroup"
27090
+ "consistencyGroup",
27091
+ "presentation"
26975
27092
  ], itemPath, issues);
26976
27093
  if (!isSafeIdentifier(candidate.fieldId)) {
26977
27094
  issues.push(issue2(`${itemPath}.fieldId`, "INVALID_FIELD_ID", "fieldId is invalid"));
@@ -27007,9 +27124,33 @@ function validateFields(value, path22, issues) {
27007
27124
  }
27008
27125
  validateFieldSource(candidate, itemPath, issues);
27009
27126
  optionalString(candidate.consistencyGroup, `${itemPath}.consistencyGroup`, issues);
27127
+ validateFieldPresentation(candidate.presentation, itemPath, issues);
27010
27128
  });
27011
27129
  return value;
27012
27130
  }
27131
+ function validateFieldPresentation(value, itemPath, issues) {
27132
+ if (value === void 0)
27133
+ return;
27134
+ const path23 = `${itemPath}.presentation`;
27135
+ if (!isPlainRecord(value)) {
27136
+ issues.push(issue2(path23, "INVALID_FIELD_PRESENTATION", `${path23} must be an object`));
27137
+ return;
27138
+ }
27139
+ if (!["echo", "reference-only", "never"].includes(String(value.visibility))) {
27140
+ issues.push(issue2(`${path23}.visibility`, "INVALID_PRESENTATION_VISIBILITY", "presentation visibility must be echo, reference-only or never"));
27141
+ }
27142
+ if (value.labelPath !== void 0 && !isSafeJsonPointer(value.labelPath)) {
27143
+ issues.push(issue2(`${path23}.labelPath`, "INVALID_PRESENTATION_PATH", "labelPath must be a safe JSON pointer"));
27144
+ }
27145
+ if (value.attributePaths !== void 0) {
27146
+ if (!Array.isArray(value.attributePaths) || value.attributePaths.length > 3 || value.attributePaths.some((candidate) => !isSafeJsonPointer(candidate))) {
27147
+ issues.push(issue2(`${path23}.attributePaths`, "INVALID_PRESENTATION_PATHS", "attributePaths must contain at most 3 safe JSON pointers"));
27148
+ }
27149
+ }
27150
+ if (value.maxItems !== void 0 && (!Number.isInteger(value.maxItems) || Number(value.maxItems) < 1 || Number(value.maxItems) > 10)) {
27151
+ issues.push(issue2(`${path23}.maxItems`, "INVALID_PRESENTATION_MAX_ITEMS", "maxItems must be an integer between 1 and 10"));
27152
+ }
27153
+ }
27013
27154
  function validateFieldSource(candidate, itemPath, issues) {
27014
27155
  if (candidate.source === "invocation") {
27015
27156
  if (!isSafeJsonPointer(candidate.sourcePath)) {
@@ -27026,35 +27167,35 @@ function validateFieldSource(candidate, itemPath, issues) {
27026
27167
  issues.push(issue2(`${itemPath}.runtimeContextKey`, "UNEXPECTED_RUNTIME_CONTEXT", "runtimeContextKey is only allowed for runtime-context fields"));
27027
27168
  }
27028
27169
  }
27029
- function validateResolver(value, path22, issues) {
27170
+ function validateResolver(value, path23, issues) {
27030
27171
  if (!isPlainRecord(value)) {
27031
- issues.push(issue2(path22, "INVALID_RESOLVER", "resolver must be an object"));
27172
+ issues.push(issue2(path23, "INVALID_RESOLVER", "resolver must be an object"));
27032
27173
  return void 0;
27033
27174
  }
27034
- exactKeys(value, ["version", "calls", "outputBindings"], path22, issues);
27175
+ exactKeys(value, ["version", "calls", "outputBindings"], path23, issues);
27035
27176
  if (value.version !== 2) {
27036
- issues.push(issue2(`${path22}.version`, "UNSUPPORTED_RESOLVER_VERSION", "resolver version must be 2"));
27177
+ issues.push(issue2(`${path23}.version`, "UNSUPPORTED_RESOLVER_VERSION", "resolver version must be 2"));
27037
27178
  }
27038
- const calls = validateResolverCalls(value.calls, `${path22}.calls`, issues);
27039
- const outputs = validateOutputBindings(value.outputBindings, `${path22}.outputBindings`, issues);
27179
+ const calls = validateResolverCalls(value.calls, `${path23}.calls`, issues);
27180
+ const outputs = validateOutputBindings(value.outputBindings, `${path23}.outputBindings`, issues);
27040
27181
  if (!calls || !outputs)
27041
27182
  return void 0;
27042
27183
  const callIds = new Set(calls.map((call) => call.callId));
27043
27184
  outputs.forEach((binding, index) => {
27044
27185
  if (!callIds.has(binding.callId)) {
27045
- issues.push(issue2(`${path22}.outputBindings[${index}].callId`, "UNKNOWN_RESOLVER_CALL", `Unknown resolver call ${binding.callId}`));
27186
+ issues.push(issue2(`${path23}.outputBindings[${index}].callId`, "UNKNOWN_RESOLVER_CALL", `Unknown resolver call ${binding.callId}`));
27046
27187
  }
27047
27188
  });
27048
27189
  return value;
27049
27190
  }
27050
- function validateResolverCalls(value, path22, issues) {
27191
+ function validateResolverCalls(value, path23, issues) {
27051
27192
  if (!Array.isArray(value)) {
27052
- issues.push(issue2(path22, "INVALID_RESOLVER_CALLS", "calls must be an array"));
27193
+ issues.push(issue2(path23, "INVALID_RESOLVER_CALLS", "calls must be an array"));
27053
27194
  return void 0;
27054
27195
  }
27055
27196
  const callIds = /* @__PURE__ */ new Set();
27056
27197
  value.forEach((candidate, index) => {
27057
- const itemPath = `${path22}[${index}]`;
27198
+ const itemPath = `${path23}[${index}]`;
27058
27199
  if (!isPlainRecord(candidate)) {
27059
27200
  issues.push(issue2(itemPath, "INVALID_RESOLVER_CALL", "call must be an object"));
27060
27201
  return;
@@ -27075,14 +27216,14 @@ function validateResolverCalls(value, path22, issues) {
27075
27216
  });
27076
27217
  return value;
27077
27218
  }
27078
- function validateInputBindings3(value, path22, issues) {
27219
+ function validateInputBindings3(value, path23, issues) {
27079
27220
  if (!Array.isArray(value)) {
27080
- issues.push(issue2(path22, "INVALID_INPUT_BINDINGS", "inputBindings must be an array"));
27221
+ issues.push(issue2(path23, "INVALID_INPUT_BINDINGS", "inputBindings must be an array"));
27081
27222
  return void 0;
27082
27223
  }
27083
27224
  const paths = /* @__PURE__ */ new Set();
27084
27225
  value.forEach((candidate, index) => {
27085
- const itemPath = `${path22}[${index}]`;
27226
+ const itemPath = `${path23}[${index}]`;
27086
27227
  if (!isPlainRecord(candidate)) {
27087
27228
  issues.push(issue2(itemPath, "INVALID_INPUT_BINDING", "binding must be an object"));
27088
27229
  return;
@@ -27099,35 +27240,35 @@ function validateInputBindings3(value, path22, issues) {
27099
27240
  });
27100
27241
  return value;
27101
27242
  }
27102
- function validateInputSource2(value, path22, issues) {
27243
+ function validateInputSource2(value, path23, issues) {
27103
27244
  if (!isPlainRecord(value)) {
27104
- issues.push(issue2(path22, "INVALID_INPUT_SOURCE", "source must be an object"));
27245
+ issues.push(issue2(path23, "INVALID_INPUT_SOURCE", "source must be an object"));
27105
27246
  return;
27106
27247
  }
27107
27248
  if (value.kind === "invocation") {
27108
- exactKeys(value, ["kind", "path"], path22, issues);
27249
+ exactKeys(value, ["kind", "path"], path23, issues);
27109
27250
  if (!isSafeJsonPointer(value.path)) {
27110
- issues.push(issue2(`${path22}.path`, "INVALID_INPUT_SOURCE_PATH", "invocation source path must be a safe JSON pointer"));
27251
+ issues.push(issue2(`${path23}.path`, "INVALID_INPUT_SOURCE_PATH", "invocation source path must be a safe JSON pointer"));
27111
27252
  }
27112
27253
  return;
27113
27254
  }
27114
27255
  if (value.kind === "runtime-context") {
27115
- exactKeys(value, ["kind", "key"], path22, issues);
27256
+ exactKeys(value, ["kind", "key"], path23, issues);
27116
27257
  if (!RUNTIME_CONTEXT_KEYS3.has(value.key)) {
27117
- issues.push(issue2(`${path22}.key`, "INVALID_RUNTIME_CONTEXT", "runtime context key is invalid"));
27258
+ issues.push(issue2(`${path23}.key`, "INVALID_RUNTIME_CONTEXT", "runtime context key is invalid"));
27118
27259
  }
27119
27260
  return;
27120
27261
  }
27121
- issues.push(issue2(`${path22}.kind`, "INVALID_INPUT_SOURCE", "source.kind must be invocation or runtime-context"));
27262
+ issues.push(issue2(`${path23}.kind`, "INVALID_INPUT_SOURCE", "source.kind must be invocation or runtime-context"));
27122
27263
  }
27123
- function validateOutputBindings(value, path22, issues) {
27264
+ function validateOutputBindings(value, path23, issues) {
27124
27265
  if (!Array.isArray(value)) {
27125
- issues.push(issue2(path22, "INVALID_OUTPUT_BINDINGS", "outputBindings must be an array"));
27266
+ issues.push(issue2(path23, "INVALID_OUTPUT_BINDINGS", "outputBindings must be an array"));
27126
27267
  return void 0;
27127
27268
  }
27128
27269
  const fields = /* @__PURE__ */ new Set();
27129
27270
  value.forEach((candidate, index) => {
27130
- const itemPath = `${path22}[${index}]`;
27271
+ const itemPath = `${path23}[${index}]`;
27131
27272
  if (!isPlainRecord(candidate)) {
27132
27273
  issues.push(issue2(itemPath, "INVALID_OUTPUT_BINDING", "binding must be an object"));
27133
27274
  return;
@@ -27147,33 +27288,33 @@ function validateOutputBindings(value, path22, issues) {
27147
27288
  });
27148
27289
  return value;
27149
27290
  }
27150
- function validateTransformShape(value, path22, issues) {
27291
+ function validateTransformShape(value, path23, issues) {
27151
27292
  if (!isPlainRecord(value)) {
27152
- issues.push(issue2(path22, "INVALID_TRANSFORM", "transform must be an object"));
27293
+ issues.push(issue2(path23, "INVALID_TRANSFORM", "transform must be an object"));
27153
27294
  return false;
27154
27295
  }
27155
- exactKeys(value, ["language", "profile", "expression"], path22, issues);
27296
+ exactKeys(value, ["language", "profile", "expression"], path23, issues);
27156
27297
  if (value.language !== A2UI_CARD_TRANSFORM_LANGUAGE) {
27157
- issues.push(issue2(`${path22}.language`, "INVALID_TRANSFORM_LANGUAGE", `language must be ${A2UI_CARD_TRANSFORM_LANGUAGE}`));
27298
+ issues.push(issue2(`${path23}.language`, "INVALID_TRANSFORM_LANGUAGE", `language must be ${A2UI_CARD_TRANSFORM_LANGUAGE}`));
27158
27299
  }
27159
27300
  if (value.profile !== A2UI_CARD_TRANSFORM_PROFILE) {
27160
- issues.push(issue2(`${path22}.profile`, "INVALID_TRANSFORM_PROFILE", `profile must be ${A2UI_CARD_TRANSFORM_PROFILE}`));
27301
+ issues.push(issue2(`${path23}.profile`, "INVALID_TRANSFORM_PROFILE", `profile must be ${A2UI_CARD_TRANSFORM_PROFILE}`));
27161
27302
  }
27162
27303
  if (typeof value.expression !== "string" || value.expression.trim().length === 0) {
27163
- issues.push(issue2(`${path22}.expression`, "INVALID_TRANSFORM_EXPRESSION", "expression must be a non-empty string"));
27304
+ issues.push(issue2(`${path23}.expression`, "INVALID_TRANSFORM_EXPRESSION", "expression must be a non-empty string"));
27164
27305
  } else if (value.expression.length > A2UI_CARD_EXPRESSION_MAX_LENGTH) {
27165
- issues.push(issue2(`${path22}.expression`, "TRANSFORM_EXPRESSION_TOO_LONG", `expression exceeds ${A2UI_CARD_EXPRESSION_MAX_LENGTH} characters`));
27306
+ issues.push(issue2(`${path23}.expression`, "TRANSFORM_EXPRESSION_TOO_LONG", `expression exceeds ${A2UI_CARD_EXPRESSION_MAX_LENGTH} characters`));
27166
27307
  }
27167
27308
  return true;
27168
27309
  }
27169
- function validateProtocol(value, path22, issues) {
27310
+ function validateProtocol(value, path23, issues) {
27170
27311
  if (!Array.isArray(value) || value.length === 0) {
27171
- issues.push(issue2(path22, "INVALID_A2UI_PROTOCOL", "card must be a non-empty array"));
27312
+ issues.push(issue2(path23, "INVALID_A2UI_PROTOCOL", "card must be a non-empty array"));
27172
27313
  return void 0;
27173
27314
  }
27174
27315
  const issueCountBeforeValidation = issues.length;
27175
27316
  value.forEach((message, messageIndex) => {
27176
- const messagePath = `${path22}[${messageIndex}]`;
27317
+ const messagePath = `${path23}[${messageIndex}]`;
27177
27318
  if (!isPlainRecord(message)) {
27178
27319
  issues.push(issue2(messagePath, "INVALID_A2UI_MESSAGE", "A2UI message must be an object"));
27179
27320
  return;
@@ -27202,7 +27343,7 @@ function validateProtocol(value, path22, issues) {
27202
27343
  return void 0;
27203
27344
  return value;
27204
27345
  }
27205
- function validateInstructionShape(instruction, path22, issues) {
27346
+ function validateInstructionShape(instruction, path23, issues) {
27206
27347
  const knownKeys = [
27207
27348
  "createSurface",
27208
27349
  "updateComponents",
@@ -27211,31 +27352,31 @@ function validateInstructionShape(instruction, path22, issues) {
27211
27352
  "x2DeleteComponent"
27212
27353
  ].filter((key) => key in instruction);
27213
27354
  if (knownKeys.length !== 1) {
27214
- issues.push(issue2(path22, "INVALID_A2UI_INSTRUCTION", "instruction must contain exactly one supported operation"));
27355
+ issues.push(issue2(path23, "INVALID_A2UI_INSTRUCTION", "instruction must contain exactly one supported operation"));
27215
27356
  return;
27216
27357
  }
27217
27358
  const operation = knownKeys[0];
27218
27359
  const payload = instruction[operation];
27219
27360
  if (!isPlainRecord(payload)) {
27220
- issues.push(issue2(`${path22}.${operation}`, "INVALID_A2UI_INSTRUCTION_PAYLOAD", `${operation} must be an object`));
27361
+ issues.push(issue2(`${path23}.${operation}`, "INVALID_A2UI_INSTRUCTION_PAYLOAD", `${operation} must be an object`));
27221
27362
  return;
27222
27363
  }
27223
27364
  if (!isSafeIdentifier(payload.surfaceId)) {
27224
- issues.push(issue2(`${path22}.${operation}.surfaceId`, "INVALID_SURFACE_ID", "surfaceId must be a non-empty safe identifier"));
27365
+ issues.push(issue2(`${path23}.${operation}.surfaceId`, "INVALID_SURFACE_ID", "surfaceId must be a non-empty safe identifier"));
27225
27366
  }
27226
27367
  if (operation === "updateComponents") {
27227
27368
  if (!Array.isArray(payload.components)) {
27228
- issues.push(issue2(`${path22}.${operation}.components`, "INVALID_A2UI_COMPONENTS", "components must be an array"));
27369
+ issues.push(issue2(`${path23}.${operation}.components`, "INVALID_A2UI_COMPONENTS", "components must be an array"));
27229
27370
  return;
27230
27371
  }
27231
27372
  payload.components.forEach((component, componentIndex) => {
27232
27373
  if (!isPlainRecord(component) || !isJsonValue(component)) {
27233
- issues.push(issue2(`${path22}.${operation}.components[${componentIndex}]`, "INVALID_A2UI_COMPONENT", "component must be a JSON object"));
27374
+ issues.push(issue2(`${path23}.${operation}.components[${componentIndex}]`, "INVALID_A2UI_COMPONENT", "component must be a JSON object"));
27234
27375
  }
27235
27376
  });
27236
27377
  }
27237
27378
  if (operation === "x2DeleteComponent" && !isSafeIdentifier(payload.componentId)) {
27238
- issues.push(issue2(`${path22}.${operation}.componentId`, "INVALID_COMPONENT_ID", "componentId must be a non-empty safe identifier"));
27379
+ issues.push(issue2(`${path23}.${operation}.componentId`, "INVALID_COMPONENT_ID", "componentId must be a non-empty safe identifier"));
27239
27380
  }
27240
27381
  }
27241
27382
  function validateTemplate(value, fields, issues) {
@@ -27261,8 +27402,8 @@ function validateTemplate(value, fields, issues) {
27261
27402
  }
27262
27403
  return void 0;
27263
27404
  }
27264
- function validateLooseJsonSchema(value, path22, issues) {
27265
- const schemaIssues = getJsonSchemaIssues(value, path22, {
27405
+ function validateLooseJsonSchema(value, path23, issues) {
27406
+ const schemaIssues = getJsonSchemaIssues(value, path23, {
27266
27407
  allowMissingType: true
27267
27408
  });
27268
27409
  issues.push(...schemaIssues);
@@ -27284,14 +27425,14 @@ function validateResolverCoverage(fields, resolver, issues, card) {
27284
27425
  }
27285
27426
  }
27286
27427
  }
27287
- function requiredString(value, path22, issues) {
27428
+ function requiredString(value, path23, issues) {
27288
27429
  if (typeof value !== "string" || value.trim().length === 0) {
27289
- issues.push(issue2(path22, "REQUIRED_STRING", `${path22} must be a non-empty string`));
27430
+ issues.push(issue2(path23, "REQUIRED_STRING", `${path23} must be a non-empty string`));
27290
27431
  }
27291
27432
  }
27292
- function optionalString(value, path22, issues) {
27433
+ function optionalString(value, path23, issues) {
27293
27434
  if (value !== void 0 && typeof value !== "string") {
27294
- issues.push(issue2(path22, "INVALID_STRING", `${path22} must be a string`));
27435
+ issues.push(issue2(path23, "INVALID_STRING", `${path23} must be a string`));
27295
27436
  }
27296
27437
  }
27297
27438
 
@@ -27897,7 +28038,11 @@ function getA2UICardAuthoringDiagnostics(bundle, partial) {
27897
28038
  occurrenceId: group.occurrenceId
27898
28039
  });
27899
28040
  }
27900
- } else if (client && typeof client.name === "string" && !["ui.overlay.close", "ui.surface.open"].includes(client.name)) {
28041
+ } else if (client && typeof client.name === "string" && ![
28042
+ "ui.overlay.close",
28043
+ "ui.surface.open",
28044
+ A2UI_PAYMENT_ACTION_NAME
28045
+ ].includes(client.name)) {
27901
28046
  diagnostics.push({
27902
28047
  code: "UNREGISTERED_CLIENT_ACTION",
27903
28048
  path: `${group.occurrenceId}.action.client.name`,
@@ -27928,8 +28073,8 @@ function isSafePageUrl(url) {
27928
28073
  tokenCount++;
27929
28074
  if (tokenCount > 32)
27930
28075
  return false;
27931
- const path22 = match[1]?.trim() ?? "";
27932
- if (!(path22 === "/" || path22.startsWith("/") || path22.startsWith("./")) || path22.split("/").some((part) => ["..", "__proto__", "constructor", "prototype"].includes(part))) {
28076
+ const path23 = match[1]?.trim() ?? "";
28077
+ if (!(path23 === "/" || path23.startsWith("/") || path23.startsWith("./")) || path23.split("/").some((part) => ["..", "__proto__", "constructor", "prototype"].includes(part))) {
27933
28078
  return false;
27934
28079
  }
27935
28080
  }
@@ -28028,22 +28173,24 @@ function actionTargets(component, occurrenceId, actionBindings) {
28028
28173
  }
28029
28174
  ];
28030
28175
  }
28031
- if (client?.name === "payment.trade-pay") {
28176
+ if (client?.name === A2UI_PAYMENT_ACTION_NAME) {
28032
28177
  const context = isPlainRecord(client.context) ? client.context : void 0;
28033
28178
  const actionId = typeof context?.actionId === "string" ? context.actionId : "";
28034
28179
  const actionContext = isPlainRecord(context?.actionContext) ? context.actionContext : {};
28035
28180
  const binding = actionBindings?.find((candidate) => candidate.kind === "payment" && candidate.actionId === actionId);
28036
- return [{
28037
- kind: "payment",
28038
- targetId: createA2UICardAuthoringTargetId(occurrenceId, "action"),
28039
- occurrenceId,
28040
- propertyPath: "action",
28041
- label: "\u652F\u4ED8",
28042
- actionId,
28043
- actionContext,
28044
- ...binding ? { binding } : {},
28045
- configured: Boolean(actionId && binding)
28046
- }];
28181
+ return [
28182
+ {
28183
+ kind: "payment",
28184
+ targetId: createA2UICardAuthoringTargetId(occurrenceId, "action"),
28185
+ occurrenceId,
28186
+ propertyPath: "action",
28187
+ label: "\u652F\u4ED8",
28188
+ actionId,
28189
+ actionContext,
28190
+ ...binding ? { binding } : {},
28191
+ configured: Boolean(actionId && binding)
28192
+ }
28193
+ ];
28047
28194
  }
28048
28195
  return [agentOnlyAction(occurrenceId, "\u8BE5\u884C\u4E3A\u53EA\u80FD\u901A\u8FC7 Coding Agent \u4FEE\u6539")];
28049
28196
  }
@@ -28258,7 +28405,7 @@ async function rollbackCardFinalize(cwd, rollbackToken) {
28258
28405
  },
28259
28406
  async () => {
28260
28407
  const configPath = import_path22.default.join(cwd, AGENT_CONFIG_PATH);
28261
- const current = await (0, import_promises16.readFile)(configPath);
28408
+ const current = await (0, import_promises15.readFile)(configPath);
28262
28409
  if (checksumBytes(current) !== payload.expectedConfigChecksum) {
28263
28410
  throw new LinkqueCliError(
28264
28411
  "CARD_FINALIZE_CONFLICT",
@@ -28329,7 +28476,7 @@ async function finalizeCardWhileLocked(cwd, draftId, expectedDraftChecksum) {
28329
28476
  await readOptionalJson(import_path22.default.join(directory, "binding-context.json"))
28330
28477
  );
28331
28478
  const configPath = import_path22.default.join(cwd, AGENT_CONFIG_PATH);
28332
- const oldConfigBytes = await (0, import_promises16.readFile)(configPath);
28479
+ const oldConfigBytes = await (0, import_promises15.readFile)(configPath);
28333
28480
  const config2 = parseAgentConfig(
28334
28481
  JSON.parse(oldConfigBytes.toString("utf8"))
28335
28482
  );
@@ -28532,7 +28679,7 @@ async function listDraftDirectories(cwd) {
28532
28679
  const root = import_path22.default.join(cwd, DRAFT_ROOT);
28533
28680
  let entries;
28534
28681
  try {
28535
- entries = await (0, import_promises16.readdir)(root, { withFileTypes: true });
28682
+ entries = await (0, import_promises15.readdir)(root, { withFileTypes: true });
28536
28683
  } catch (cause) {
28537
28684
  if (isNodeError(cause, "ENOENT")) return [];
28538
28685
  throw new LinkqueCliError(
@@ -28571,7 +28718,7 @@ function draftIssue(code, message, recoverable, severity) {
28571
28718
  }
28572
28719
  async function readRequiredJson(file, missingCode = "CARD_DRAFT_INVALID") {
28573
28720
  try {
28574
- const content = await (0, import_promises16.readFile)(file, "utf8");
28721
+ const content = await (0, import_promises15.readFile)(file, "utf8");
28575
28722
  if (Buffer.byteLength(content, "utf8") > DRAFT_FILE_MAX_BYTES) {
28576
28723
  throw new LinkqueCliError(
28577
28724
  "CARD_DRAFT_INVALID",
@@ -28618,7 +28765,7 @@ async function readOptionalJsonObject(file) {
28618
28765
  }
28619
28766
  async function readModifiedAt(file) {
28620
28767
  try {
28621
- return (await (0, import_promises16.stat)(file)).mtime.toISOString();
28768
+ return (await (0, import_promises15.stat)(file)).mtime.toISOString();
28622
28769
  } catch {
28623
28770
  return "";
28624
28771
  }
@@ -28650,7 +28797,7 @@ function parseCardDraftState(value) {
28650
28797
  return { status: state.status, updatedAt: state.updatedAt };
28651
28798
  }
28652
28799
  function draftChecksum(bundle) {
28653
- return (0, import_crypto8.createHash)("sha256").update(stableJsonStringify(bundle)).digest("hex");
28800
+ return (0, import_crypto9.createHash)("sha256").update(stableJsonStringify(bundle)).digest("hex");
28654
28801
  }
28655
28802
  function assertDraftId(draftId) {
28656
28803
  if (!SAFE_DRAFT_ID.test(draftId)) {
@@ -28733,19 +28880,19 @@ function isJsonObject(value) {
28733
28880
  return value !== null && typeof value === "object" && !Array.isArray(value);
28734
28881
  }
28735
28882
  function checksumBytes(value) {
28736
- return (0, import_crypto8.createHash)("sha256").update(value).digest("hex");
28883
+ return (0, import_crypto9.createHash)("sha256").update(value).digest("hex");
28737
28884
  }
28738
28885
  async function atomicWrite(file, content) {
28739
- const temporary = `${file}.${process.pid}.${(0, import_crypto8.randomUUID)()}.tmp`;
28886
+ const temporary = `${file}.${process.pid}.${(0, import_crypto9.randomUUID)()}.tmp`;
28740
28887
  let handle;
28741
28888
  try {
28742
- handle = await (0, import_promises16.open)(temporary, "wx", 384);
28889
+ handle = await (0, import_promises15.open)(temporary, "wx", 384);
28743
28890
  await handle.writeFile(content);
28744
28891
  await handle.sync();
28745
28892
  await handle.close();
28746
28893
  handle = void 0;
28747
- await (0, import_promises16.rename)(temporary, file);
28748
- const directoryHandle = await (0, import_promises16.open)(import_path22.default.dirname(file), "r");
28894
+ await (0, import_promises15.rename)(temporary, file);
28895
+ const directoryHandle = await (0, import_promises15.open)(import_path22.default.dirname(file), "r");
28749
28896
  try {
28750
28897
  await directoryHandle.sync();
28751
28898
  } finally {
@@ -28753,7 +28900,7 @@ async function atomicWrite(file, content) {
28753
28900
  }
28754
28901
  } catch (cause) {
28755
28902
  await handle?.close().catch(() => void 0);
28756
- await (0, import_promises16.unlink)(temporary).catch(() => void 0);
28903
+ await (0, import_promises15.unlink)(temporary).catch(() => void 0);
28757
28904
  throw new LinkqueCliError(
28758
28905
  "CARD_FINALIZE_WRITE_FAILED",
28759
28906
  `\u539F\u5B50\u5199\u5165\u5931\u8D25: ${import_path22.default.basename(file)}`,
@@ -28782,13 +28929,13 @@ function parseRollbackToken(token) {
28782
28929
 
28783
28930
  // src/commands/dev.ts
28784
28931
  var import_child_process4 = require("child_process");
28785
- var import_promises18 = require("fs/promises");
28932
+ var import_promises17 = require("fs/promises");
28786
28933
  var import_net2 = require("net");
28787
28934
  var import_path24 = __toESM(require("path"));
28788
28935
 
28789
28936
  // src/commands/inspector.ts
28790
28937
  var import_module = require("module");
28791
- var import_promises17 = require("fs/promises");
28938
+ var import_promises16 = require("fs/promises");
28792
28939
  var import_os3 = require("os");
28793
28940
  var import_path23 = __toESM(require("path"));
28794
28941
  var import_url = require("url");
@@ -28839,7 +28986,7 @@ var assertManagedRequestFile = async (requestFile) => {
28839
28986
  );
28840
28987
  }
28841
28988
  try {
28842
- const fileStat = await (0, import_promises17.lstat)(requestFile);
28989
+ const fileStat = await (0, import_promises16.lstat)(requestFile);
28843
28990
  if (fileStat.isSymbolicLink() || !fileStat.isFile()) {
28844
28991
  throw new LinkqueCliError(
28845
28992
  "INSPECTOR_PATH_FORBIDDEN",
@@ -28853,8 +29000,8 @@ var assertManagedRequestFile = async (requestFile) => {
28853
29000
  );
28854
29001
  }
28855
29002
  const [directoryRealPath, fileRealPath] = await Promise.all([
28856
- (0, import_promises17.realpath)(managedRequestDirectory()),
28857
- (0, import_promises17.realpath)(requestFile)
29003
+ (0, import_promises16.realpath)(managedRequestDirectory()),
29004
+ (0, import_promises16.realpath)(requestFile)
28858
29005
  ]);
28859
29006
  const relative = import_path23.default.relative(directoryRealPath, fileRealPath);
28860
29007
  if (relative === "" || relative.startsWith(`..${import_path23.default.sep}`) || import_path23.default.isAbsolute(relative)) {
@@ -28882,7 +29029,7 @@ var assertManagedRequestFile = async (requestFile) => {
28882
29029
  var readInspectorRequest = async (requestFile) => {
28883
29030
  await assertManagedRequestFile(requestFile);
28884
29031
  try {
28885
- const content = await (0, import_promises17.readFile)(requestFile, "utf8");
29032
+ const content = await (0, import_promises16.readFile)(requestFile, "utf8");
28886
29033
  if (Buffer.byteLength(content, "utf8") > REQUEST_MAX_BYTES) {
28887
29034
  throw new LinkqueCliError(
28888
29035
  "INSPECTOR_REQUEST_INVALID",
@@ -29085,7 +29232,7 @@ var isPortListening2 = (port) => new Promise((resolve2) => {
29085
29232
  });
29086
29233
  async function removeMatchingState2(statePath, pid) {
29087
29234
  const owned = await readOwnedDevState(statePath);
29088
- if (owned?.pid === pid) await (0, import_promises18.rm)(statePath, { force: true });
29235
+ if (owned?.pid === pid) await (0, import_promises17.rm)(statePath, { force: true });
29089
29236
  }
29090
29237
  async function terminateOwner2(statePath, pid) {
29091
29238
  if (!isProcessAlive(pid)) {
@@ -29125,7 +29272,7 @@ var inspectRecordedDevServer = async (cwd) => {
29125
29272
  }
29126
29273
  const owned = parseOwnedDevState(content);
29127
29274
  if (owned === null) {
29128
- await (0, import_promises18.rm)(statePath, { force: true });
29275
+ await (0, import_promises17.rm)(statePath, { force: true });
29129
29276
  return { state: null, status: stopped2("STALE") };
29130
29277
  }
29131
29278
  const state = owned;
@@ -29354,15 +29501,15 @@ var stopDevServer = async (cwd) => {
29354
29501
  async () => {
29355
29502
  const owned = await readOwnedDevState(statePath);
29356
29503
  if (owned !== null) await terminateOwner2(statePath, owned.pid);
29357
- await (0, import_promises18.rm)(statePath, { force: true });
29504
+ await (0, import_promises17.rm)(statePath, { force: true });
29358
29505
  return { stopped: true };
29359
29506
  }
29360
29507
  );
29361
29508
  };
29362
29509
 
29363
29510
  // src/commands/platformSdk/apply.ts
29364
- var import_crypto9 = require("crypto");
29365
- var import_promises19 = require("fs/promises");
29511
+ var import_crypto10 = require("crypto");
29512
+ var import_promises18 = require("fs/promises");
29366
29513
  var import_path25 = __toESM(require("path"));
29367
29514
  var PLATFORM_SDK_DIR = ".platform-sdk";
29368
29515
  var PLATFORM_SDK_STATE = ".linkque/runtime/platform-sdk-state.json";
@@ -29406,7 +29553,7 @@ var parseManifest = (content) => {
29406
29553
  }
29407
29554
  return raw;
29408
29555
  };
29409
- var sha256 = (content) => `sha256:${(0, import_crypto9.createHash)("sha256").update(content).digest("hex")}`;
29556
+ var sha256 = (content) => `sha256:${(0, import_crypto10.createHash)("sha256").update(content).digest("hex")}`;
29410
29557
  var extractArchive = async (cwd, archive, manifest) => {
29411
29558
  const reader = new ZipReader(new Uint8ArrayReader(archive));
29412
29559
  const extractedFiles = /* @__PURE__ */ new Map();
@@ -29422,12 +29569,12 @@ var extractArchive = async (cwd, archive, manifest) => {
29422
29569
  }
29423
29570
  const destination = import_path25.default.join(cwd, ...entryPath.split("/"));
29424
29571
  if (entry.directory) {
29425
- await (0, import_promises19.mkdir)(destination, { recursive: true });
29572
+ await (0, import_promises18.mkdir)(destination, { recursive: true });
29426
29573
  continue;
29427
29574
  }
29428
29575
  const bytes = await entry.getData(new Uint8ArrayWriter());
29429
- await (0, import_promises19.mkdir)(import_path25.default.dirname(destination), { recursive: true });
29430
- await (0, import_promises19.writeFile)(destination, bytes, { flag: "wx" });
29576
+ await (0, import_promises18.mkdir)(import_path25.default.dirname(destination), { recursive: true });
29577
+ await (0, import_promises18.writeFile)(destination, bytes, { flag: "wx" });
29431
29578
  extractedFiles.set(entryPath, sha256(bytes));
29432
29579
  }
29433
29580
  } finally {
@@ -29446,7 +29593,7 @@ var rewritePackageJson = async (cwd, manifest) => {
29446
29593
  const packageJsonPath = import_path25.default.join(cwd, "package.json");
29447
29594
  let packageJson;
29448
29595
  try {
29449
- packageJson = JSON.parse(await (0, import_promises19.readFile)(packageJsonPath, "utf8"));
29596
+ packageJson = JSON.parse(await (0, import_promises18.readFile)(packageJsonPath, "utf8"));
29450
29597
  } catch (error) {
29451
29598
  throw new LinkqueCliError(
29452
29599
  "PLATFORM_SDK_APPLY_FAILED",
@@ -29486,8 +29633,8 @@ var rewritePackageJson = async (cwd, manifest) => {
29486
29633
  };
29487
29634
  var applyWhileLocked = async (cwd, manifestPath, archivePath, options) => {
29488
29635
  const [manifestContent, archive] = await Promise.all([
29489
- (0, import_promises19.readFile)(import_path25.default.resolve(cwd, manifestPath), "utf8"),
29490
- (0, import_promises19.readFile)(import_path25.default.resolve(cwd, archivePath))
29636
+ (0, import_promises18.readFile)(import_path25.default.resolve(cwd, manifestPath), "utf8"),
29637
+ (0, import_promises18.readFile)(import_path25.default.resolve(cwd, archivePath))
29491
29638
  ]).catch((error) => {
29492
29639
  throw new LinkqueCliError(
29493
29640
  "PLATFORM_SDK_APPLY_FAILED",
@@ -29502,7 +29649,7 @@ var applyWhileLocked = async (cwd, manifestPath, archivePath, options) => {
29502
29649
  "platform SDK archive identity does not match the manifest"
29503
29650
  );
29504
29651
  }
29505
- await (0, import_promises19.rm)(import_path25.default.join(cwd, PLATFORM_SDK_DIR), { force: true, recursive: true });
29652
+ await (0, import_promises18.rm)(import_path25.default.join(cwd, PLATFORM_SDK_DIR), { force: true, recursive: true });
29506
29653
  try {
29507
29654
  await extractArchive(cwd, archive, manifest);
29508
29655
  await rewritePackageJson(cwd, manifest);
@@ -29513,7 +29660,7 @@ var applyWhileLocked = async (cwd, manifestPath, archivePath, options) => {
29513
29660
  let templateVersion;
29514
29661
  try {
29515
29662
  const artifact = JSON.parse(
29516
- await (0, import_promises19.readFile)(import_path25.default.join(cwd, "template-artifact.json"), "utf8")
29663
+ await (0, import_promises18.readFile)(import_path25.default.join(cwd, "template-artifact.json"), "utf8")
29517
29664
  );
29518
29665
  templateVersion = typeof artifact.templateVersion === "string" ? artifact.templateVersion : void 0;
29519
29666
  } catch {
@@ -29552,6 +29699,187 @@ var applyPlatformSdk = async (cwd, manifestPath, archivePath, options = {}) => w
29552
29699
  () => applyWhileLocked(cwd, manifestPath, archivePath, options)
29553
29700
  );
29554
29701
 
29702
+ // src/commands/unzip.ts
29703
+ var import_promises19 = require("fs/promises");
29704
+ var import_path26 = __toESM(require("path"));
29705
+ var MAX_ZIP_BYTES = 70 * 1024 * 1024;
29706
+ var MAX_FILE_COUNT = 5e3;
29707
+ var MAX_TOTAL_BYTES = 50 * 1024 * 1024;
29708
+ var FileHandleZipReader = class extends Reader {
29709
+ constructor(handle) {
29710
+ super(handle);
29711
+ this.handle = handle;
29712
+ }
29713
+ async init() {
29714
+ this.size = (await this.handle.stat()).size;
29715
+ }
29716
+ async readUint8Array(offset, length) {
29717
+ const buffer = Buffer.allocUnsafe(length);
29718
+ const { bytesRead } = await this.handle.read(buffer, 0, length, offset);
29719
+ return new Uint8Array(buffer.buffer, buffer.byteOffset, bytesRead);
29720
+ }
29721
+ };
29722
+ var SourceArchiveExtractor = class {
29723
+ sourceChecksum = new SourceChecksumWriter();
29724
+ inputPath;
29725
+ outputPath;
29726
+ totalBytes = 0;
29727
+ constructor(cwd, input, output) {
29728
+ if (!input) this.invalid("unzip input path must not be empty");
29729
+ if (!output) this.invalid("unzip output path must not be empty");
29730
+ this.inputPath = import_path26.default.resolve(cwd, input);
29731
+ this.outputPath = import_path26.default.resolve(cwd, output);
29732
+ }
29733
+ async extract() {
29734
+ await this.assertInputs();
29735
+ const handle = await (0, import_promises19.open)(this.inputPath, "r").catch((error) => {
29736
+ throw new LinkqueCliError(
29737
+ "UNZIP_INPUT_INVALID",
29738
+ "unzip input archive could not be opened",
29739
+ { cause: error }
29740
+ );
29741
+ });
29742
+ const reader = new ZipReader(new FileHandleZipReader(handle), {
29743
+ useWebWorkers: false
29744
+ });
29745
+ try {
29746
+ const files = await this.readEntries(reader);
29747
+ for (const file of files) await this.extractFile(file);
29748
+ return {
29749
+ sourceChecksum: this.sourceChecksum.digest().checksum,
29750
+ fileCount: files.length,
29751
+ totalBytes: this.totalBytes
29752
+ };
29753
+ } catch (error) {
29754
+ if (error instanceof LinkqueCliError) throw error;
29755
+ throw new LinkqueCliError(
29756
+ "UNZIP_INPUT_INVALID",
29757
+ "unzip archive is invalid",
29758
+ { cause: error instanceof Error ? error : void 0 }
29759
+ );
29760
+ } finally {
29761
+ await reader.close().catch(() => void 0);
29762
+ await handle.close().catch(() => void 0);
29763
+ }
29764
+ }
29765
+ async assertInputs() {
29766
+ if (this.inputPath === this.outputPath) {
29767
+ this.invalid("unzip input and output must be different paths");
29768
+ }
29769
+ let inputStat;
29770
+ try {
29771
+ inputStat = await (0, import_promises19.stat)(this.inputPath);
29772
+ } catch (error) {
29773
+ throw new LinkqueCliError(
29774
+ "UNZIP_INPUT_INVALID",
29775
+ "unzip input archive does not exist",
29776
+ { cause: error }
29777
+ );
29778
+ }
29779
+ if (!inputStat.isFile()) this.invalid("unzip input must be a file");
29780
+ if (inputStat.size <= 0 || inputStat.size > MAX_ZIP_BYTES) {
29781
+ this.invalid(`unzip input archive exceeds ${MAX_ZIP_BYTES} bytes`);
29782
+ }
29783
+ let outputStat;
29784
+ try {
29785
+ outputStat = await (0, import_promises19.lstat)(this.outputPath);
29786
+ } catch (error) {
29787
+ throw new LinkqueCliError(
29788
+ "UNZIP_INPUT_INVALID",
29789
+ "unzip output directory does not exist",
29790
+ { cause: error }
29791
+ );
29792
+ }
29793
+ if (outputStat.isSymbolicLink() || !outputStat.isDirectory()) {
29794
+ this.invalid("unzip output must be an existing directory");
29795
+ }
29796
+ if ((await (0, import_promises19.readdir)(this.outputPath)).length > 0) {
29797
+ this.invalid("unzip output directory must be empty");
29798
+ }
29799
+ }
29800
+ async readEntries(reader) {
29801
+ const seen = /* @__PURE__ */ new Set();
29802
+ const files = [];
29803
+ let totalBytes = 0;
29804
+ for (const entry of await reader.getEntries({
29805
+ filenameValidation: "tolerant"
29806
+ })) {
29807
+ const filename = this.normalizeEntryPath(entry.filename);
29808
+ if (seen.has(filename))
29809
+ this.invalid(`unzip archive contains duplicate path: ${filename}`);
29810
+ seen.add(filename);
29811
+ if (entry.directory) continue;
29812
+ const size = entry.uncompressedSize;
29813
+ if (!Number.isSafeInteger(size) || size < 0) {
29814
+ this.invalid(`unzip entry has invalid size: ${filename}`);
29815
+ }
29816
+ totalBytes += size;
29817
+ if (files.length >= MAX_FILE_COUNT || totalBytes > MAX_TOTAL_BYTES) {
29818
+ this.invalid("unzip archive exceeds declared file or size limit");
29819
+ }
29820
+ files.push({ entry, filename, size });
29821
+ }
29822
+ this.totalBytes = totalBytes;
29823
+ return files.toSorted(
29824
+ (left, right) => left.filename < right.filename ? -1 : left.filename > right.filename ? 1 : 0
29825
+ );
29826
+ }
29827
+ normalizeEntryPath(filename) {
29828
+ const normalized = filename.replace(/\/$/u, "");
29829
+ if (!normalized || filename.includes("\0") || filename.includes("\\") || import_path26.default.posix.isAbsolute(normalized) || /^[a-zA-Z]:\//u.test(normalized) || normalized.split("/").some((part) => part === "" || part === "." || part === "..")) {
29830
+ this.invalid(`unzip archive contains an unsafe path: ${filename}`);
29831
+ }
29832
+ return normalized;
29833
+ }
29834
+ async extractFile(file) {
29835
+ const destination = this.resolveDestination(file.filename);
29836
+ await (0, import_promises19.mkdir)(import_path26.default.dirname(destination), { recursive: true });
29837
+ this.sourceChecksum.appendFileHeader(file.filename, file.size);
29838
+ const handle = await (0, import_promises19.open)(destination, "wx");
29839
+ let written = 0;
29840
+ try {
29841
+ await file.entry.getData(
29842
+ new WritableStream({
29843
+ write: async (chunk) => {
29844
+ const content = Buffer.from(
29845
+ chunk.buffer,
29846
+ chunk.byteOffset,
29847
+ chunk.byteLength
29848
+ );
29849
+ await handle.writeFile(content);
29850
+ written += content.byteLength;
29851
+ this.sourceChecksum.appendFileContent(content);
29852
+ }
29853
+ }),
29854
+ { useWebWorkers: false }
29855
+ );
29856
+ if (written !== file.size)
29857
+ this.invalid(`unzip entry size mismatch: ${file.filename}`);
29858
+ } catch (error) {
29859
+ if (error instanceof LinkqueCliError) throw error;
29860
+ throw new LinkqueCliError(
29861
+ "UNZIP_FAILED",
29862
+ "unzip archive extraction failed",
29863
+ { cause: error instanceof Error ? error : void 0 }
29864
+ );
29865
+ } finally {
29866
+ await handle.close().catch(() => void 0);
29867
+ }
29868
+ }
29869
+ resolveDestination(filename) {
29870
+ const destination = import_path26.default.resolve(this.outputPath, ...filename.split("/"));
29871
+ const relative = import_path26.default.relative(this.outputPath, destination);
29872
+ if (relative === "" || relative.startsWith("..") || import_path26.default.isAbsolute(relative)) {
29873
+ this.invalid(`unzip archive escapes output directory: ${filename}`);
29874
+ }
29875
+ return destination;
29876
+ }
29877
+ invalid(message) {
29878
+ throw new LinkqueCliError("UNZIP_INPUT_INVALID", message);
29879
+ }
29880
+ };
29881
+ var unzipArchive = (cwd, input, output) => new SourceArchiveExtractor(cwd, input, output).extract();
29882
+
29555
29883
  // src/commands/registry.ts
29556
29884
  var parsePort = (value) => {
29557
29885
  const port = Number(value);
@@ -29582,6 +29910,12 @@ var parseRequestFile = (value) => {
29582
29910
  }
29583
29911
  return value;
29584
29912
  };
29913
+ var parseUnzipPath = (value) => {
29914
+ if (value === "") {
29915
+ throw new InvalidArgumentError("unzip path must not be empty");
29916
+ }
29917
+ return value;
29918
+ };
29585
29919
  var parseOnly = (value) => value.split(",").map((item) => item.trim()).filter(Boolean);
29586
29920
  var parseEnvList = (value, previous) => [
29587
29921
  ...Array.isArray(previous) ? previous : [],
@@ -29975,6 +30309,34 @@ var buildSnapshotCommand = {
29975
30309
  excludePlatformSdk: options.excludePlatformSdk === true || process.env.LINKQUE_SNAPSHOT_EXCLUDE_PLATFORM_SDK === "1"
29976
30310
  })
29977
30311
  };
30312
+ var unzipCommand = {
30313
+ name: "unzip",
30314
+ description: "extract a manager-staged source ZIP into an empty directory",
30315
+ options: [
30316
+ {
30317
+ flags: "--input <archivePath>",
30318
+ description: "manager-staged ZIP archive path",
30319
+ key: "input",
30320
+ parse: parseUnzipPath
30321
+ },
30322
+ {
30323
+ flags: "--output <outputPath>",
30324
+ description: "existing empty output directory path",
30325
+ key: "output",
30326
+ parse: parseUnzipPath
30327
+ }
30328
+ ],
30329
+ summarize: ({ fileCount, totalBytes }) => `Archive extracted (${fileCount} files, ${totalBytes} bytes).
30330
+ `,
30331
+ run: (cwd, options) => {
30332
+ if (options.input === void 0 || options.output === void 0) {
30333
+ throw new InvalidArgumentError(
30334
+ "required options '--input' and '--output' not specified"
30335
+ );
30336
+ }
30337
+ return unzipArchive(cwd, options.input, options.output);
30338
+ }
30339
+ };
29978
30340
  var platformSdkApplyCommand = {
29979
30341
  name: "platform-sdk.apply",
29980
30342
  description: "validate and apply a platform SDK bundle to the workspace",
@@ -30138,6 +30500,7 @@ var COMMANDS = [
30138
30500
  agentdevStop,
30139
30501
  buildDistCommand,
30140
30502
  buildSnapshotCommand,
30503
+ unzipCommand,
30141
30504
  platformSdkApplyCommand,
30142
30505
  agentBuildCommand,
30143
30506
  agentDeployCommand,