linkque-cli-v2 1.2.1 → 1.2.2

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,14 @@ 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 [issue2(path23, "INVALID_ACTION_BINDINGS", "actionBindings must be an array")];
26365
26468
  }
26366
26469
  const issues = [];
26367
26470
  const actionIds = /* @__PURE__ */ new Set();
26368
26471
  value.forEach((candidate, index) => {
26369
- const itemPath = `${path22}[${index}]`;
26472
+ const itemPath = `${path23}[${index}]`;
26370
26473
  if (!isPlainRecord(candidate)) {
26371
26474
  issues.push(issue2(itemPath, "INVALID_ACTION_BINDING", "action binding must be an object"));
26372
26475
  return;
@@ -26388,7 +26491,7 @@ function getA2UICardActionBindingIssues(value, path22 = "actionBindings") {
26388
26491
  });
26389
26492
  return issues;
26390
26493
  }
26391
- function getA2UIPaymentActionReferenceIssues(card, bindings, path22 = "a2uiTemplate.content") {
26494
+ function getA2UIPaymentActionReferenceIssues(card, bindings, path23 = "a2uiTemplate.content") {
26392
26495
  const issues = [];
26393
26496
  const bindingIds = new Set(bindings.map((binding) => binding.actionId));
26394
26497
  const referenced = /* @__PURE__ */ new Set();
@@ -26400,63 +26503,63 @@ function getA2UIPaymentActionReferenceIssues(card, bindings, path22 = "a2uiTempl
26400
26503
  components.forEach((component, componentIndex) => {
26401
26504
  if (!isPlainRecord(component))
26402
26505
  return;
26403
- collectPaymentActionReferences(component.action, `${path22}[${messageIndex}].datas[${instructionIndex}].updateComponents.components[${componentIndex}].action`, referenced, issues);
26506
+ collectPaymentActionReferences(component.action, `${path23}[${messageIndex}].datas[${instructionIndex}].updateComponents.components[${componentIndex}].action`, referenced, issues);
26404
26507
  });
26405
26508
  });
26406
26509
  });
26407
26510
  for (const actionId of referenced) {
26408
26511
  if (!bindingIds.has(actionId)) {
26409
- issues.push(issue2(path22, "PAYMENT_ACTION_BINDING_MISSING", `payment action ${actionId} has no action binding`));
26512
+ issues.push(issue2(path23, "PAYMENT_ACTION_BINDING_MISSING", `payment action ${actionId} has no action binding`));
26410
26513
  }
26411
26514
  }
26412
26515
  for (const actionId of bindingIds) {
26413
26516
  if (!referenced.has(actionId)) {
26414
- issues.push(issue2(path22, "PAYMENT_ACTION_UNUSED", `payment action binding ${actionId} is not referenced`));
26517
+ issues.push(issue2(path23, "PAYMENT_ACTION_UNUSED", `payment action binding ${actionId} is not referenced`));
26415
26518
  }
26416
26519
  }
26417
26520
  return issues;
26418
26521
  }
26419
- function validateToolBinding(value, path22, phase, issues) {
26522
+ function validateToolBinding(value, path23, phase, issues) {
26420
26523
  if (!isPlainRecord(value)) {
26421
- issues.push(issue2(path22, "INVALID_PAYMENT_TOOL", `${path22} must be an object`));
26524
+ issues.push(issue2(path23, "INVALID_PAYMENT_TOOL", `${path23} must be an object`));
26422
26525
  return;
26423
26526
  }
26424
- rejectExtraKeys(value, phase === "create" ? ["mcpResourceId", "toolName", "inputBindings", "tradeNoPath"] : ["mcpResourceId", "toolName", "inputBindings", "statusPath", "paidValues"], path22, issues);
26527
+ rejectExtraKeys(value, phase === "create" ? ["mcpResourceId", "toolName", "inputBindings", "tradeNoPath"] : ["mcpResourceId", "toolName", "inputBindings", "statusPath", "paidValues"], path23, issues);
26425
26528
  if (!isSafeIdentifier(value.mcpResourceId)) {
26426
- issues.push(issue2(`${path22}.mcpResourceId`, "INVALID_MCP_RESOURCE_ID", "mcpResourceId is invalid"));
26529
+ issues.push(issue2(`${path23}.mcpResourceId`, "INVALID_MCP_RESOURCE_ID", "mcpResourceId is invalid"));
26427
26530
  }
26428
26531
  if (typeof value.toolName !== "string" || !value.toolName.trim()) {
26429
- issues.push(issue2(`${path22}.toolName`, "INVALID_TOOL_NAME", "toolName is required"));
26532
+ issues.push(issue2(`${path23}.toolName`, "INVALID_TOOL_NAME", "toolName is required"));
26430
26533
  }
26431
- validateInputBindings2(value.inputBindings, `${path22}.inputBindings`, phase, issues);
26534
+ validateInputBindings2(value.inputBindings, `${path23}.inputBindings`, phase, issues);
26432
26535
  if (phase === "create") {
26433
26536
  if (!isSafeJsonPointer(value.tradeNoPath)) {
26434
- issues.push(issue2(`${path22}.tradeNoPath`, "INVALID_TRADE_NO_PATH", "tradeNoPath must be an absolute JSON Pointer"));
26537
+ issues.push(issue2(`${path23}.tradeNoPath`, "INVALID_TRADE_NO_PATH", "tradeNoPath must be an absolute JSON Pointer"));
26435
26538
  }
26436
26539
  return;
26437
26540
  }
26438
26541
  if (!isSafeJsonPointer(value.statusPath)) {
26439
- issues.push(issue2(`${path22}.statusPath`, "INVALID_PAYMENT_STATUS_PATH", "statusPath must be an absolute JSON Pointer"));
26542
+ issues.push(issue2(`${path23}.statusPath`, "INVALID_PAYMENT_STATUS_PATH", "statusPath must be an absolute JSON Pointer"));
26440
26543
  }
26441
26544
  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"));
26545
+ issues.push(issue2(`${path23}.inputBindings`, "PAYMENT_TRADE_NO_BINDING_MISSING", "queryTrade must map tradeNO"));
26443
26546
  }
26444
26547
  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"));
26548
+ issues.push(issue2(`${path23}.paidValues`, "INVALID_PAID_VALUES", "paidValues must contain JSON primitives"));
26446
26549
  }
26447
26550
  }
26448
- function collectPaymentActionReferences(value, path22, referenced, issues) {
26551
+ function collectPaymentActionReferences(value, path23, referenced, issues) {
26449
26552
  if (!isPlainRecord(value))
26450
26553
  return;
26451
26554
  if (isPlainRecord(value.client) && value.client.name === A2UI_PAYMENT_ACTION_NAME) {
26452
26555
  const context = value.client.context;
26453
26556
  if (!isPlainRecord(context) || !isSafeIdentifier(context.actionId)) {
26454
- issues.push(issue2(path22, "INVALID_PAYMENT_ACTION", "payment action requires a safe actionId"));
26557
+ issues.push(issue2(path23, "INVALID_PAYMENT_ACTION", "payment action requires a safe actionId"));
26455
26558
  return;
26456
26559
  }
26457
- rejectExtraKeys(context, ["actionId", "actionContext"], `${path22}.client.context`, issues);
26560
+ rejectExtraKeys(context, ["actionId", "actionContext"], `${path23}.client.context`, issues);
26458
26561
  if (!isPlainRecord(context.actionContext)) {
26459
- issues.push(issue2(path22, "INVALID_PAYMENT_ACTION", "payment action requires an object actionContext"));
26562
+ issues.push(issue2(path23, "INVALID_PAYMENT_ACTION", "payment action requires an object actionContext"));
26460
26563
  }
26461
26564
  referenced.add(context.actionId);
26462
26565
  return;
@@ -26466,20 +26569,20 @@ function collectPaymentActionReferences(value, path22, referenced, issues) {
26466
26569
  if (Array.isArray(value.select.cases)) {
26467
26570
  value.select.cases.forEach((entry, index) => {
26468
26571
  if (isPlainRecord(entry)) {
26469
- collectPaymentActionReferences(entry.action, `${path22}.select.cases[${index}].action`, referenced, issues);
26572
+ collectPaymentActionReferences(entry.action, `${path23}.select.cases[${index}].action`, referenced, issues);
26470
26573
  }
26471
26574
  });
26472
26575
  }
26473
- collectPaymentActionReferences(value.select.default, `${path22}.select.default`, referenced, issues);
26576
+ collectPaymentActionReferences(value.select.default, `${path23}.select.default`, referenced, issues);
26474
26577
  }
26475
- function validateInputBindings2(value, path22, phase, issues) {
26578
+ function validateInputBindings2(value, path23, phase, issues) {
26476
26579
  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"));
26580
+ issues.push(issue2(path23, "INVALID_PAYMENT_INPUT_BINDINGS", "inputBindings must be an array of at most 128 entries"));
26478
26581
  return;
26479
26582
  }
26480
26583
  const targets = /* @__PURE__ */ new Set();
26481
26584
  value.forEach((candidate, index) => {
26482
- const itemPath = `${path22}[${index}]`;
26585
+ const itemPath = `${path23}[${index}]`;
26483
26586
  if (!isPlainRecord(candidate) || !isSafeJsonPointer(candidate.inputPath)) {
26484
26587
  issues.push(issue2(itemPath, "INVALID_PAYMENT_INPUT_BINDING", "inputPath must be an absolute JSON Pointer"));
26485
26588
  return;
@@ -26492,50 +26595,50 @@ function validateInputBindings2(value, path22, phase, issues) {
26492
26595
  validateInputSource(candidate.source, `${itemPath}.source`, phase, issues);
26493
26596
  });
26494
26597
  }
26495
- function validateInputSource(value, path22, phase, issues) {
26598
+ function validateInputSource(value, path23, phase, issues) {
26496
26599
  if (!isPlainRecord(value) || typeof value.kind !== "string") {
26497
- issues.push(issue2(path22, "INVALID_PAYMENT_INPUT_SOURCE", "source must be an object"));
26600
+ issues.push(issue2(path23, "INVALID_PAYMENT_INPUT_SOURCE", "source must be an object"));
26498
26601
  return;
26499
26602
  }
26500
26603
  if (value.kind === "action-context") {
26501
- rejectExtraKeys(value, ["kind", "path"], path22, issues);
26604
+ rejectExtraKeys(value, ["kind", "path"], path23, issues);
26502
26605
  if (!isSafeJsonPointer(value.path, true)) {
26503
- issues.push(issue2(`${path22}.path`, "INVALID_PAYMENT_SOURCE_PATH", "action context path must be a JSON Pointer"));
26606
+ issues.push(issue2(`${path23}.path`, "INVALID_PAYMENT_SOURCE_PATH", "action context path must be a JSON Pointer"));
26504
26607
  }
26505
26608
  return;
26506
26609
  }
26507
26610
  if (value.kind === "runtime-context") {
26508
- rejectExtraKeys(value, ["kind", "key"], path22, issues);
26611
+ rejectExtraKeys(value, ["kind", "key"], path23, issues);
26509
26612
  if (!RUNTIME_CONTEXT_KEYS2.has(String(value.key))) {
26510
- issues.push(issue2(`${path22}.key`, "INVALID_RUNTIME_CONTEXT_KEY", "runtime context key is unsupported"));
26613
+ issues.push(issue2(`${path23}.key`, "INVALID_RUNTIME_CONTEXT_KEY", "runtime context key is unsupported"));
26511
26614
  }
26512
26615
  return;
26513
26616
  }
26514
26617
  if (value.kind === "literal") {
26515
- rejectExtraKeys(value, ["kind", "value"], path22, issues);
26618
+ rejectExtraKeys(value, ["kind", "value"], path23, issues);
26516
26619
  if (!isJsonValue(value.value)) {
26517
- issues.push(issue2(`${path22}.value`, "INVALID_PAYMENT_LITERAL", "literal must be JSON"));
26620
+ issues.push(issue2(`${path23}.value`, "INVALID_PAYMENT_LITERAL", "literal must be JSON"));
26518
26621
  }
26519
26622
  return;
26520
26623
  }
26521
26624
  if (phase === "query" && value.kind === "trade-no") {
26522
- rejectExtraKeys(value, ["kind"], path22, issues);
26625
+ rejectExtraKeys(value, ["kind"], path23, issues);
26523
26626
  return;
26524
26627
  }
26525
26628
  if (phase === "query" && value.kind === "callback") {
26526
- rejectExtraKeys(value, ["kind", "path"], path22, issues);
26629
+ rejectExtraKeys(value, ["kind", "path"], path23, issues);
26527
26630
  if (!isSafeJsonPointer(value.path, true)) {
26528
- issues.push(issue2(`${path22}.path`, "INVALID_PAYMENT_CALLBACK_PATH", "callback path must be a JSON Pointer"));
26631
+ issues.push(issue2(`${path23}.path`, "INVALID_PAYMENT_CALLBACK_PATH", "callback path must be a JSON Pointer"));
26529
26632
  }
26530
26633
  return;
26531
26634
  }
26532
- issues.push(issue2(path22, "INVALID_PAYMENT_INPUT_SOURCE", `${value.kind} is unavailable for ${phase}`));
26635
+ issues.push(issue2(path23, "INVALID_PAYMENT_INPUT_SOURCE", `${value.kind} is unavailable for ${phase}`));
26533
26636
  }
26534
- function rejectExtraKeys(value, allowed, path22, issues) {
26637
+ function rejectExtraKeys(value, allowed, path23, issues) {
26535
26638
  const allowedKeys = new Set(allowed);
26536
26639
  for (const key of Object.keys(value)) {
26537
26640
  if (!allowedKeys.has(key)) {
26538
- issues.push(issue2(`${path22}.${key}`, "UNEXPECTED_ACTION_BINDING_FIELD", `${key} is not allowed`));
26641
+ issues.push(issue2(`${path23}.${key}`, "UNEXPECTED_ACTION_BINDING_FIELD", `${key} is not allowed`));
26539
26642
  }
26540
26643
  }
26541
26644
  }
@@ -26688,14 +26791,14 @@ function getA2UICardResourceConfigV3Issues(value) {
26688
26791
  }
26689
26792
  return issues;
26690
26793
  }
26691
- function validateDataSources(value, path22, issues, options = {}) {
26794
+ function validateDataSources(value, path23, issues, options = {}) {
26692
26795
  if (!Array.isArray(value)) {
26693
- issues.push(issue2(path22, "INVALID_DATA_SOURCES", "dataSources must be a non-empty array"));
26796
+ issues.push(issue2(path23, "INVALID_DATA_SOURCES", "dataSources must be a non-empty array"));
26694
26797
  return void 0;
26695
26798
  }
26696
26799
  const ids = /* @__PURE__ */ new Set();
26697
26800
  value.forEach((candidate, index) => {
26698
- const itemPath = `${path22}[${index}]`;
26801
+ const itemPath = `${path23}[${index}]`;
26699
26802
  if (!isPlainRecord(candidate)) {
26700
26803
  issues.push(issue2(itemPath, "INVALID_DATA_SOURCE", "data source must be an object"));
26701
26804
  return;
@@ -26733,7 +26836,7 @@ function validateDataSources(value, path22, issues, options = {}) {
26733
26836
  for (const [index, source] of value.entries()) {
26734
26837
  for (const dependency of source.dependsOn ?? []) {
26735
26838
  if (!ids.has(dependency) || dependency === source.sourceId) {
26736
- issues.push(issue2(`${path22}[${index}].dependsOn`, "UNKNOWN_SOURCE_DEPENDENCY", `Unknown dependency ${dependency}`));
26839
+ issues.push(issue2(`${path23}[${index}].dependsOn`, "UNKNOWN_SOURCE_DEPENDENCY", `Unknown dependency ${dependency}`));
26737
26840
  }
26738
26841
  }
26739
26842
  }
@@ -26752,18 +26855,18 @@ function validateDataSources(value, path22, issues, options = {}) {
26752
26855
  return cyclic;
26753
26856
  };
26754
26857
  if ([...byId.keys()].some(visit)) {
26755
- issues.push(issue2(path22, "CYCLIC_SOURCE_DEPENDENCY", "data source dependencies must be acyclic"));
26858
+ issues.push(issue2(path23, "CYCLIC_SOURCE_DEPENDENCY", "data source dependencies must be acyclic"));
26756
26859
  }
26757
26860
  return value;
26758
26861
  }
26759
- function validateV3OutputBindings(value, path22, issues) {
26862
+ function validateV3OutputBindings(value, path23, issues) {
26760
26863
  if (!Array.isArray(value)) {
26761
- issues.push(issue2(path22, "INVALID_OUTPUT_BINDINGS", "bindings must be an array"));
26864
+ issues.push(issue2(path23, "INVALID_OUTPUT_BINDINGS", "bindings must be an array"));
26762
26865
  return void 0;
26763
26866
  }
26764
26867
  const fields = /* @__PURE__ */ new Set();
26765
26868
  value.forEach((candidate, index) => {
26766
- const itemPath = `${path22}[${index}]`;
26869
+ const itemPath = `${path23}[${index}]`;
26767
26870
  if (!isPlainRecord(candidate)) {
26768
26871
  issues.push(issue2(itemPath, "INVALID_OUTPUT_BINDING", "binding must be an object"));
26769
26872
  return;
@@ -26806,9 +26909,9 @@ function validateV3Coverage(fields, dataSources, bindings, issues, options = {})
26806
26909
  }
26807
26910
  }
26808
26911
  }
26809
- function validateV3BindingSelections(value, path22, fields, issues) {
26912
+ function validateV3BindingSelections(value, path23, fields, issues) {
26810
26913
  if (!Array.isArray(value)) {
26811
- issues.push(issue2(path22, "INVALID_BINDINGS", "bindings must be an array"));
26914
+ issues.push(issue2(path23, "INVALID_BINDINGS", "bindings must be an array"));
26812
26915
  return;
26813
26916
  }
26814
26917
  if (value.length === 0)
@@ -26817,7 +26920,7 @@ function validateV3BindingSelections(value, path22, fields, issues) {
26817
26920
  const outputBindings = [];
26818
26921
  const dataSources = [];
26819
26922
  value.forEach((candidate, index) => {
26820
- const itemPath = `${path22}[${index}]`;
26923
+ const itemPath = `${path23}[${index}]`;
26821
26924
  if (!isPlainRecord(candidate)) {
26822
26925
  issues.push(issue2(itemPath, "INVALID_BINDING", "binding must be an object"));
26823
26926
  return;
@@ -26862,19 +26965,19 @@ function validateV3BindingSelections(value, path22, fields, issues) {
26862
26965
  });
26863
26966
  }
26864
26967
  });
26865
- validateDataSources(dataSources, `${path22}.dataSources`, issues, {
26968
+ validateDataSources(dataSources, `${path23}.dataSources`, issues, {
26866
26969
  validateOutputSchema: false
26867
26970
  });
26868
- validateV3OutputBindings(outputBindings, `${path22}.outputs`, issues);
26971
+ validateV3OutputBindings(outputBindings, `${path23}.outputs`, issues);
26869
26972
  if (fields) {
26870
26973
  validateV3Coverage(fields, dataSources, outputBindings, issues, {
26871
26974
  requireComplete: false
26872
26975
  });
26873
26976
  }
26874
26977
  }
26875
- function validateManifest(value, path22, issues) {
26978
+ function validateManifest(value, path23, issues) {
26876
26979
  if (!isPlainRecord(value)) {
26877
- issues.push(issue2(path22, "INVALID_MANIFEST", `${path22} must be an object`));
26980
+ issues.push(issue2(path23, "INVALID_MANIFEST", `${path23} must be an object`));
26878
26981
  return void 0;
26879
26982
  }
26880
26983
  if (value.schemaVersion === "3") {
@@ -26890,27 +26993,27 @@ function validateManifest(value, path22, issues) {
26890
26993
  "fields",
26891
26994
  "bindings",
26892
26995
  "actionBindings"
26893
- ], path22, issues);
26996
+ ], path23, issues);
26894
26997
  if (!isSafeIdentifier(value.draftId)) {
26895
- issues.push(issue2(`${path22}.draftId`, "INVALID_DRAFT_ID", "draftId is invalid"));
26998
+ issues.push(issue2(`${path23}.draftId`, "INVALID_DRAFT_ID", "draftId is invalid"));
26896
26999
  }
26897
27000
  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);
27001
+ issues.push(issue2(`${path23}.resourceId`, "INVALID_RESOURCE_ID", "resourceId is invalid"));
27002
+ }
27003
+ optionalString(value.baseRevision, `${path23}.baseRevision`, issues);
27004
+ requiredString(value.displayName, `${path23}.displayName`, issues);
27005
+ requiredString(value.description, `${path23}.description`, issues);
27006
+ requiredString(value.whenToUse, `${path23}.whenToUse`, issues);
27007
+ optionalString(value.whenNotToUse, `${path23}.whenNotToUse`, issues);
27008
+ const fields2 = validateFields(value.fields, `${path23}.fields`, issues);
26906
27009
  if (fields2?.some((field) => field.source === "invocation")) {
26907
- issues.push(issue2(`${path22}.fields`, "INVOCATION_FIELD_UNSUPPORTED", "schema v3 does not support invocation fields"));
27010
+ issues.push(issue2(`${path23}.fields`, "INVOCATION_FIELD_UNSUPPORTED", "schema v3 does not support invocation fields"));
26908
27011
  }
26909
27012
  if (value.bindings !== void 0) {
26910
- validateV3BindingSelections(value.bindings, `${path22}.bindings`, fields2, issues);
27013
+ validateV3BindingSelections(value.bindings, `${path23}.bindings`, fields2, issues);
26911
27014
  }
26912
27015
  if (value.actionBindings !== void 0) {
26913
- issues.push(...getA2UICardActionBindingIssues(value.actionBindings, `${path22}.actionBindings`));
27016
+ issues.push(...getA2UICardActionBindingIssues(value.actionBindings, `${path23}.actionBindings`));
26914
27017
  }
26915
27018
  return fields2 ? value : void 0;
26916
27019
  }
@@ -26926,37 +27029,37 @@ function validateManifest(value, path22, issues) {
26926
27029
  "presentationInputSchema",
26927
27030
  "fields",
26928
27031
  "bindings"
26929
- ], path22, issues);
27032
+ ], path23, issues);
26930
27033
  if (value.schemaVersion !== "2") {
26931
- issues.push(issue2(`${path22}.schemaVersion`, "UNSUPPORTED_DRAFT_VERSION", "schemaVersion must be 2 or 3"));
27034
+ issues.push(issue2(`${path23}.schemaVersion`, "UNSUPPORTED_DRAFT_VERSION", "schemaVersion must be 2 or 3"));
26932
27035
  }
26933
27036
  if (!isSafeIdentifier(value.draftId)) {
26934
- issues.push(issue2(`${path22}.draftId`, "INVALID_DRAFT_ID", "draftId is invalid"));
27037
+ issues.push(issue2(`${path23}.draftId`, "INVALID_DRAFT_ID", "draftId is invalid"));
26935
27038
  }
26936
27039
  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);
27040
+ issues.push(issue2(`${path23}.resourceId`, "INVALID_RESOURCE_ID", "resourceId is invalid"));
27041
+ }
27042
+ optionalString(value.baseRevision, `${path23}.baseRevision`, issues);
27043
+ requiredString(value.displayName, `${path23}.displayName`, issues);
27044
+ requiredString(value.description, `${path23}.description`, issues);
27045
+ requiredString(value.whenToUse, `${path23}.whenToUse`, issues);
27046
+ optionalString(value.whenNotToUse, `${path23}.whenNotToUse`, issues);
27047
+ const schema = validateLooseJsonSchema(value.presentationInputSchema, `${path23}.presentationInputSchema`, issues);
27048
+ const fields = validateFields(value.fields, `${path23}.fields`, issues);
26946
27049
  if (value.bindings !== void 0) {
26947
- issues.push(...getA2UICardBindingSelectionIssues(value.bindings, `${path22}.bindings`, fields));
27050
+ issues.push(...getA2UICardBindingSelectionIssues(value.bindings, `${path23}.bindings`, fields));
26948
27051
  }
26949
27052
  return schema && fields ? value : void 0;
26950
27053
  }
26951
- function validateFields(value, path22, issues) {
27054
+ function validateFields(value, path23, issues) {
26952
27055
  if (!Array.isArray(value)) {
26953
- issues.push(issue2(path22, "INVALID_FIELDS", `${path22} must be an array`));
27056
+ issues.push(issue2(path23, "INVALID_FIELDS", `${path23} must be an array`));
26954
27057
  return void 0;
26955
27058
  }
26956
27059
  const ids = /* @__PURE__ */ new Set();
26957
27060
  const paths = /* @__PURE__ */ new Set();
26958
27061
  value.forEach((candidate, index) => {
26959
- const itemPath = `${path22}[${index}]`;
27062
+ const itemPath = `${path23}[${index}]`;
26960
27063
  if (!isPlainRecord(candidate)) {
26961
27064
  issues.push(issue2(itemPath, "INVALID_FIELD", `${itemPath} must be an object`));
26962
27065
  return;
@@ -27026,35 +27129,35 @@ function validateFieldSource(candidate, itemPath, issues) {
27026
27129
  issues.push(issue2(`${itemPath}.runtimeContextKey`, "UNEXPECTED_RUNTIME_CONTEXT", "runtimeContextKey is only allowed for runtime-context fields"));
27027
27130
  }
27028
27131
  }
27029
- function validateResolver(value, path22, issues) {
27132
+ function validateResolver(value, path23, issues) {
27030
27133
  if (!isPlainRecord(value)) {
27031
- issues.push(issue2(path22, "INVALID_RESOLVER", "resolver must be an object"));
27134
+ issues.push(issue2(path23, "INVALID_RESOLVER", "resolver must be an object"));
27032
27135
  return void 0;
27033
27136
  }
27034
- exactKeys(value, ["version", "calls", "outputBindings"], path22, issues);
27137
+ exactKeys(value, ["version", "calls", "outputBindings"], path23, issues);
27035
27138
  if (value.version !== 2) {
27036
- issues.push(issue2(`${path22}.version`, "UNSUPPORTED_RESOLVER_VERSION", "resolver version must be 2"));
27139
+ issues.push(issue2(`${path23}.version`, "UNSUPPORTED_RESOLVER_VERSION", "resolver version must be 2"));
27037
27140
  }
27038
- const calls = validateResolverCalls(value.calls, `${path22}.calls`, issues);
27039
- const outputs = validateOutputBindings(value.outputBindings, `${path22}.outputBindings`, issues);
27141
+ const calls = validateResolverCalls(value.calls, `${path23}.calls`, issues);
27142
+ const outputs = validateOutputBindings(value.outputBindings, `${path23}.outputBindings`, issues);
27040
27143
  if (!calls || !outputs)
27041
27144
  return void 0;
27042
27145
  const callIds = new Set(calls.map((call) => call.callId));
27043
27146
  outputs.forEach((binding, index) => {
27044
27147
  if (!callIds.has(binding.callId)) {
27045
- issues.push(issue2(`${path22}.outputBindings[${index}].callId`, "UNKNOWN_RESOLVER_CALL", `Unknown resolver call ${binding.callId}`));
27148
+ issues.push(issue2(`${path23}.outputBindings[${index}].callId`, "UNKNOWN_RESOLVER_CALL", `Unknown resolver call ${binding.callId}`));
27046
27149
  }
27047
27150
  });
27048
27151
  return value;
27049
27152
  }
27050
- function validateResolverCalls(value, path22, issues) {
27153
+ function validateResolverCalls(value, path23, issues) {
27051
27154
  if (!Array.isArray(value)) {
27052
- issues.push(issue2(path22, "INVALID_RESOLVER_CALLS", "calls must be an array"));
27155
+ issues.push(issue2(path23, "INVALID_RESOLVER_CALLS", "calls must be an array"));
27053
27156
  return void 0;
27054
27157
  }
27055
27158
  const callIds = /* @__PURE__ */ new Set();
27056
27159
  value.forEach((candidate, index) => {
27057
- const itemPath = `${path22}[${index}]`;
27160
+ const itemPath = `${path23}[${index}]`;
27058
27161
  if (!isPlainRecord(candidate)) {
27059
27162
  issues.push(issue2(itemPath, "INVALID_RESOLVER_CALL", "call must be an object"));
27060
27163
  return;
@@ -27075,14 +27178,14 @@ function validateResolverCalls(value, path22, issues) {
27075
27178
  });
27076
27179
  return value;
27077
27180
  }
27078
- function validateInputBindings3(value, path22, issues) {
27181
+ function validateInputBindings3(value, path23, issues) {
27079
27182
  if (!Array.isArray(value)) {
27080
- issues.push(issue2(path22, "INVALID_INPUT_BINDINGS", "inputBindings must be an array"));
27183
+ issues.push(issue2(path23, "INVALID_INPUT_BINDINGS", "inputBindings must be an array"));
27081
27184
  return void 0;
27082
27185
  }
27083
27186
  const paths = /* @__PURE__ */ new Set();
27084
27187
  value.forEach((candidate, index) => {
27085
- const itemPath = `${path22}[${index}]`;
27188
+ const itemPath = `${path23}[${index}]`;
27086
27189
  if (!isPlainRecord(candidate)) {
27087
27190
  issues.push(issue2(itemPath, "INVALID_INPUT_BINDING", "binding must be an object"));
27088
27191
  return;
@@ -27099,35 +27202,35 @@ function validateInputBindings3(value, path22, issues) {
27099
27202
  });
27100
27203
  return value;
27101
27204
  }
27102
- function validateInputSource2(value, path22, issues) {
27205
+ function validateInputSource2(value, path23, issues) {
27103
27206
  if (!isPlainRecord(value)) {
27104
- issues.push(issue2(path22, "INVALID_INPUT_SOURCE", "source must be an object"));
27207
+ issues.push(issue2(path23, "INVALID_INPUT_SOURCE", "source must be an object"));
27105
27208
  return;
27106
27209
  }
27107
27210
  if (value.kind === "invocation") {
27108
- exactKeys(value, ["kind", "path"], path22, issues);
27211
+ exactKeys(value, ["kind", "path"], path23, issues);
27109
27212
  if (!isSafeJsonPointer(value.path)) {
27110
- issues.push(issue2(`${path22}.path`, "INVALID_INPUT_SOURCE_PATH", "invocation source path must be a safe JSON pointer"));
27213
+ issues.push(issue2(`${path23}.path`, "INVALID_INPUT_SOURCE_PATH", "invocation source path must be a safe JSON pointer"));
27111
27214
  }
27112
27215
  return;
27113
27216
  }
27114
27217
  if (value.kind === "runtime-context") {
27115
- exactKeys(value, ["kind", "key"], path22, issues);
27218
+ exactKeys(value, ["kind", "key"], path23, issues);
27116
27219
  if (!RUNTIME_CONTEXT_KEYS3.has(value.key)) {
27117
- issues.push(issue2(`${path22}.key`, "INVALID_RUNTIME_CONTEXT", "runtime context key is invalid"));
27220
+ issues.push(issue2(`${path23}.key`, "INVALID_RUNTIME_CONTEXT", "runtime context key is invalid"));
27118
27221
  }
27119
27222
  return;
27120
27223
  }
27121
- issues.push(issue2(`${path22}.kind`, "INVALID_INPUT_SOURCE", "source.kind must be invocation or runtime-context"));
27224
+ issues.push(issue2(`${path23}.kind`, "INVALID_INPUT_SOURCE", "source.kind must be invocation or runtime-context"));
27122
27225
  }
27123
- function validateOutputBindings(value, path22, issues) {
27226
+ function validateOutputBindings(value, path23, issues) {
27124
27227
  if (!Array.isArray(value)) {
27125
- issues.push(issue2(path22, "INVALID_OUTPUT_BINDINGS", "outputBindings must be an array"));
27228
+ issues.push(issue2(path23, "INVALID_OUTPUT_BINDINGS", "outputBindings must be an array"));
27126
27229
  return void 0;
27127
27230
  }
27128
27231
  const fields = /* @__PURE__ */ new Set();
27129
27232
  value.forEach((candidate, index) => {
27130
- const itemPath = `${path22}[${index}]`;
27233
+ const itemPath = `${path23}[${index}]`;
27131
27234
  if (!isPlainRecord(candidate)) {
27132
27235
  issues.push(issue2(itemPath, "INVALID_OUTPUT_BINDING", "binding must be an object"));
27133
27236
  return;
@@ -27147,33 +27250,33 @@ function validateOutputBindings(value, path22, issues) {
27147
27250
  });
27148
27251
  return value;
27149
27252
  }
27150
- function validateTransformShape(value, path22, issues) {
27253
+ function validateTransformShape(value, path23, issues) {
27151
27254
  if (!isPlainRecord(value)) {
27152
- issues.push(issue2(path22, "INVALID_TRANSFORM", "transform must be an object"));
27255
+ issues.push(issue2(path23, "INVALID_TRANSFORM", "transform must be an object"));
27153
27256
  return false;
27154
27257
  }
27155
- exactKeys(value, ["language", "profile", "expression"], path22, issues);
27258
+ exactKeys(value, ["language", "profile", "expression"], path23, issues);
27156
27259
  if (value.language !== A2UI_CARD_TRANSFORM_LANGUAGE) {
27157
- issues.push(issue2(`${path22}.language`, "INVALID_TRANSFORM_LANGUAGE", `language must be ${A2UI_CARD_TRANSFORM_LANGUAGE}`));
27260
+ issues.push(issue2(`${path23}.language`, "INVALID_TRANSFORM_LANGUAGE", `language must be ${A2UI_CARD_TRANSFORM_LANGUAGE}`));
27158
27261
  }
27159
27262
  if (value.profile !== A2UI_CARD_TRANSFORM_PROFILE) {
27160
- issues.push(issue2(`${path22}.profile`, "INVALID_TRANSFORM_PROFILE", `profile must be ${A2UI_CARD_TRANSFORM_PROFILE}`));
27263
+ issues.push(issue2(`${path23}.profile`, "INVALID_TRANSFORM_PROFILE", `profile must be ${A2UI_CARD_TRANSFORM_PROFILE}`));
27161
27264
  }
27162
27265
  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"));
27266
+ issues.push(issue2(`${path23}.expression`, "INVALID_TRANSFORM_EXPRESSION", "expression must be a non-empty string"));
27164
27267
  } 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`));
27268
+ issues.push(issue2(`${path23}.expression`, "TRANSFORM_EXPRESSION_TOO_LONG", `expression exceeds ${A2UI_CARD_EXPRESSION_MAX_LENGTH} characters`));
27166
27269
  }
27167
27270
  return true;
27168
27271
  }
27169
- function validateProtocol(value, path22, issues) {
27272
+ function validateProtocol(value, path23, issues) {
27170
27273
  if (!Array.isArray(value) || value.length === 0) {
27171
- issues.push(issue2(path22, "INVALID_A2UI_PROTOCOL", "card must be a non-empty array"));
27274
+ issues.push(issue2(path23, "INVALID_A2UI_PROTOCOL", "card must be a non-empty array"));
27172
27275
  return void 0;
27173
27276
  }
27174
27277
  const issueCountBeforeValidation = issues.length;
27175
27278
  value.forEach((message, messageIndex) => {
27176
- const messagePath = `${path22}[${messageIndex}]`;
27279
+ const messagePath = `${path23}[${messageIndex}]`;
27177
27280
  if (!isPlainRecord(message)) {
27178
27281
  issues.push(issue2(messagePath, "INVALID_A2UI_MESSAGE", "A2UI message must be an object"));
27179
27282
  return;
@@ -27202,7 +27305,7 @@ function validateProtocol(value, path22, issues) {
27202
27305
  return void 0;
27203
27306
  return value;
27204
27307
  }
27205
- function validateInstructionShape(instruction, path22, issues) {
27308
+ function validateInstructionShape(instruction, path23, issues) {
27206
27309
  const knownKeys = [
27207
27310
  "createSurface",
27208
27311
  "updateComponents",
@@ -27211,31 +27314,31 @@ function validateInstructionShape(instruction, path22, issues) {
27211
27314
  "x2DeleteComponent"
27212
27315
  ].filter((key) => key in instruction);
27213
27316
  if (knownKeys.length !== 1) {
27214
- issues.push(issue2(path22, "INVALID_A2UI_INSTRUCTION", "instruction must contain exactly one supported operation"));
27317
+ issues.push(issue2(path23, "INVALID_A2UI_INSTRUCTION", "instruction must contain exactly one supported operation"));
27215
27318
  return;
27216
27319
  }
27217
27320
  const operation = knownKeys[0];
27218
27321
  const payload = instruction[operation];
27219
27322
  if (!isPlainRecord(payload)) {
27220
- issues.push(issue2(`${path22}.${operation}`, "INVALID_A2UI_INSTRUCTION_PAYLOAD", `${operation} must be an object`));
27323
+ issues.push(issue2(`${path23}.${operation}`, "INVALID_A2UI_INSTRUCTION_PAYLOAD", `${operation} must be an object`));
27221
27324
  return;
27222
27325
  }
27223
27326
  if (!isSafeIdentifier(payload.surfaceId)) {
27224
- issues.push(issue2(`${path22}.${operation}.surfaceId`, "INVALID_SURFACE_ID", "surfaceId must be a non-empty safe identifier"));
27327
+ issues.push(issue2(`${path23}.${operation}.surfaceId`, "INVALID_SURFACE_ID", "surfaceId must be a non-empty safe identifier"));
27225
27328
  }
27226
27329
  if (operation === "updateComponents") {
27227
27330
  if (!Array.isArray(payload.components)) {
27228
- issues.push(issue2(`${path22}.${operation}.components`, "INVALID_A2UI_COMPONENTS", "components must be an array"));
27331
+ issues.push(issue2(`${path23}.${operation}.components`, "INVALID_A2UI_COMPONENTS", "components must be an array"));
27229
27332
  return;
27230
27333
  }
27231
27334
  payload.components.forEach((component, componentIndex) => {
27232
27335
  if (!isPlainRecord(component) || !isJsonValue(component)) {
27233
- issues.push(issue2(`${path22}.${operation}.components[${componentIndex}]`, "INVALID_A2UI_COMPONENT", "component must be a JSON object"));
27336
+ issues.push(issue2(`${path23}.${operation}.components[${componentIndex}]`, "INVALID_A2UI_COMPONENT", "component must be a JSON object"));
27234
27337
  }
27235
27338
  });
27236
27339
  }
27237
27340
  if (operation === "x2DeleteComponent" && !isSafeIdentifier(payload.componentId)) {
27238
- issues.push(issue2(`${path22}.${operation}.componentId`, "INVALID_COMPONENT_ID", "componentId must be a non-empty safe identifier"));
27341
+ issues.push(issue2(`${path23}.${operation}.componentId`, "INVALID_COMPONENT_ID", "componentId must be a non-empty safe identifier"));
27239
27342
  }
27240
27343
  }
27241
27344
  function validateTemplate(value, fields, issues) {
@@ -27261,8 +27364,8 @@ function validateTemplate(value, fields, issues) {
27261
27364
  }
27262
27365
  return void 0;
27263
27366
  }
27264
- function validateLooseJsonSchema(value, path22, issues) {
27265
- const schemaIssues = getJsonSchemaIssues(value, path22, {
27367
+ function validateLooseJsonSchema(value, path23, issues) {
27368
+ const schemaIssues = getJsonSchemaIssues(value, path23, {
27266
27369
  allowMissingType: true
27267
27370
  });
27268
27371
  issues.push(...schemaIssues);
@@ -27284,14 +27387,14 @@ function validateResolverCoverage(fields, resolver, issues, card) {
27284
27387
  }
27285
27388
  }
27286
27389
  }
27287
- function requiredString(value, path22, issues) {
27390
+ function requiredString(value, path23, issues) {
27288
27391
  if (typeof value !== "string" || value.trim().length === 0) {
27289
- issues.push(issue2(path22, "REQUIRED_STRING", `${path22} must be a non-empty string`));
27392
+ issues.push(issue2(path23, "REQUIRED_STRING", `${path23} must be a non-empty string`));
27290
27393
  }
27291
27394
  }
27292
- function optionalString(value, path22, issues) {
27395
+ function optionalString(value, path23, issues) {
27293
27396
  if (value !== void 0 && typeof value !== "string") {
27294
- issues.push(issue2(path22, "INVALID_STRING", `${path22} must be a string`));
27397
+ issues.push(issue2(path23, "INVALID_STRING", `${path23} must be a string`));
27295
27398
  }
27296
27399
  }
27297
27400
 
@@ -27897,7 +28000,11 @@ function getA2UICardAuthoringDiagnostics(bundle, partial) {
27897
28000
  occurrenceId: group.occurrenceId
27898
28001
  });
27899
28002
  }
27900
- } else if (client && typeof client.name === "string" && !["ui.overlay.close", "ui.surface.open"].includes(client.name)) {
28003
+ } else if (client && typeof client.name === "string" && ![
28004
+ "ui.overlay.close",
28005
+ "ui.surface.open",
28006
+ A2UI_PAYMENT_ACTION_NAME
28007
+ ].includes(client.name)) {
27901
28008
  diagnostics.push({
27902
28009
  code: "UNREGISTERED_CLIENT_ACTION",
27903
28010
  path: `${group.occurrenceId}.action.client.name`,
@@ -27928,8 +28035,8 @@ function isSafePageUrl(url) {
27928
28035
  tokenCount++;
27929
28036
  if (tokenCount > 32)
27930
28037
  return false;
27931
- const path22 = match[1]?.trim() ?? "";
27932
- if (!(path22 === "/" || path22.startsWith("/") || path22.startsWith("./")) || path22.split("/").some((part) => ["..", "__proto__", "constructor", "prototype"].includes(part))) {
28038
+ const path23 = match[1]?.trim() ?? "";
28039
+ if (!(path23 === "/" || path23.startsWith("/") || path23.startsWith("./")) || path23.split("/").some((part) => ["..", "__proto__", "constructor", "prototype"].includes(part))) {
27933
28040
  return false;
27934
28041
  }
27935
28042
  }
@@ -28028,22 +28135,24 @@ function actionTargets(component, occurrenceId, actionBindings) {
28028
28135
  }
28029
28136
  ];
28030
28137
  }
28031
- if (client?.name === "payment.trade-pay") {
28138
+ if (client?.name === A2UI_PAYMENT_ACTION_NAME) {
28032
28139
  const context = isPlainRecord(client.context) ? client.context : void 0;
28033
28140
  const actionId = typeof context?.actionId === "string" ? context.actionId : "";
28034
28141
  const actionContext = isPlainRecord(context?.actionContext) ? context.actionContext : {};
28035
28142
  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
- }];
28143
+ return [
28144
+ {
28145
+ kind: "payment",
28146
+ targetId: createA2UICardAuthoringTargetId(occurrenceId, "action"),
28147
+ occurrenceId,
28148
+ propertyPath: "action",
28149
+ label: "\u652F\u4ED8",
28150
+ actionId,
28151
+ actionContext,
28152
+ ...binding ? { binding } : {},
28153
+ configured: Boolean(actionId && binding)
28154
+ }
28155
+ ];
28047
28156
  }
28048
28157
  return [agentOnlyAction(occurrenceId, "\u8BE5\u884C\u4E3A\u53EA\u80FD\u901A\u8FC7 Coding Agent \u4FEE\u6539")];
28049
28158
  }
@@ -28258,7 +28367,7 @@ async function rollbackCardFinalize(cwd, rollbackToken) {
28258
28367
  },
28259
28368
  async () => {
28260
28369
  const configPath = import_path22.default.join(cwd, AGENT_CONFIG_PATH);
28261
- const current = await (0, import_promises16.readFile)(configPath);
28370
+ const current = await (0, import_promises15.readFile)(configPath);
28262
28371
  if (checksumBytes(current) !== payload.expectedConfigChecksum) {
28263
28372
  throw new LinkqueCliError(
28264
28373
  "CARD_FINALIZE_CONFLICT",
@@ -28329,7 +28438,7 @@ async function finalizeCardWhileLocked(cwd, draftId, expectedDraftChecksum) {
28329
28438
  await readOptionalJson(import_path22.default.join(directory, "binding-context.json"))
28330
28439
  );
28331
28440
  const configPath = import_path22.default.join(cwd, AGENT_CONFIG_PATH);
28332
- const oldConfigBytes = await (0, import_promises16.readFile)(configPath);
28441
+ const oldConfigBytes = await (0, import_promises15.readFile)(configPath);
28333
28442
  const config2 = parseAgentConfig(
28334
28443
  JSON.parse(oldConfigBytes.toString("utf8"))
28335
28444
  );
@@ -28532,7 +28641,7 @@ async function listDraftDirectories(cwd) {
28532
28641
  const root = import_path22.default.join(cwd, DRAFT_ROOT);
28533
28642
  let entries;
28534
28643
  try {
28535
- entries = await (0, import_promises16.readdir)(root, { withFileTypes: true });
28644
+ entries = await (0, import_promises15.readdir)(root, { withFileTypes: true });
28536
28645
  } catch (cause) {
28537
28646
  if (isNodeError(cause, "ENOENT")) return [];
28538
28647
  throw new LinkqueCliError(
@@ -28571,7 +28680,7 @@ function draftIssue(code, message, recoverable, severity) {
28571
28680
  }
28572
28681
  async function readRequiredJson(file, missingCode = "CARD_DRAFT_INVALID") {
28573
28682
  try {
28574
- const content = await (0, import_promises16.readFile)(file, "utf8");
28683
+ const content = await (0, import_promises15.readFile)(file, "utf8");
28575
28684
  if (Buffer.byteLength(content, "utf8") > DRAFT_FILE_MAX_BYTES) {
28576
28685
  throw new LinkqueCliError(
28577
28686
  "CARD_DRAFT_INVALID",
@@ -28618,7 +28727,7 @@ async function readOptionalJsonObject(file) {
28618
28727
  }
28619
28728
  async function readModifiedAt(file) {
28620
28729
  try {
28621
- return (await (0, import_promises16.stat)(file)).mtime.toISOString();
28730
+ return (await (0, import_promises15.stat)(file)).mtime.toISOString();
28622
28731
  } catch {
28623
28732
  return "";
28624
28733
  }
@@ -28650,7 +28759,7 @@ function parseCardDraftState(value) {
28650
28759
  return { status: state.status, updatedAt: state.updatedAt };
28651
28760
  }
28652
28761
  function draftChecksum(bundle) {
28653
- return (0, import_crypto8.createHash)("sha256").update(stableJsonStringify(bundle)).digest("hex");
28762
+ return (0, import_crypto9.createHash)("sha256").update(stableJsonStringify(bundle)).digest("hex");
28654
28763
  }
28655
28764
  function assertDraftId(draftId) {
28656
28765
  if (!SAFE_DRAFT_ID.test(draftId)) {
@@ -28733,19 +28842,19 @@ function isJsonObject(value) {
28733
28842
  return value !== null && typeof value === "object" && !Array.isArray(value);
28734
28843
  }
28735
28844
  function checksumBytes(value) {
28736
- return (0, import_crypto8.createHash)("sha256").update(value).digest("hex");
28845
+ return (0, import_crypto9.createHash)("sha256").update(value).digest("hex");
28737
28846
  }
28738
28847
  async function atomicWrite(file, content) {
28739
- const temporary = `${file}.${process.pid}.${(0, import_crypto8.randomUUID)()}.tmp`;
28848
+ const temporary = `${file}.${process.pid}.${(0, import_crypto9.randomUUID)()}.tmp`;
28740
28849
  let handle;
28741
28850
  try {
28742
- handle = await (0, import_promises16.open)(temporary, "wx", 384);
28851
+ handle = await (0, import_promises15.open)(temporary, "wx", 384);
28743
28852
  await handle.writeFile(content);
28744
28853
  await handle.sync();
28745
28854
  await handle.close();
28746
28855
  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");
28856
+ await (0, import_promises15.rename)(temporary, file);
28857
+ const directoryHandle = await (0, import_promises15.open)(import_path22.default.dirname(file), "r");
28749
28858
  try {
28750
28859
  await directoryHandle.sync();
28751
28860
  } finally {
@@ -28753,7 +28862,7 @@ async function atomicWrite(file, content) {
28753
28862
  }
28754
28863
  } catch (cause) {
28755
28864
  await handle?.close().catch(() => void 0);
28756
- await (0, import_promises16.unlink)(temporary).catch(() => void 0);
28865
+ await (0, import_promises15.unlink)(temporary).catch(() => void 0);
28757
28866
  throw new LinkqueCliError(
28758
28867
  "CARD_FINALIZE_WRITE_FAILED",
28759
28868
  `\u539F\u5B50\u5199\u5165\u5931\u8D25: ${import_path22.default.basename(file)}`,
@@ -28782,13 +28891,13 @@ function parseRollbackToken(token) {
28782
28891
 
28783
28892
  // src/commands/dev.ts
28784
28893
  var import_child_process4 = require("child_process");
28785
- var import_promises18 = require("fs/promises");
28894
+ var import_promises17 = require("fs/promises");
28786
28895
  var import_net2 = require("net");
28787
28896
  var import_path24 = __toESM(require("path"));
28788
28897
 
28789
28898
  // src/commands/inspector.ts
28790
28899
  var import_module = require("module");
28791
- var import_promises17 = require("fs/promises");
28900
+ var import_promises16 = require("fs/promises");
28792
28901
  var import_os3 = require("os");
28793
28902
  var import_path23 = __toESM(require("path"));
28794
28903
  var import_url = require("url");
@@ -28839,7 +28948,7 @@ var assertManagedRequestFile = async (requestFile) => {
28839
28948
  );
28840
28949
  }
28841
28950
  try {
28842
- const fileStat = await (0, import_promises17.lstat)(requestFile);
28951
+ const fileStat = await (0, import_promises16.lstat)(requestFile);
28843
28952
  if (fileStat.isSymbolicLink() || !fileStat.isFile()) {
28844
28953
  throw new LinkqueCliError(
28845
28954
  "INSPECTOR_PATH_FORBIDDEN",
@@ -28853,8 +28962,8 @@ var assertManagedRequestFile = async (requestFile) => {
28853
28962
  );
28854
28963
  }
28855
28964
  const [directoryRealPath, fileRealPath] = await Promise.all([
28856
- (0, import_promises17.realpath)(managedRequestDirectory()),
28857
- (0, import_promises17.realpath)(requestFile)
28965
+ (0, import_promises16.realpath)(managedRequestDirectory()),
28966
+ (0, import_promises16.realpath)(requestFile)
28858
28967
  ]);
28859
28968
  const relative = import_path23.default.relative(directoryRealPath, fileRealPath);
28860
28969
  if (relative === "" || relative.startsWith(`..${import_path23.default.sep}`) || import_path23.default.isAbsolute(relative)) {
@@ -28882,7 +28991,7 @@ var assertManagedRequestFile = async (requestFile) => {
28882
28991
  var readInspectorRequest = async (requestFile) => {
28883
28992
  await assertManagedRequestFile(requestFile);
28884
28993
  try {
28885
- const content = await (0, import_promises17.readFile)(requestFile, "utf8");
28994
+ const content = await (0, import_promises16.readFile)(requestFile, "utf8");
28886
28995
  if (Buffer.byteLength(content, "utf8") > REQUEST_MAX_BYTES) {
28887
28996
  throw new LinkqueCliError(
28888
28997
  "INSPECTOR_REQUEST_INVALID",
@@ -29085,7 +29194,7 @@ var isPortListening2 = (port) => new Promise((resolve2) => {
29085
29194
  });
29086
29195
  async function removeMatchingState2(statePath, pid) {
29087
29196
  const owned = await readOwnedDevState(statePath);
29088
- if (owned?.pid === pid) await (0, import_promises18.rm)(statePath, { force: true });
29197
+ if (owned?.pid === pid) await (0, import_promises17.rm)(statePath, { force: true });
29089
29198
  }
29090
29199
  async function terminateOwner2(statePath, pid) {
29091
29200
  if (!isProcessAlive(pid)) {
@@ -29125,7 +29234,7 @@ var inspectRecordedDevServer = async (cwd) => {
29125
29234
  }
29126
29235
  const owned = parseOwnedDevState(content);
29127
29236
  if (owned === null) {
29128
- await (0, import_promises18.rm)(statePath, { force: true });
29237
+ await (0, import_promises17.rm)(statePath, { force: true });
29129
29238
  return { state: null, status: stopped2("STALE") };
29130
29239
  }
29131
29240
  const state = owned;
@@ -29354,15 +29463,15 @@ var stopDevServer = async (cwd) => {
29354
29463
  async () => {
29355
29464
  const owned = await readOwnedDevState(statePath);
29356
29465
  if (owned !== null) await terminateOwner2(statePath, owned.pid);
29357
- await (0, import_promises18.rm)(statePath, { force: true });
29466
+ await (0, import_promises17.rm)(statePath, { force: true });
29358
29467
  return { stopped: true };
29359
29468
  }
29360
29469
  );
29361
29470
  };
29362
29471
 
29363
29472
  // src/commands/platformSdk/apply.ts
29364
- var import_crypto9 = require("crypto");
29365
- var import_promises19 = require("fs/promises");
29473
+ var import_crypto10 = require("crypto");
29474
+ var import_promises18 = require("fs/promises");
29366
29475
  var import_path25 = __toESM(require("path"));
29367
29476
  var PLATFORM_SDK_DIR = ".platform-sdk";
29368
29477
  var PLATFORM_SDK_STATE = ".linkque/runtime/platform-sdk-state.json";
@@ -29406,7 +29515,7 @@ var parseManifest = (content) => {
29406
29515
  }
29407
29516
  return raw;
29408
29517
  };
29409
- var sha256 = (content) => `sha256:${(0, import_crypto9.createHash)("sha256").update(content).digest("hex")}`;
29518
+ var sha256 = (content) => `sha256:${(0, import_crypto10.createHash)("sha256").update(content).digest("hex")}`;
29410
29519
  var extractArchive = async (cwd, archive, manifest) => {
29411
29520
  const reader = new ZipReader(new Uint8ArrayReader(archive));
29412
29521
  const extractedFiles = /* @__PURE__ */ new Map();
@@ -29422,12 +29531,12 @@ var extractArchive = async (cwd, archive, manifest) => {
29422
29531
  }
29423
29532
  const destination = import_path25.default.join(cwd, ...entryPath.split("/"));
29424
29533
  if (entry.directory) {
29425
- await (0, import_promises19.mkdir)(destination, { recursive: true });
29534
+ await (0, import_promises18.mkdir)(destination, { recursive: true });
29426
29535
  continue;
29427
29536
  }
29428
29537
  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" });
29538
+ await (0, import_promises18.mkdir)(import_path25.default.dirname(destination), { recursive: true });
29539
+ await (0, import_promises18.writeFile)(destination, bytes, { flag: "wx" });
29431
29540
  extractedFiles.set(entryPath, sha256(bytes));
29432
29541
  }
29433
29542
  } finally {
@@ -29446,7 +29555,7 @@ var rewritePackageJson = async (cwd, manifest) => {
29446
29555
  const packageJsonPath = import_path25.default.join(cwd, "package.json");
29447
29556
  let packageJson;
29448
29557
  try {
29449
- packageJson = JSON.parse(await (0, import_promises19.readFile)(packageJsonPath, "utf8"));
29558
+ packageJson = JSON.parse(await (0, import_promises18.readFile)(packageJsonPath, "utf8"));
29450
29559
  } catch (error) {
29451
29560
  throw new LinkqueCliError(
29452
29561
  "PLATFORM_SDK_APPLY_FAILED",
@@ -29486,8 +29595,8 @@ var rewritePackageJson = async (cwd, manifest) => {
29486
29595
  };
29487
29596
  var applyWhileLocked = async (cwd, manifestPath, archivePath, options) => {
29488
29597
  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))
29598
+ (0, import_promises18.readFile)(import_path25.default.resolve(cwd, manifestPath), "utf8"),
29599
+ (0, import_promises18.readFile)(import_path25.default.resolve(cwd, archivePath))
29491
29600
  ]).catch((error) => {
29492
29601
  throw new LinkqueCliError(
29493
29602
  "PLATFORM_SDK_APPLY_FAILED",
@@ -29502,7 +29611,7 @@ var applyWhileLocked = async (cwd, manifestPath, archivePath, options) => {
29502
29611
  "platform SDK archive identity does not match the manifest"
29503
29612
  );
29504
29613
  }
29505
- await (0, import_promises19.rm)(import_path25.default.join(cwd, PLATFORM_SDK_DIR), { force: true, recursive: true });
29614
+ await (0, import_promises18.rm)(import_path25.default.join(cwd, PLATFORM_SDK_DIR), { force: true, recursive: true });
29506
29615
  try {
29507
29616
  await extractArchive(cwd, archive, manifest);
29508
29617
  await rewritePackageJson(cwd, manifest);
@@ -29513,7 +29622,7 @@ var applyWhileLocked = async (cwd, manifestPath, archivePath, options) => {
29513
29622
  let templateVersion;
29514
29623
  try {
29515
29624
  const artifact = JSON.parse(
29516
- await (0, import_promises19.readFile)(import_path25.default.join(cwd, "template-artifact.json"), "utf8")
29625
+ await (0, import_promises18.readFile)(import_path25.default.join(cwd, "template-artifact.json"), "utf8")
29517
29626
  );
29518
29627
  templateVersion = typeof artifact.templateVersion === "string" ? artifact.templateVersion : void 0;
29519
29628
  } catch {
@@ -29552,6 +29661,187 @@ var applyPlatformSdk = async (cwd, manifestPath, archivePath, options = {}) => w
29552
29661
  () => applyWhileLocked(cwd, manifestPath, archivePath, options)
29553
29662
  );
29554
29663
 
29664
+ // src/commands/unzip.ts
29665
+ var import_promises19 = require("fs/promises");
29666
+ var import_path26 = __toESM(require("path"));
29667
+ var MAX_ZIP_BYTES = 70 * 1024 * 1024;
29668
+ var MAX_FILE_COUNT = 5e3;
29669
+ var MAX_TOTAL_BYTES = 50 * 1024 * 1024;
29670
+ var FileHandleZipReader = class extends Reader {
29671
+ constructor(handle) {
29672
+ super(handle);
29673
+ this.handle = handle;
29674
+ }
29675
+ async init() {
29676
+ this.size = (await this.handle.stat()).size;
29677
+ }
29678
+ async readUint8Array(offset, length) {
29679
+ const buffer = Buffer.allocUnsafe(length);
29680
+ const { bytesRead } = await this.handle.read(buffer, 0, length, offset);
29681
+ return new Uint8Array(buffer.buffer, buffer.byteOffset, bytesRead);
29682
+ }
29683
+ };
29684
+ var SourceArchiveExtractor = class {
29685
+ sourceChecksum = new SourceChecksumWriter();
29686
+ inputPath;
29687
+ outputPath;
29688
+ totalBytes = 0;
29689
+ constructor(cwd, input, output) {
29690
+ if (!input) this.invalid("unzip input path must not be empty");
29691
+ if (!output) this.invalid("unzip output path must not be empty");
29692
+ this.inputPath = import_path26.default.resolve(cwd, input);
29693
+ this.outputPath = import_path26.default.resolve(cwd, output);
29694
+ }
29695
+ async extract() {
29696
+ await this.assertInputs();
29697
+ const handle = await (0, import_promises19.open)(this.inputPath, "r").catch((error) => {
29698
+ throw new LinkqueCliError(
29699
+ "UNZIP_INPUT_INVALID",
29700
+ "unzip input archive could not be opened",
29701
+ { cause: error }
29702
+ );
29703
+ });
29704
+ const reader = new ZipReader(new FileHandleZipReader(handle), {
29705
+ useWebWorkers: false
29706
+ });
29707
+ try {
29708
+ const files = await this.readEntries(reader);
29709
+ for (const file of files) await this.extractFile(file);
29710
+ return {
29711
+ sourceChecksum: this.sourceChecksum.digest().checksum,
29712
+ fileCount: files.length,
29713
+ totalBytes: this.totalBytes
29714
+ };
29715
+ } catch (error) {
29716
+ if (error instanceof LinkqueCliError) throw error;
29717
+ throw new LinkqueCliError(
29718
+ "UNZIP_INPUT_INVALID",
29719
+ "unzip archive is invalid",
29720
+ { cause: error instanceof Error ? error : void 0 }
29721
+ );
29722
+ } finally {
29723
+ await reader.close().catch(() => void 0);
29724
+ await handle.close().catch(() => void 0);
29725
+ }
29726
+ }
29727
+ async assertInputs() {
29728
+ if (this.inputPath === this.outputPath) {
29729
+ this.invalid("unzip input and output must be different paths");
29730
+ }
29731
+ let inputStat;
29732
+ try {
29733
+ inputStat = await (0, import_promises19.stat)(this.inputPath);
29734
+ } catch (error) {
29735
+ throw new LinkqueCliError(
29736
+ "UNZIP_INPUT_INVALID",
29737
+ "unzip input archive does not exist",
29738
+ { cause: error }
29739
+ );
29740
+ }
29741
+ if (!inputStat.isFile()) this.invalid("unzip input must be a file");
29742
+ if (inputStat.size <= 0 || inputStat.size > MAX_ZIP_BYTES) {
29743
+ this.invalid(`unzip input archive exceeds ${MAX_ZIP_BYTES} bytes`);
29744
+ }
29745
+ let outputStat;
29746
+ try {
29747
+ outputStat = await (0, import_promises19.lstat)(this.outputPath);
29748
+ } catch (error) {
29749
+ throw new LinkqueCliError(
29750
+ "UNZIP_INPUT_INVALID",
29751
+ "unzip output directory does not exist",
29752
+ { cause: error }
29753
+ );
29754
+ }
29755
+ if (outputStat.isSymbolicLink() || !outputStat.isDirectory()) {
29756
+ this.invalid("unzip output must be an existing directory");
29757
+ }
29758
+ if ((await (0, import_promises19.readdir)(this.outputPath)).length > 0) {
29759
+ this.invalid("unzip output directory must be empty");
29760
+ }
29761
+ }
29762
+ async readEntries(reader) {
29763
+ const seen = /* @__PURE__ */ new Set();
29764
+ const files = [];
29765
+ let totalBytes = 0;
29766
+ for (const entry of await reader.getEntries({
29767
+ filenameValidation: "tolerant"
29768
+ })) {
29769
+ const filename = this.normalizeEntryPath(entry.filename);
29770
+ if (seen.has(filename))
29771
+ this.invalid(`unzip archive contains duplicate path: ${filename}`);
29772
+ seen.add(filename);
29773
+ if (entry.directory) continue;
29774
+ const size = entry.uncompressedSize;
29775
+ if (!Number.isSafeInteger(size) || size < 0) {
29776
+ this.invalid(`unzip entry has invalid size: ${filename}`);
29777
+ }
29778
+ totalBytes += size;
29779
+ if (files.length >= MAX_FILE_COUNT || totalBytes > MAX_TOTAL_BYTES) {
29780
+ this.invalid("unzip archive exceeds declared file or size limit");
29781
+ }
29782
+ files.push({ entry, filename, size });
29783
+ }
29784
+ this.totalBytes = totalBytes;
29785
+ return files.toSorted(
29786
+ (left, right) => left.filename < right.filename ? -1 : left.filename > right.filename ? 1 : 0
29787
+ );
29788
+ }
29789
+ normalizeEntryPath(filename) {
29790
+ const normalized = filename.replace(/\/$/u, "");
29791
+ 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 === "..")) {
29792
+ this.invalid(`unzip archive contains an unsafe path: ${filename}`);
29793
+ }
29794
+ return normalized;
29795
+ }
29796
+ async extractFile(file) {
29797
+ const destination = this.resolveDestination(file.filename);
29798
+ await (0, import_promises19.mkdir)(import_path26.default.dirname(destination), { recursive: true });
29799
+ this.sourceChecksum.appendFileHeader(file.filename, file.size);
29800
+ const handle = await (0, import_promises19.open)(destination, "wx");
29801
+ let written = 0;
29802
+ try {
29803
+ await file.entry.getData(
29804
+ new WritableStream({
29805
+ write: async (chunk) => {
29806
+ const content = Buffer.from(
29807
+ chunk.buffer,
29808
+ chunk.byteOffset,
29809
+ chunk.byteLength
29810
+ );
29811
+ await handle.writeFile(content);
29812
+ written += content.byteLength;
29813
+ this.sourceChecksum.appendFileContent(content);
29814
+ }
29815
+ }),
29816
+ { useWebWorkers: false }
29817
+ );
29818
+ if (written !== file.size)
29819
+ this.invalid(`unzip entry size mismatch: ${file.filename}`);
29820
+ } catch (error) {
29821
+ if (error instanceof LinkqueCliError) throw error;
29822
+ throw new LinkqueCliError(
29823
+ "UNZIP_FAILED",
29824
+ "unzip archive extraction failed",
29825
+ { cause: error instanceof Error ? error : void 0 }
29826
+ );
29827
+ } finally {
29828
+ await handle.close().catch(() => void 0);
29829
+ }
29830
+ }
29831
+ resolveDestination(filename) {
29832
+ const destination = import_path26.default.resolve(this.outputPath, ...filename.split("/"));
29833
+ const relative = import_path26.default.relative(this.outputPath, destination);
29834
+ if (relative === "" || relative.startsWith("..") || import_path26.default.isAbsolute(relative)) {
29835
+ this.invalid(`unzip archive escapes output directory: ${filename}`);
29836
+ }
29837
+ return destination;
29838
+ }
29839
+ invalid(message) {
29840
+ throw new LinkqueCliError("UNZIP_INPUT_INVALID", message);
29841
+ }
29842
+ };
29843
+ var unzipArchive = (cwd, input, output) => new SourceArchiveExtractor(cwd, input, output).extract();
29844
+
29555
29845
  // src/commands/registry.ts
29556
29846
  var parsePort = (value) => {
29557
29847
  const port = Number(value);
@@ -29582,6 +29872,12 @@ var parseRequestFile = (value) => {
29582
29872
  }
29583
29873
  return value;
29584
29874
  };
29875
+ var parseUnzipPath = (value) => {
29876
+ if (value === "") {
29877
+ throw new InvalidArgumentError("unzip path must not be empty");
29878
+ }
29879
+ return value;
29880
+ };
29585
29881
  var parseOnly = (value) => value.split(",").map((item) => item.trim()).filter(Boolean);
29586
29882
  var parseEnvList = (value, previous) => [
29587
29883
  ...Array.isArray(previous) ? previous : [],
@@ -29975,6 +30271,34 @@ var buildSnapshotCommand = {
29975
30271
  excludePlatformSdk: options.excludePlatformSdk === true || process.env.LINKQUE_SNAPSHOT_EXCLUDE_PLATFORM_SDK === "1"
29976
30272
  })
29977
30273
  };
30274
+ var unzipCommand = {
30275
+ name: "unzip",
30276
+ description: "extract a manager-staged source ZIP into an empty directory",
30277
+ options: [
30278
+ {
30279
+ flags: "--input <archivePath>",
30280
+ description: "manager-staged ZIP archive path",
30281
+ key: "input",
30282
+ parse: parseUnzipPath
30283
+ },
30284
+ {
30285
+ flags: "--output <outputPath>",
30286
+ description: "existing empty output directory path",
30287
+ key: "output",
30288
+ parse: parseUnzipPath
30289
+ }
30290
+ ],
30291
+ summarize: ({ fileCount, totalBytes }) => `Archive extracted (${fileCount} files, ${totalBytes} bytes).
30292
+ `,
30293
+ run: (cwd, options) => {
30294
+ if (options.input === void 0 || options.output === void 0) {
30295
+ throw new InvalidArgumentError(
30296
+ "required options '--input' and '--output' not specified"
30297
+ );
30298
+ }
30299
+ return unzipArchive(cwd, options.input, options.output);
30300
+ }
30301
+ };
29978
30302
  var platformSdkApplyCommand = {
29979
30303
  name: "platform-sdk.apply",
29980
30304
  description: "validate and apply a platform SDK bundle to the workspace",
@@ -30138,6 +30462,7 @@ var COMMANDS = [
30138
30462
  agentdevStop,
30139
30463
  buildDistCommand,
30140
30464
  buildSnapshotCommand,
30465
+ unzipCommand,
30141
30466
  platformSdkApplyCommand,
30142
30467
  agentBuildCommand,
30143
30468
  agentDeployCommand,