linkque-cli-v2 1.6.19 → 1.6.21

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 path26 = require("node:path");
1199
+ var path28 = require("node:path");
1200
1200
  var fs2 = require("node:fs");
1201
1201
  var process2 = require("node:process");
1202
1202
  var { Argument: Argument2, humanReadableArgName } = require_argument();
@@ -2209,9 +2209,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2209
2209
  let launchWithNode = false;
2210
2210
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
2211
2211
  function findFile(baseDir, baseName) {
2212
- const localBin = path26.resolve(baseDir, baseName);
2212
+ const localBin = path28.resolve(baseDir, baseName);
2213
2213
  if (fs2.existsSync(localBin)) return localBin;
2214
- if (sourceExt.includes(path26.extname(baseName))) return void 0;
2214
+ if (sourceExt.includes(path28.extname(baseName))) return void 0;
2215
2215
  const foundExt = sourceExt.find(
2216
2216
  (ext) => fs2.existsSync(`${localBin}${ext}`)
2217
2217
  );
@@ -2229,17 +2229,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
2229
2229
  } catch {
2230
2230
  resolvedScriptPath = this._scriptPath;
2231
2231
  }
2232
- executableDir = path26.resolve(
2233
- path26.dirname(resolvedScriptPath),
2232
+ executableDir = path28.resolve(
2233
+ path28.dirname(resolvedScriptPath),
2234
2234
  executableDir
2235
2235
  );
2236
2236
  }
2237
2237
  if (executableDir) {
2238
2238
  let localFile = findFile(executableDir, executableFile);
2239
2239
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
2240
- const legacyName = path26.basename(
2240
+ const legacyName = path28.basename(
2241
2241
  this._scriptPath,
2242
- path26.extname(this._scriptPath)
2242
+ path28.extname(this._scriptPath)
2243
2243
  );
2244
2244
  if (legacyName !== this._name) {
2245
2245
  localFile = findFile(
@@ -2250,7 +2250,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2250
2250
  }
2251
2251
  executableFile = localFile || executableFile;
2252
2252
  }
2253
- launchWithNode = sourceExt.includes(path26.extname(executableFile));
2253
+ launchWithNode = sourceExt.includes(path28.extname(executableFile));
2254
2254
  let proc;
2255
2255
  if (process2.platform !== "win32") {
2256
2256
  if (launchWithNode) {
@@ -3165,7 +3165,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3165
3165
  * @return {Command}
3166
3166
  */
3167
3167
  nameFromFilename(filename) {
3168
- this._name = path26.basename(filename, path26.extname(filename));
3168
+ this._name = path28.basename(filename, path28.extname(filename));
3169
3169
  return this;
3170
3170
  }
3171
3171
  /**
@@ -3179,9 +3179,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
3179
3179
  * @param {string} [path]
3180
3180
  * @return {(string|null|Command)}
3181
3181
  */
3182
- executableDir(path27) {
3183
- if (path27 === void 0) return this._executableDir;
3184
- this._executableDir = path27;
3182
+ executableDir(path29) {
3183
+ if (path29 === void 0) return this._executableDir;
3184
+ this._executableDir = path29;
3185
3185
  return this;
3186
3186
  }
3187
3187
  /**
@@ -3836,11 +3836,11 @@ var require_codegen = __commonJS({
3836
3836
  const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
3837
3837
  return `${varKind} ${this.name}${rhs};` + _n2;
3838
3838
  }
3839
- optimizeNames(names, constants) {
3839
+ optimizeNames(names, constants2) {
3840
3840
  if (!names[this.name.str])
3841
3841
  return;
3842
3842
  if (this.rhs)
3843
- this.rhs = optimizeExpr(this.rhs, names, constants);
3843
+ this.rhs = optimizeExpr(this.rhs, names, constants2);
3844
3844
  return this;
3845
3845
  }
3846
3846
  get names() {
@@ -3857,10 +3857,10 @@ var require_codegen = __commonJS({
3857
3857
  render({ _n: _n2 }) {
3858
3858
  return `${this.lhs} = ${this.rhs};` + _n2;
3859
3859
  }
3860
- optimizeNames(names, constants) {
3860
+ optimizeNames(names, constants2) {
3861
3861
  if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects)
3862
3862
  return;
3863
- this.rhs = optimizeExpr(this.rhs, names, constants);
3863
+ this.rhs = optimizeExpr(this.rhs, names, constants2);
3864
3864
  return this;
3865
3865
  }
3866
3866
  get names() {
@@ -3921,8 +3921,8 @@ var require_codegen = __commonJS({
3921
3921
  optimizeNodes() {
3922
3922
  return `${this.code}` ? this : void 0;
3923
3923
  }
3924
- optimizeNames(names, constants) {
3925
- this.code = optimizeExpr(this.code, names, constants);
3924
+ optimizeNames(names, constants2) {
3925
+ this.code = optimizeExpr(this.code, names, constants2);
3926
3926
  return this;
3927
3927
  }
3928
3928
  get names() {
@@ -3951,12 +3951,12 @@ var require_codegen = __commonJS({
3951
3951
  }
3952
3952
  return nodes.length > 0 ? this : void 0;
3953
3953
  }
3954
- optimizeNames(names, constants) {
3954
+ optimizeNames(names, constants2) {
3955
3955
  const { nodes } = this;
3956
3956
  let i = nodes.length;
3957
3957
  while (i--) {
3958
3958
  const n3 = nodes[i];
3959
- if (n3.optimizeNames(names, constants))
3959
+ if (n3.optimizeNames(names, constants2))
3960
3960
  continue;
3961
3961
  subtractNames(names, n3.names);
3962
3962
  nodes.splice(i, 1);
@@ -4009,12 +4009,12 @@ var require_codegen = __commonJS({
4009
4009
  return void 0;
4010
4010
  return this;
4011
4011
  }
4012
- optimizeNames(names, constants) {
4012
+ optimizeNames(names, constants2) {
4013
4013
  var _a;
4014
- this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants);
4015
- if (!(super.optimizeNames(names, constants) || this.else))
4014
+ this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants2);
4015
+ if (!(super.optimizeNames(names, constants2) || this.else))
4016
4016
  return;
4017
- this.condition = optimizeExpr(this.condition, names, constants);
4017
+ this.condition = optimizeExpr(this.condition, names, constants2);
4018
4018
  return this;
4019
4019
  }
4020
4020
  get names() {
@@ -4037,10 +4037,10 @@ var require_codegen = __commonJS({
4037
4037
  render(opts) {
4038
4038
  return `for(${this.iteration})` + super.render(opts);
4039
4039
  }
4040
- optimizeNames(names, constants) {
4041
- if (!super.optimizeNames(names, constants))
4040
+ optimizeNames(names, constants2) {
4041
+ if (!super.optimizeNames(names, constants2))
4042
4042
  return;
4043
- this.iteration = optimizeExpr(this.iteration, names, constants);
4043
+ this.iteration = optimizeExpr(this.iteration, names, constants2);
4044
4044
  return this;
4045
4045
  }
4046
4046
  get names() {
@@ -4076,10 +4076,10 @@ var require_codegen = __commonJS({
4076
4076
  render(opts) {
4077
4077
  return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
4078
4078
  }
4079
- optimizeNames(names, constants) {
4080
- if (!super.optimizeNames(names, constants))
4079
+ optimizeNames(names, constants2) {
4080
+ if (!super.optimizeNames(names, constants2))
4081
4081
  return;
4082
- this.iterable = optimizeExpr(this.iterable, names, constants);
4082
+ this.iterable = optimizeExpr(this.iterable, names, constants2);
4083
4083
  return this;
4084
4084
  }
4085
4085
  get names() {
@@ -4121,11 +4121,11 @@ var require_codegen = __commonJS({
4121
4121
  (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
4122
4122
  return this;
4123
4123
  }
4124
- optimizeNames(names, constants) {
4124
+ optimizeNames(names, constants2) {
4125
4125
  var _a, _b;
4126
- super.optimizeNames(names, constants);
4127
- (_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants);
4128
- (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants);
4126
+ super.optimizeNames(names, constants2);
4127
+ (_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants2);
4128
+ (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants2);
4129
4129
  return this;
4130
4130
  }
4131
4131
  get names() {
@@ -4426,7 +4426,7 @@ var require_codegen = __commonJS({
4426
4426
  function addExprNames(names, from) {
4427
4427
  return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
4428
4428
  }
4429
- function optimizeExpr(expr, names, constants) {
4429
+ function optimizeExpr(expr, names, constants2) {
4430
4430
  if (expr instanceof code_1.Name)
4431
4431
  return replaceName(expr);
4432
4432
  if (!canOptimize(expr))
@@ -4441,14 +4441,14 @@ var require_codegen = __commonJS({
4441
4441
  return items;
4442
4442
  }, []));
4443
4443
  function replaceName(n3) {
4444
- const c = constants[n3.str];
4444
+ const c = constants2[n3.str];
4445
4445
  if (c === void 0 || names[n3.str] !== 1)
4446
4446
  return n3;
4447
4447
  delete names[n3.str];
4448
4448
  return c;
4449
4449
  }
4450
4450
  function canOptimize(e3) {
4451
- return e3 instanceof code_1._Code && e3._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants[c.str] !== void 0);
4451
+ return e3 instanceof code_1._Code && e3._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants2[c.str] !== void 0);
4452
4452
  }
4453
4453
  }
4454
4454
  function subtractNames(names, from) {
@@ -6688,8 +6688,8 @@ var require_utils = __commonJS({
6688
6688
  }
6689
6689
  return ind;
6690
6690
  }
6691
- function removeDotSegments(path26) {
6692
- let input = path26;
6691
+ function removeDotSegments(path28) {
6692
+ let input = path28;
6693
6693
  const output = [];
6694
6694
  let nextSlash = -1;
6695
6695
  let len = 0;
@@ -6763,11 +6763,11 @@ var require_utils = __commonJS({
6763
6763
  }
6764
6764
  return output.join("");
6765
6765
  }
6766
- function removeDotSegmentsRelative(path26) {
6767
- if (path26 === "" || path26[0] === "/") {
6768
- return removeDotSegments(path26);
6766
+ function removeDotSegmentsRelative(path28) {
6767
+ if (path28 === "" || path28[0] === "/") {
6768
+ return removeDotSegments(path28);
6769
6769
  }
6770
- const segments = path26.split("/");
6770
+ const segments = path28.split("/");
6771
6771
  const last = segments.length - 1;
6772
6772
  const output = [];
6773
6773
  let trailingDirectory = false;
@@ -7130,8 +7130,8 @@ var require_schemes = __commonJS({
7130
7130
  }
7131
7131
  if (wsComponent.resourceName) {
7132
7132
  const queryIndex = wsComponent.resourceName.indexOf("?");
7133
- const path26 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
7134
- wsComponent.path = path26 && path26 !== "/" ? path26 : void 0;
7133
+ const path28 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
7134
+ wsComponent.path = path28 && path28 !== "/" ? path28 : void 0;
7135
7135
  wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
7136
7136
  wsComponent.resourceName = void 0;
7137
7137
  }
@@ -12848,14 +12848,14 @@ var require_util2 = __commonJS({
12848
12848
  }
12849
12849
  const port = url2.port != null ? url2.port : url2.protocol === "https:" ? 443 : 80;
12850
12850
  let origin = url2.origin != null ? url2.origin : `${url2.protocol || ""}//${url2.hostname || ""}:${port}`;
12851
- let path26 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
12851
+ let path28 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
12852
12852
  if (origin[origin.length - 1] === "/") {
12853
12853
  origin = origin.slice(0, origin.length - 1);
12854
12854
  }
12855
- if (path26 && path26[0] !== "/") {
12856
- path26 = `/${path26}`;
12855
+ if (path28 && path28[0] !== "/") {
12856
+ path28 = `/${path28}`;
12857
12857
  }
12858
- return new URL(`${origin}${path26}`);
12858
+ return new URL(`${origin}${path28}`);
12859
12859
  }
12860
12860
  if (!isHttpOrHttpsPrefixed(url2.origin || url2.protocol)) {
12861
12861
  throw new InvalidArgumentError2("Invalid URL protocol: the URL must start with `http:` or `https:`.");
@@ -13306,39 +13306,39 @@ var require_diagnostics = __commonJS({
13306
13306
  });
13307
13307
  diagnosticsChannel.channel("undici:client:sendHeaders").subscribe((evt) => {
13308
13308
  const {
13309
- request: { method, path: path26, origin }
13309
+ request: { method, path: path28, origin }
13310
13310
  } = evt;
13311
- debuglog("sending request to %s %s/%s", method, origin, path26);
13311
+ debuglog("sending request to %s %s/%s", method, origin, path28);
13312
13312
  });
13313
13313
  diagnosticsChannel.channel("undici:request:headers").subscribe((evt) => {
13314
13314
  const {
13315
- request: { method, path: path26, origin },
13315
+ request: { method, path: path28, origin },
13316
13316
  response: { statusCode }
13317
13317
  } = evt;
13318
13318
  debuglog(
13319
13319
  "received response to %s %s/%s - HTTP %d",
13320
13320
  method,
13321
13321
  origin,
13322
- path26,
13322
+ path28,
13323
13323
  statusCode
13324
13324
  );
13325
13325
  });
13326
13326
  diagnosticsChannel.channel("undici:request:trailers").subscribe((evt) => {
13327
13327
  const {
13328
- request: { method, path: path26, origin }
13328
+ request: { method, path: path28, origin }
13329
13329
  } = evt;
13330
- debuglog("trailers received from %s %s/%s", method, origin, path26);
13330
+ debuglog("trailers received from %s %s/%s", method, origin, path28);
13331
13331
  });
13332
13332
  diagnosticsChannel.channel("undici:request:error").subscribe((evt) => {
13333
13333
  const {
13334
- request: { method, path: path26, origin },
13334
+ request: { method, path: path28, origin },
13335
13335
  error: error2
13336
13336
  } = evt;
13337
13337
  debuglog(
13338
13338
  "request to %s %s/%s errored - %s",
13339
13339
  method,
13340
13340
  origin,
13341
- path26,
13341
+ path28,
13342
13342
  error2.message
13343
13343
  );
13344
13344
  });
@@ -13387,9 +13387,9 @@ var require_diagnostics = __commonJS({
13387
13387
  });
13388
13388
  diagnosticsChannel.channel("undici:client:sendHeaders").subscribe((evt) => {
13389
13389
  const {
13390
- request: { method, path: path26, origin }
13390
+ request: { method, path: path28, origin }
13391
13391
  } = evt;
13392
- debuglog("sending request to %s %s/%s", method, origin, path26);
13392
+ debuglog("sending request to %s %s/%s", method, origin, path28);
13393
13393
  });
13394
13394
  }
13395
13395
  diagnosticsChannel.channel("undici:websocket:open").subscribe((evt) => {
@@ -13452,7 +13452,7 @@ var require_request = __commonJS({
13452
13452
  var kHandler = Symbol("handler");
13453
13453
  var Request2 = class {
13454
13454
  constructor(origin, {
13455
- path: path26,
13455
+ path: path28,
13456
13456
  method,
13457
13457
  body,
13458
13458
  headers,
@@ -13467,11 +13467,11 @@ var require_request = __commonJS({
13467
13467
  expectContinue,
13468
13468
  servername
13469
13469
  }, handler) {
13470
- if (typeof path26 !== "string") {
13470
+ if (typeof path28 !== "string") {
13471
13471
  throw new InvalidArgumentError2("path must be a string");
13472
- } else if (path26[0] !== "/" && !(path26.startsWith("http://") || path26.startsWith("https://")) && method !== "CONNECT") {
13472
+ } else if (path28[0] !== "/" && !(path28.startsWith("http://") || path28.startsWith("https://")) && method !== "CONNECT") {
13473
13473
  throw new InvalidArgumentError2("path must be an absolute URL or start with a slash");
13474
- } else if (invalidPathRegex.test(path26)) {
13474
+ } else if (invalidPathRegex.test(path28)) {
13475
13475
  throw new InvalidArgumentError2("invalid request path");
13476
13476
  }
13477
13477
  if (typeof method !== "string") {
@@ -13534,7 +13534,7 @@ var require_request = __commonJS({
13534
13534
  this.completed = false;
13535
13535
  this.aborted = false;
13536
13536
  this.upgrade = upgrade || null;
13537
- this.path = query ? buildURL(path26, query) : path26;
13537
+ this.path = query ? buildURL(path28, query) : path28;
13538
13538
  this.origin = origin;
13539
13539
  this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
13540
13540
  this.blocking = blocking == null ? false : blocking;
@@ -17205,7 +17205,7 @@ var require_client_h1 = __commonJS({
17205
17205
  kResume,
17206
17206
  kHTTPContext
17207
17207
  } = require_symbols();
17208
- var constants = require_constants2();
17208
+ var constants2 = require_constants2();
17209
17209
  var EMPTY_BUF = Buffer.alloc(0);
17210
17210
  var FastBuffer = Buffer[Symbol.species];
17211
17211
  var addListener = util2.addListener;
@@ -17275,7 +17275,7 @@ var require_client_h1 = __commonJS({
17275
17275
  constructor(client, socket, { exports: exports3 }) {
17276
17276
  assert2(Number.isFinite(client[kMaxHeadersSize]) && client[kMaxHeadersSize] > 0);
17277
17277
  this.llhttp = exports3;
17278
- this.ptr = this.llhttp.llhttp_alloc(constants.TYPE.RESPONSE);
17278
+ this.ptr = this.llhttp.llhttp_alloc(constants2.TYPE.RESPONSE);
17279
17279
  this.client = client;
17280
17280
  this.socket = socket;
17281
17281
  this.timeout = null;
@@ -17367,19 +17367,19 @@ var require_client_h1 = __commonJS({
17367
17367
  currentBufferRef = null;
17368
17368
  }
17369
17369
  const offset = llhttp.llhttp_get_error_pos(this.ptr) - currentBufferPtr;
17370
- if (ret === constants.ERROR.PAUSED_UPGRADE) {
17370
+ if (ret === constants2.ERROR.PAUSED_UPGRADE) {
17371
17371
  this.onUpgrade(data.slice(offset));
17372
- } else if (ret === constants.ERROR.PAUSED) {
17372
+ } else if (ret === constants2.ERROR.PAUSED) {
17373
17373
  this.paused = true;
17374
17374
  socket.unshift(data.slice(offset));
17375
- } else if (ret !== constants.ERROR.OK) {
17375
+ } else if (ret !== constants2.ERROR.OK) {
17376
17376
  const ptr = llhttp.llhttp_get_error_reason(this.ptr);
17377
17377
  let message = "";
17378
17378
  if (ptr) {
17379
17379
  const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0);
17380
17380
  message = "Response does not match the HTTP/1.1 protocol (" + Buffer.from(llhttp.memory.buffer, ptr, len).toString() + ")";
17381
17381
  }
17382
- throw new HTTPParserError(message, constants.ERROR[ret], data.slice(offset));
17382
+ throw new HTTPParserError(message, constants2.ERROR[ret], data.slice(offset));
17383
17383
  }
17384
17384
  } catch (err) {
17385
17385
  util2.destroy(socket, err);
@@ -17554,7 +17554,7 @@ var require_client_h1 = __commonJS({
17554
17554
  socket[kBlocking] = false;
17555
17555
  client[kResume]();
17556
17556
  }
17557
- return pause ? constants.ERROR.PAUSED : 0;
17557
+ return pause ? constants2.ERROR.PAUSED : 0;
17558
17558
  }
17559
17559
  onBody(buf) {
17560
17560
  const { client, socket, statusCode, maxResponseSize } = this;
@@ -17576,7 +17576,7 @@ var require_client_h1 = __commonJS({
17576
17576
  }
17577
17577
  this.bytesRead += buf.length;
17578
17578
  if (request2.onData(buf) === false) {
17579
- return constants.ERROR.PAUSED;
17579
+ return constants2.ERROR.PAUSED;
17580
17580
  }
17581
17581
  }
17582
17582
  onMessageComplete() {
@@ -17611,13 +17611,13 @@ var require_client_h1 = __commonJS({
17611
17611
  if (socket[kWriting]) {
17612
17612
  assert2.strictEqual(client[kRunning], 0);
17613
17613
  util2.destroy(socket, new InformationalError("reset"));
17614
- return constants.ERROR.PAUSED;
17614
+ return constants2.ERROR.PAUSED;
17615
17615
  } else if (!shouldKeepAlive) {
17616
17616
  util2.destroy(socket, new InformationalError("reset"));
17617
- return constants.ERROR.PAUSED;
17617
+ return constants2.ERROR.PAUSED;
17618
17618
  } else if (socket[kReset] && client[kRunning] === 0) {
17619
17619
  util2.destroy(socket, new InformationalError("reset"));
17620
- return constants.ERROR.PAUSED;
17620
+ return constants2.ERROR.PAUSED;
17621
17621
  } else if (client[kPipelining] == null || client[kPipelining] === 1) {
17622
17622
  setImmediate(() => client[kResume]());
17623
17623
  } else {
@@ -17777,7 +17777,7 @@ var require_client_h1 = __commonJS({
17777
17777
  return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
17778
17778
  }
17779
17779
  function writeH1(client, request2) {
17780
- const { method, path: path26, host, upgrade, blocking, reset } = request2;
17780
+ const { method, path: path28, host, upgrade, blocking, reset } = request2;
17781
17781
  let { body, headers, contentLength } = request2;
17782
17782
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
17783
17783
  if (util2.isFormDataLike(body)) {
@@ -17843,7 +17843,7 @@ var require_client_h1 = __commonJS({
17843
17843
  if (blocking) {
17844
17844
  socket[kBlocking] = true;
17845
17845
  }
17846
- let header = `${method} ${path26} HTTP/1.1\r
17846
+ let header = `${method} ${path28} HTTP/1.1\r
17847
17847
  `;
17848
17848
  if (typeof host === "string") {
17849
17849
  header += `host: ${host}\r
@@ -18340,7 +18340,7 @@ var require_client_h2 = __commonJS({
18340
18340
  }
18341
18341
  function writeH2(client, request2) {
18342
18342
  const session = client[kHTTP2Session];
18343
- const { body, method, path: path26, host, upgrade, expectContinue, signal, headers: reqHeaders } = request2;
18343
+ const { body, method, path: path28, host, upgrade, expectContinue, signal, headers: reqHeaders } = request2;
18344
18344
  if (upgrade) {
18345
18345
  util2.errorRequest(client, request2, new Error("Upgrade not supported for H2"));
18346
18346
  return false;
@@ -18402,7 +18402,7 @@ var require_client_h2 = __commonJS({
18402
18402
  });
18403
18403
  return true;
18404
18404
  }
18405
- headers[HTTP2_HEADER_PATH] = path26;
18405
+ headers[HTTP2_HEADER_PATH] = path28;
18406
18406
  headers[HTTP2_HEADER_SCHEME] = "https";
18407
18407
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
18408
18408
  if (body && typeof body.read === "function") {
@@ -18746,9 +18746,9 @@ var require_redirect_handler = __commonJS({
18746
18746
  return this.handler.onHeaders(statusCode, headers, resume, statusText);
18747
18747
  }
18748
18748
  const { origin, pathname, search: search3 } = util2.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
18749
- const path26 = search3 ? `${pathname}${search3}` : pathname;
18749
+ const path28 = search3 ? `${pathname}${search3}` : pathname;
18750
18750
  this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
18751
- this.opts.path = path26;
18751
+ this.opts.path = path28;
18752
18752
  this.opts.origin = origin;
18753
18753
  this.opts.maxRedirections = 0;
18754
18754
  this.opts.query = null;
@@ -21793,20 +21793,20 @@ var require_mock_utils = __commonJS({
21793
21793
  }
21794
21794
  return true;
21795
21795
  }
21796
- function safeUrl(path26) {
21797
- if (typeof path26 !== "string") {
21798
- return path26;
21796
+ function safeUrl(path28) {
21797
+ if (typeof path28 !== "string") {
21798
+ return path28;
21799
21799
  }
21800
- const pathSegments = path26.split("?");
21800
+ const pathSegments = path28.split("?");
21801
21801
  if (pathSegments.length !== 2) {
21802
- return path26;
21802
+ return path28;
21803
21803
  }
21804
21804
  const qp = new URLSearchParams(pathSegments.pop());
21805
21805
  qp.sort();
21806
21806
  return [...pathSegments, qp.toString()].join("?");
21807
21807
  }
21808
- function matchKey(mockDispatch2, { path: path26, method, body, headers }) {
21809
- const pathMatch = matchValue(mockDispatch2.path, path26);
21808
+ function matchKey(mockDispatch2, { path: path28, method, body, headers }) {
21809
+ const pathMatch = matchValue(mockDispatch2.path, path28);
21810
21810
  const methodMatch = matchValue(mockDispatch2.method, method);
21811
21811
  const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
21812
21812
  const headersMatch = matchHeaders(mockDispatch2, headers);
@@ -21824,7 +21824,7 @@ var require_mock_utils = __commonJS({
21824
21824
  function getMockDispatch(mockDispatches, key) {
21825
21825
  const basePath = key.query ? buildURL(key.path, key.query) : key.path;
21826
21826
  const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
21827
- let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path26 }) => matchValue(safeUrl(path26), resolvedPath));
21827
+ let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path28 }) => matchValue(safeUrl(path28), resolvedPath));
21828
21828
  if (matchedMockDispatches.length === 0) {
21829
21829
  throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
21830
21830
  }
@@ -21862,9 +21862,9 @@ var require_mock_utils = __commonJS({
21862
21862
  }
21863
21863
  }
21864
21864
  function buildKey(opts) {
21865
- const { path: path26, method, body, headers, query } = opts;
21865
+ const { path: path28, method, body, headers, query } = opts;
21866
21866
  return {
21867
- path: path26,
21867
+ path: path28,
21868
21868
  method,
21869
21869
  body,
21870
21870
  headers,
@@ -22327,10 +22327,10 @@ var require_pending_interceptors_formatter = __commonJS({
22327
22327
  }
22328
22328
  format(pendingInterceptors) {
22329
22329
  const withPrettyHeaders = pendingInterceptors.map(
22330
- ({ method, path: path26, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
22330
+ ({ method, path: path28, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
22331
22331
  Method: method,
22332
22332
  Origin: origin,
22333
- Path: path26,
22333
+ Path: path28,
22334
22334
  "Status code": statusCode,
22335
22335
  Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
22336
22336
  Invocations: timesInvoked,
@@ -26915,9 +26915,9 @@ var require_util7 = __commonJS({
26915
26915
  }
26916
26916
  }
26917
26917
  }
26918
- function validateCookiePath(path26) {
26919
- for (let i = 0; i < path26.length; ++i) {
26920
- const code = path26.charCodeAt(i);
26918
+ function validateCookiePath(path28) {
26919
+ for (let i = 0; i < path28.length; ++i) {
26920
+ const code = path28.charCodeAt(i);
26921
26921
  if (code < 32 || // exclude CTLs (0-31)
26922
26922
  code === 127 || // DEL
26923
26923
  code === 59) {
@@ -29504,11 +29504,11 @@ var require_undici = __commonJS({
29504
29504
  if (typeof opts.path !== "string") {
29505
29505
  throw new InvalidArgumentError2("invalid opts.path");
29506
29506
  }
29507
- let path26 = opts.path;
29507
+ let path28 = opts.path;
29508
29508
  if (!opts.path.startsWith("/")) {
29509
- path26 = `/${path26}`;
29509
+ path28 = `/${path28}`;
29510
29510
  }
29511
- url2 = new URL(util2.parseOrigin(url2).origin + path26);
29511
+ url2 = new URL(util2.parseOrigin(url2).origin + path28);
29512
29512
  } else {
29513
29513
  if (!opts) {
29514
29514
  opts = typeof url2 === "object" ? url2 : {};
@@ -34477,24 +34477,184 @@ var {
34477
34477
  Help
34478
34478
  } = import_index.default;
34479
34479
 
34480
+ // src/utils/cardStorage.ts
34481
+ var import_promises3 = require("fs/promises");
34482
+ var import_path2 = __toESM(require("path"));
34483
+
34484
+ // ../linkque-agent-protocol/dist/esm/cardStorage.js
34485
+ var import_node_crypto = require("node:crypto");
34486
+ function canonicalJson(value) {
34487
+ return JSON.stringify(value, (_key, item) => item !== null && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.entries(item).sort(([a], [b3]) => a < b3 ? -1 : a > b3 ? 1 : 0)) : item);
34488
+ }
34489
+ function contentChecksum(value) {
34490
+ return (0, import_node_crypto.createHash)("sha256").update(canonicalJson(value)).digest("hex");
34491
+ }
34492
+ function assertCardPath(value) {
34493
+ if (typeof value !== "string" || !/^cards\/(?!\.{1,2}\/)[A-Za-z0-9%._-]+\/[a-f0-9]{64}\/(card|binding)\.json$/.test(value)) {
34494
+ throw new Error("\u65E0\u6548\u7684\u5361\u7247\u6587\u4EF6\u5F15\u7528");
34495
+ }
34496
+ }
34497
+ function splitAgentCards(input) {
34498
+ const config3 = structuredClone(input);
34499
+ const files = {};
34500
+ for (const resource of config3.agent.resources ?? []) {
34501
+ if (resource.resourceType !== "CARD")
34502
+ continue;
34503
+ if (resource.config.schemaVersion !== "4")
34504
+ throw new Error("\u5361\u7247\u5B58\u50A8\u53EA\u652F\u6301 V4");
34505
+ const directory = `cards/${encodeURIComponent(resource.resourceId)}/${contentChecksum(resource.config)}`;
34506
+ const template = resource.config.a2uiTemplate;
34507
+ const definition = {
34508
+ format: "linkque-a2ui",
34509
+ protocol: JSON.parse(template.content)
34510
+ };
34511
+ const binding = {
34512
+ ...resource.config,
34513
+ definitionRef: `${directory}/card.json`,
34514
+ a2uiTemplate: { argsSchema: template.argsSchema }
34515
+ };
34516
+ files[`${directory}/card.json`] = definition;
34517
+ files[`${directory}/binding.json`] = binding;
34518
+ resource.config = { bindingRef: `${directory}/binding.json` };
34519
+ }
34520
+ return { config: config3, files };
34521
+ }
34522
+ async function hydrateAgentCards(input, readJson) {
34523
+ const config3 = structuredClone(input);
34524
+ for (const resource of config3.agent.resources ?? []) {
34525
+ if (resource.resourceType !== "CARD")
34526
+ continue;
34527
+ if (!("bindingRef" in resource.config)) {
34528
+ if (resource.config.schemaVersion !== "4")
34529
+ throw new Error("\u5361\u7247\u5B58\u50A8\u53EA\u652F\u6301 V4");
34530
+ const template = resource.config.a2uiTemplate;
34531
+ template.content = canonicalJson(JSON.parse(template.content));
34532
+ continue;
34533
+ }
34534
+ assertCardPath(resource.config.bindingRef);
34535
+ const binding = await readJson(resource.config.bindingRef);
34536
+ assertCardPath(binding.definitionRef);
34537
+ const definition = await readJson(binding.definitionRef);
34538
+ const { definitionRef: _ref, ...execution } = binding;
34539
+ resource.config = {
34540
+ ...execution,
34541
+ a2uiTemplate: {
34542
+ ...execution.a2uiTemplate,
34543
+ content: canonicalJson(definition.protocol)
34544
+ }
34545
+ };
34546
+ }
34547
+ return config3;
34548
+ }
34549
+
34550
+ // src/utils/files.ts
34551
+ var import_crypto = require("crypto");
34552
+ var import_promises = require("fs/promises");
34553
+ var import_promises2 = require("fs/promises");
34554
+ var import_path = __toESM(require("path"));
34555
+ var isNodeError = (error2, code) => error2 !== null && typeof error2 === "object" && "code" in error2 && error2.code === code;
34556
+ var ensureParentDir = (filePath) => (0, import_promises2.mkdir)(import_path.default.dirname(filePath), { recursive: true }).then(() => void 0);
34557
+ var readUtf8IfExists = async (filePath) => {
34558
+ try {
34559
+ return await (0, import_promises2.readFile)(filePath, "utf8");
34560
+ } catch (error2) {
34561
+ if (isNodeError(error2, "ENOENT")) {
34562
+ return null;
34563
+ }
34564
+ throw error2;
34565
+ }
34566
+ };
34567
+ var pathExists = async (filePath) => {
34568
+ try {
34569
+ await (0, import_promises.stat)(filePath);
34570
+ return true;
34571
+ } catch (error2) {
34572
+ if (isNodeError(error2, "ENOENT")) return false;
34573
+ throw error2;
34574
+ }
34575
+ };
34576
+ var pathHasKind = async (filePath, kind) => {
34577
+ try {
34578
+ return (await (0, import_promises.stat)(filePath))[kind === "dir" ? "isDirectory" : "isFile"]();
34579
+ } catch (error2) {
34580
+ if (isNodeError(error2, "ENOENT")) return false;
34581
+ throw error2;
34582
+ }
34583
+ };
34584
+ var parseJsonObject = (content, code, message) => {
34585
+ try {
34586
+ const value = JSON.parse(content);
34587
+ if (value !== null && typeof value === "object" && !Array.isArray(value)) {
34588
+ return value;
34589
+ }
34590
+ } catch (error2) {
34591
+ throw new LinkqueCliError(code, message, { cause: error2 });
34592
+ }
34593
+ throw new LinkqueCliError(code, message);
34594
+ };
34595
+ var writeJsonAtomically = async (filePath, value, { exclusive = false } = {}) => {
34596
+ await ensureParentDir(filePath);
34597
+ const tempPath = `${filePath}.${process.pid}.${(0, import_crypto.randomUUID)()}.tmp`;
34598
+ try {
34599
+ await (0, import_promises2.writeFile)(
34600
+ tempPath,
34601
+ `${JSON.stringify(value, null, 2)}
34602
+ `,
34603
+ exclusive ? { encoding: "utf8", flag: "wx" } : "utf8"
34604
+ );
34605
+ if (exclusive) {
34606
+ await (0, import_promises2.link)(tempPath, filePath);
34607
+ } else {
34608
+ await (0, import_promises2.rename)(tempPath, filePath);
34609
+ }
34610
+ } finally {
34611
+ await (0, import_promises2.rm)(tempPath, { force: true }).catch(() => void 0);
34612
+ }
34613
+ };
34614
+
34615
+ // src/utils/cardStorage.ts
34616
+ async function readAgentCards(configPath) {
34617
+ const root = import_path2.default.dirname(configPath);
34618
+ return hydrateAgentCards(
34619
+ JSON.parse(await (0, import_promises3.readFile)(configPath, "utf8")),
34620
+ async (file) => JSON.parse(await (0, import_promises3.readFile)(import_path2.default.join(root, file), "utf8"))
34621
+ );
34622
+ }
34623
+ async function writeAgentCards(configPath, config3) {
34624
+ const source = splitAgentCards(config3);
34625
+ const root = import_path2.default.dirname(configPath);
34626
+ for (const [file, value] of Object.entries(source.files)) {
34627
+ await (0, import_promises3.mkdir)(import_path2.default.dirname(import_path2.default.join(root, file)), { recursive: true });
34628
+ await writeJsonAtomically(import_path2.default.join(root, file), value);
34629
+ }
34630
+ await writeJsonAtomically(configPath, source.config);
34631
+ return source;
34632
+ }
34633
+ async function migrateAgentCards(configPath) {
34634
+ return writeAgentCards(configPath, await readAgentCards(configPath));
34635
+ }
34636
+
34637
+ // src/commands/registry.ts
34638
+ var import_path29 = __toESM(require("path"));
34639
+
34480
34640
  // src/protocol.ts
34481
34641
  var import_fs = require("fs");
34482
- var import_path = __toESM(require("path"));
34642
+ var import_path3 = __toESM(require("path"));
34483
34643
  var PROTOCOL_VERSION = "1.0";
34484
34644
  var readCliVersion = () => {
34485
34645
  let dir = __dirname;
34486
- const root = import_path.default.parse(dir).root;
34646
+ const root = import_path3.default.parse(dir).root;
34487
34647
  while (dir !== root) {
34488
34648
  try {
34489
34649
  const pkg = JSON.parse(
34490
- (0, import_fs.readFileSync)(import_path.default.join(dir, "package.json"), "utf8")
34650
+ (0, import_fs.readFileSync)(import_path3.default.join(dir, "package.json"), "utf8")
34491
34651
  );
34492
34652
  if (pkg.name === "@alipay/linkque-cli" || pkg.name === "linkque-cli-v2") {
34493
34653
  return pkg.version ?? "0.0.0";
34494
34654
  }
34495
34655
  } catch {
34496
34656
  }
34497
- dir = import_path.default.dirname(dir);
34657
+ dir = import_path3.default.dirname(dir);
34498
34658
  }
34499
34659
  return "0.0.0";
34500
34660
  };
@@ -34514,8 +34674,8 @@ var failureEnvelope = (command, error2, durationMs) => ({
34514
34674
  });
34515
34675
 
34516
34676
  // src/commands/agentbuild/buildCommand.ts
34517
- var import_path10 = __toESM(require("path"));
34518
- var import_promises5 = require("fs/promises");
34677
+ var import_path11 = __toESM(require("path"));
34678
+ var import_promises6 = require("fs/promises");
34519
34679
 
34520
34680
  // ../../node_modules/tar/dist/esm/index.min.js
34521
34681
  var import_events = __toESM(require("events"), 1);
@@ -34525,7 +34685,7 @@ var import_node_stream = __toESM(require("node:stream"), 1);
34525
34685
  var import_node_string_decoder = require("node:string_decoder");
34526
34686
  var import_node_path = __toESM(require("node:path"), 1);
34527
34687
  var import_node_fs = __toESM(require("node:fs"), 1);
34528
- var import_path2 = require("path");
34688
+ var import_path4 = require("path");
34529
34689
  var import_events2 = require("events");
34530
34690
  var import_assert = __toESM(require("assert"), 1);
34531
34691
  var import_buffer = require("buffer");
@@ -34535,19 +34695,19 @@ var import_node_path2 = require("node:path");
34535
34695
  var import_node_path3 = require("node:path");
34536
34696
  var import_fs3 = __toESM(require("fs"), 1);
34537
34697
  var import_fs4 = __toESM(require("fs"), 1);
34538
- var import_path3 = __toESM(require("path"), 1);
34698
+ var import_path5 = __toESM(require("path"), 1);
34539
34699
  var import_node_path4 = require("node:path");
34540
- var import_path4 = __toESM(require("path"), 1);
34700
+ var import_path6 = __toESM(require("path"), 1);
34541
34701
  var import_node_fs2 = __toESM(require("node:fs"), 1);
34542
34702
  var import_node_assert = __toESM(require("node:assert"), 1);
34543
- var import_node_crypto = require("node:crypto");
34703
+ var import_node_crypto2 = require("node:crypto");
34544
34704
  var import_node_fs3 = __toESM(require("node:fs"), 1);
34545
34705
  var import_node_path5 = __toESM(require("node:path"), 1);
34546
34706
  var import_fs5 = __toESM(require("fs"), 1);
34547
34707
  var import_node_fs4 = __toESM(require("node:fs"), 1);
34548
34708
  var import_node_path6 = __toESM(require("node:path"), 1);
34549
34709
  var import_node_fs5 = __toESM(require("node:fs"), 1);
34550
- var import_promises = __toESM(require("node:fs/promises"), 1);
34710
+ var import_promises4 = __toESM(require("node:fs/promises"), 1);
34551
34711
  var import_node_path7 = __toESM(require("node:path"), 1);
34552
34712
  var import_node_path8 = require("node:path");
34553
34713
  var import_node_fs6 = __toESM(require("node:fs"), 1);
@@ -35909,11 +36069,11 @@ var vn = (s4) => {
35909
36069
  var Qi = (s4, t3) => {
35910
36070
  let e3 = new Map(t3.map((o2) => [mt(o2), true])), i = s4.filter, r2 = 100, n3 = (o2, h = "", a = 0) => {
35911
36071
  if (a >= r2) return e3.set(o2, false), false;
35912
- let l2 = h || (0, import_path2.parse)(o2).root || ".", c;
36072
+ let l2 = h || (0, import_path4.parse)(o2).root || ".", c;
35913
36073
  if (o2 === l2) c = false;
35914
36074
  else {
35915
36075
  let d = e3.get(o2);
35916
- c = d !== void 0 ? d : n3((0, import_path2.dirname)(o2), l2, a + 1);
36076
+ c = d !== void 0 ? d : n3((0, import_path4.dirname)(o2), l2, a + 1);
35917
36077
  }
35918
36078
  return e3.set(o2, c), c;
35919
36079
  };
@@ -36033,7 +36193,7 @@ var de = class extends A {
36033
36193
  let [o2, h] = ce(this.path);
36034
36194
  o2 && typeof h == "string" && (this.path = h, r2 = o2);
36035
36195
  }
36036
- this.win32 = !!i.win32 || process.platform === "win32", this.win32 && (this.path = Qs(this.path.replaceAll(/\\/g, "/")), t3 = t3.replaceAll(/\\/g, "/")), this.absolute = f(i.absolute || import_path3.default.resolve(this.cwd, t3)), this.path === "" && (this.path = "./"), r2 && this.warn("TAR_ENTRY_INFO", `stripping ${r2} from absolute path`, { entry: this, path: r2 + this.path });
36196
+ this.win32 = !!i.win32 || process.platform === "win32", this.win32 && (this.path = Qs(this.path.replaceAll(/\\/g, "/")), t3 = t3.replaceAll(/\\/g, "/")), this.absolute = f(i.absolute || import_path5.default.resolve(this.cwd, t3)), this.path === "" && (this.path = "./"), r2 && this.warn("TAR_ENTRY_INFO", `stripping ${r2} from absolute path`, { entry: this, path: r2 + this.path });
36037
36197
  let n3 = this.statCache.get(this.absolute);
36038
36198
  n3 ? this[si](n3) : this[ss]();
36039
36199
  }
@@ -36092,7 +36252,7 @@ var de = class extends A {
36092
36252
  }
36093
36253
  [sr](t3) {
36094
36254
  if (!this.stat) throw new Error("cannot create link entry without stat");
36095
- this.type = "Link", this.linkpath = f(import_path3.default.relative(this.cwd, t3)), this.stat.size = 0, this[fe](), this.end();
36255
+ this.type = "Link", this.linkpath = f(import_path5.default.relative(this.cwd, t3)), this.stat.size = 0, this[fe](), this.end();
36096
36256
  }
36097
36257
  [er]() {
36098
36258
  if (!this.stat) throw new Error("cannot create file entry without stat");
@@ -36506,7 +36666,7 @@ var wt = class extends A {
36506
36666
  return typeof t3 == "string" ? this[ci](t3) : this[or](t3), this.flowing;
36507
36667
  }
36508
36668
  [or](t3) {
36509
- let e3 = f(import_path4.default.resolve(this.cwd, t3.path));
36669
+ let e3 = f(import_path6.default.resolve(this.cwd, t3.path));
36510
36670
  if (!this.filter(t3.path, t3)) t3.resume();
36511
36671
  else {
36512
36672
  let i = new pi(t3.path, e3);
@@ -36515,7 +36675,7 @@ var wt = class extends A {
36515
36675
  this[Ft]();
36516
36676
  }
36517
36677
  [ci](t3) {
36518
- let e3 = f(import_path4.default.resolve(this.cwd, t3));
36678
+ let e3 = f(import_path6.default.resolve(this.cwd, t3));
36519
36679
  this[W].push(new pi(t3, e3)), this[Ft]();
36520
36680
  }
36521
36681
  [ds](t3) {
@@ -36786,7 +36946,7 @@ var gr = (s4, t3, e3) => {
36786
36946
  E ? e3(E) : x && a ? Es(x, o2, h, (Le) => y(Le)) : n3 ? import_node_fs5.default.chmod(s4, r2, e3) : e3();
36787
36947
  };
36788
36948
  if (s4 === d) return no(s4, y);
36789
- if (l2) return import_promises.default.mkdir(s4, { mode: r2, recursive: true }).then((E) => y(null, E ?? void 0), y);
36949
+ if (l2) return import_promises4.default.mkdir(s4, { mode: r2, recursive: true }).then((E) => y(null, E ?? void 0), y);
36790
36950
  let D = f(import_node_path7.default.relative(d, s4)).split("/");
36791
36951
  Ss(d, D, r2, c, d, void 0, y);
36792
36952
  };
@@ -36955,7 +37115,7 @@ var Te = fo === "win32";
36955
37115
  var uo = 1024;
36956
37116
  var mo = (s4, t3) => {
36957
37117
  if (!Te) return import_node_fs3.default.unlink(s4, t3);
36958
- let e3 = s4 + ".DELETE." + (0, import_node_crypto.randomBytes)(16).toString("hex");
37118
+ let e3 = s4 + ".DELETE." + (0, import_node_crypto2.randomBytes)(16).toString("hex");
36959
37119
  import_node_fs3.default.rename(s4, e3, (i) => {
36960
37120
  if (i) return t3(i);
36961
37121
  import_node_fs3.default.unlink(e3, t3);
@@ -36963,7 +37123,7 @@ var mo = (s4, t3) => {
36963
37123
  };
36964
37124
  var po = (s4) => {
36965
37125
  if (!Te) return import_node_fs3.default.unlinkSync(s4);
36966
- let t3 = s4 + ".DELETE." + (0, import_node_crypto.randomBytes)(16).toString("hex");
37126
+ let t3 = s4 + ".DELETE." + (0, import_node_crypto2.randomBytes)(16).toString("hex");
36967
37127
  import_node_fs3.default.renameSync(s4, t3), import_node_fs3.default.unlinkSync(t3);
36968
37128
  };
36969
37129
  var vr = (s4, t3, e3) => s4 !== void 0 && s4 === s4 >>> 0 ? s4 : t3 !== void 0 && t3 === t3 >>> 0 ? t3 : e3;
@@ -37486,74 +37646,9 @@ var To = (s4) => {
37486
37646
  s4.mtimeCache || (s4.mtimeCache = /* @__PURE__ */ new Map()), s4.filter = t3 ? (e3, i) => t3(e3, i) && !((s4.mtimeCache?.get(e3) ?? i.mtime ?? 0) > (i.mtime ?? 0)) : (e3, i) => !((s4.mtimeCache?.get(e3) ?? i.mtime ?? 0) > (i.mtime ?? 0));
37487
37647
  };
37488
37648
 
37489
- // src/utils/files.ts
37490
- var import_crypto = require("crypto");
37491
- var import_promises2 = require("fs/promises");
37492
- var import_promises3 = require("fs/promises");
37493
- var import_path5 = __toESM(require("path"));
37494
- var isNodeError = (error2, code) => error2 !== null && typeof error2 === "object" && "code" in error2 && error2.code === code;
37495
- var ensureParentDir = (filePath) => (0, import_promises3.mkdir)(import_path5.default.dirname(filePath), { recursive: true }).then(() => void 0);
37496
- var readUtf8IfExists = async (filePath) => {
37497
- try {
37498
- return await (0, import_promises3.readFile)(filePath, "utf8");
37499
- } catch (error2) {
37500
- if (isNodeError(error2, "ENOENT")) {
37501
- return null;
37502
- }
37503
- throw error2;
37504
- }
37505
- };
37506
- var pathExists = async (filePath) => {
37507
- try {
37508
- await (0, import_promises2.stat)(filePath);
37509
- return true;
37510
- } catch (error2) {
37511
- if (isNodeError(error2, "ENOENT")) return false;
37512
- throw error2;
37513
- }
37514
- };
37515
- var pathHasKind = async (filePath, kind) => {
37516
- try {
37517
- return (await (0, import_promises2.stat)(filePath))[kind === "dir" ? "isDirectory" : "isFile"]();
37518
- } catch (error2) {
37519
- if (isNodeError(error2, "ENOENT")) return false;
37520
- throw error2;
37521
- }
37522
- };
37523
- var parseJsonObject = (content, code, message) => {
37524
- try {
37525
- const value = JSON.parse(content);
37526
- if (value !== null && typeof value === "object" && !Array.isArray(value)) {
37527
- return value;
37528
- }
37529
- } catch (error2) {
37530
- throw new LinkqueCliError(code, message, { cause: error2 });
37531
- }
37532
- throw new LinkqueCliError(code, message);
37533
- };
37534
- var writeJsonAtomically = async (filePath, value, { exclusive = false } = {}) => {
37535
- await ensureParentDir(filePath);
37536
- const tempPath = `${filePath}.${process.pid}.${(0, import_crypto.randomUUID)()}.tmp`;
37537
- try {
37538
- await (0, import_promises3.writeFile)(
37539
- tempPath,
37540
- `${JSON.stringify(value, null, 2)}
37541
- `,
37542
- exclusive ? { encoding: "utf8", flag: "wx" } : "utf8"
37543
- );
37544
- if (exclusive) {
37545
- await (0, import_promises3.link)(tempPath, filePath);
37546
- } else {
37547
- await (0, import_promises3.rename)(tempPath, filePath);
37548
- }
37549
- } finally {
37550
- await (0, import_promises3.rm)(tempPath, { force: true }).catch(() => void 0);
37551
- }
37552
- };
37553
-
37554
37649
  // src/utils/workspaceLock.ts
37555
37650
  var import_crypto2 = require("crypto");
37556
- var import_promises4 = require("fs/promises");
37651
+ var import_promises5 = require("fs/promises");
37557
37652
  var import_os = require("os");
37558
37653
 
37559
37654
  // src/utils/process.ts
@@ -37613,19 +37708,19 @@ var describeOwner = (owner) => {
37613
37708
  };
37614
37709
  var publishOwner = async (lockPath, owner) => {
37615
37710
  const pendingPath = `${lockPath}.${owner.ownerId}.pending`;
37616
- await (0, import_promises4.writeFile)(pendingPath, `${JSON.stringify(owner)}
37711
+ await (0, import_promises5.writeFile)(pendingPath, `${JSON.stringify(owner)}
37617
37712
  `, {
37618
37713
  encoding: "utf8",
37619
37714
  flag: "wx"
37620
37715
  });
37621
37716
  try {
37622
- await (0, import_promises4.link)(pendingPath, lockPath);
37717
+ await (0, import_promises5.link)(pendingPath, lockPath);
37623
37718
  return true;
37624
37719
  } catch (error2) {
37625
37720
  if (isNodeError(error2, "EEXIST")) return false;
37626
37721
  throw error2;
37627
37722
  } finally {
37628
- await (0, import_promises4.rm)(pendingPath, { force: true });
37723
+ await (0, import_promises5.rm)(pendingPath, { force: true });
37629
37724
  }
37630
37725
  };
37631
37726
  var releaseOwner = async (lockPath, ownerId, name) => {
@@ -37634,7 +37729,7 @@ var releaseOwner = async (lockPath, ownerId, name) => {
37634
37729
  if (owner.ownerId !== ownerId) {
37635
37730
  throw new Error(`workspace ${name} lock ownership changed`);
37636
37731
  }
37637
- await (0, import_promises4.rm)(lockPath);
37732
+ await (0, import_promises5.rm)(lockPath);
37638
37733
  };
37639
37734
  var acquireWorkspaceLock = async (lockPath, options) => {
37640
37735
  await ensureParentDir(lockPath);
@@ -37870,7 +37965,7 @@ async function bundleAgentInstallation(input) {
37870
37965
  }
37871
37966
 
37872
37967
  // src/commands/agentbuild/configLoader.ts
37873
- var import_path6 = __toESM(require("path"));
37968
+ var import_path7 = __toESM(require("path"));
37874
37969
 
37875
37970
  // src/commands/agentbuild/types.ts
37876
37971
  var AGENT_BUNDLE_DIR = ".linkque/artifacts/agent-bundle";
@@ -37885,7 +37980,7 @@ var DEFAULT_CONFIG_NAME = "agent_config.json";
37885
37980
 
37886
37981
  // src/commands/agentbuild/configLoader.ts
37887
37982
  var loadAgentProtocol = async (rawConfigPath, cwd) => {
37888
- const configPath = import_path6.default.resolve(
37983
+ const configPath = import_path7.default.resolve(
37889
37984
  cwd,
37890
37985
  rawConfigPath === "" ? DEFAULT_CONFIG_NAME : rawConfigPath
37891
37986
  );
@@ -37931,7 +38026,7 @@ var EModelRequestSource;
37931
38026
  })(EModelRequestSource || (EModelRequestSource = {}));
37932
38027
 
37933
38028
  // ../linkque-agent-runtime/dist/esm/core/dataTransformExecutor.js
37934
- var import_node_crypto2 = require("node:crypto");
38029
+ var import_node_crypto3 = require("node:crypto");
37935
38030
  var import_node_worker_threads = require("node:worker_threads");
37936
38031
 
37937
38032
  // ../linkque-agent-runtime/dist/esm/core/dataTransformWorkerUrl.js
@@ -37988,7 +38083,7 @@ var DataTransformExecutor = class {
37988
38083
  }
37989
38084
  execute(source, input, signal, options) {
37990
38085
  const sourceBytes = Buffer.byteLength(source, "utf8");
37991
- const sourceHash = (0, import_node_crypto2.createHash)("sha256").update(source).digest("hex");
38086
+ const sourceHash = (0, import_node_crypto3.createHash)("sha256").update(source).digest("hex");
37992
38087
  if (!source.trim() || sourceBytes > DATA_TRANSFORM_LIMITS.sourceBytes) {
37993
38088
  return Promise.reject(new DataTransformError("CARD_TRANSFORM_SOURCE_INVALID", `\u6570\u636E\u8F6C\u6362\u6E90\u7801\u4E3A\u7A7A\u6216\u8D85\u8FC7 ${DATA_TRANSFORM_LIMITS.sourceBytes} \u5B57\u8282`, sourceHash));
37994
38089
  }
@@ -38044,7 +38139,7 @@ var DataTransformExecutor = class {
38044
38139
  }
38045
38140
  validateSource(source, profile) {
38046
38141
  const sourceBytes = Buffer.byteLength(source, "utf8");
38047
- const sourceHash = (0, import_node_crypto2.createHash)("sha256").update(source).digest("hex");
38142
+ const sourceHash = (0, import_node_crypto3.createHash)("sha256").update(source).digest("hex");
38048
38143
  if (!source.trim() || sourceBytes > DATA_TRANSFORM_LIMITS.sourceBytes) {
38049
38144
  return Promise.reject(new DataTransformError("CARD_TRANSFORM_SOURCE_INVALID", `\u6570\u636E\u8F6C\u6362\u6E90\u7801\u4E3A\u7A7A\u6216\u8D85\u8FC7 ${DATA_TRANSFORM_LIMITS.sourceBytes} \u5B57\u8282`, sourceHash));
38050
38145
  }
@@ -38342,6 +38437,7 @@ var EHookExecutorName;
38342
38437
  EHookExecutorName2["SecurityAnswerHookExecutor"] = "SecurityAnswerHookExecutor";
38343
38438
  EHookExecutorName2["ImageUnderstandingHookExecutor"] = "ImageUnderstandingHookExecutor";
38344
38439
  EHookExecutorName2["McpDiscoveryHookExecutor"] = "McpDiscoveryHookExecutor";
38440
+ EHookExecutorName2["BusinessDataPromptHookExecutor"] = "BusinessDataPromptHookExecutor";
38345
38441
  EHookExecutorName2["CurrentTimeHookExecutor"] = "CurrentTimeHookExecutor";
38346
38442
  EHookExecutorName2["MemoryHookExecutor"] = "MemoryHookExecutor";
38347
38443
  })(EHookExecutorName || (EHookExecutorName = {}));
@@ -38369,7 +38465,10 @@ function isPlainRecord(value) {
38369
38465
  if (!value || typeof value !== "object" || Array.isArray(value))
38370
38466
  return false;
38371
38467
  const prototype = Object.getPrototypeOf(value);
38372
- return prototype === Object.prototype || prototype === null;
38468
+ if (prototype === Object.prototype || prototype === null)
38469
+ return true;
38470
+ const constructor = Object.getOwnPropertyDescriptor(prototype, "constructor")?.value;
38471
+ return Object.getPrototypeOf(prototype) === null && typeof constructor === "function" && Function.prototype.toString.call(constructor) === Function.prototype.toString.call(Object);
38373
38472
  }
38374
38473
  function isJsonValue(value) {
38375
38474
  if (value === null || typeof value === "string" || typeof value === "boolean") {
@@ -38449,10 +38548,10 @@ function canonicalizeBindingPath(rawPath, listRoot) {
38449
38548
  }
38450
38549
  return isSafeJsonPointer(candidate, true) ? candidate : void 0;
38451
38550
  }
38452
- function issue2(path26, code, message) {
38453
- return { path: path26, code, message };
38551
+ function issue2(path28, code, message) {
38552
+ return { path: path28, code, message };
38454
38553
  }
38455
- function exactKeys(value, allowed, path26, issues) {
38554
+ function exactKeys(value, allowed, path28, issues) {
38456
38555
  }
38457
38556
 
38458
38557
  // ../agent-a2ui-card-contract/dist/esm/binding-analyzer.js
@@ -38682,9 +38781,9 @@ var SCHEMA_TYPES = /* @__PURE__ */ new Set([
38682
38781
  "object",
38683
38782
  "string"
38684
38783
  ]);
38685
- function getJsonSchemaIssues(value, path26 = "schema", options = {}) {
38784
+ function getJsonSchemaIssues(value, path28 = "schema", options = {}) {
38686
38785
  const issues = [];
38687
- validateSchemaNode(value, path26, issues, options);
38786
+ validateSchemaNode(value, path28, issues, options);
38688
38787
  return issues;
38689
38788
  }
38690
38789
  var OPAQUE_OBJECT_SCHEMA = {
@@ -38706,9 +38805,9 @@ function normalizeTargetJsonSchema(schema2) {
38706
38805
  normalizeObjectDefaults(cloned);
38707
38806
  return cloned;
38708
38807
  }
38709
- function validateJsonSchemaValue2(schema2, value, path26 = "$") {
38808
+ function validateJsonSchemaValue2(schema2, value, path28 = "$") {
38710
38809
  const issues = [];
38711
- validateValue(schema2, value, path26, issues);
38810
+ validateValue(schema2, value, path28, issues);
38712
38811
  return issues;
38713
38812
  }
38714
38813
  function normalizeCardDataValue(schema2, value, required2 = true) {
@@ -38812,9 +38911,9 @@ function getJsonSchemaAtDataPointer(schema2, pointer) {
38812
38911
  return schema2;
38813
38912
  return getJsonSchemaAtPath(schema2, pointer.slice(1).split("/").map(decodePointerSegment));
38814
38913
  }
38815
- function getJsonSchemaAtPath(schema2, path26) {
38914
+ function getJsonSchemaAtPath(schema2, path28) {
38816
38915
  let current = schema2;
38817
- for (const segment of path26) {
38916
+ for (const segment of path28) {
38818
38917
  if (!current)
38819
38918
  return void 0;
38820
38919
  if (segment === "*" || current.type === "array") {
@@ -38832,56 +38931,56 @@ function getJsonSchemaAtPath(schema2, path26) {
38832
38931
  }
38833
38932
  return current;
38834
38933
  }
38835
- function getJsonSchemaCompatibilityIssues(source, target, path26 = "$") {
38934
+ function getJsonSchemaCompatibilityIssues(source, target, path28 = "$") {
38836
38935
  const issues = [];
38837
- compareSchemas(source, target, path26, issues);
38936
+ compareSchemas(source, target, path28, issues);
38838
38937
  return issues;
38839
38938
  }
38840
38939
  function areJsonSchemaTypesCompatible(sourceType, targetType) {
38841
38940
  return sourceType === targetType || sourceType === "integer" && targetType === "number";
38842
38941
  }
38843
- function validateSchemaNode(value, path26, issues, options) {
38942
+ function validateSchemaNode(value, path28, issues, options) {
38844
38943
  if (!isPlainRecord(value) || !isJsonValue(value)) {
38845
- issues.push(issue2(path26, "INVALID_JSON_SCHEMA", `${path26} must be a JSON object`));
38944
+ issues.push(issue2(path28, "INVALID_JSON_SCHEMA", `${path28} must be a JSON object`));
38846
38945
  return false;
38847
38946
  }
38848
38947
  if (value.type === void 0 && options.allowMissingType) {
38849
38948
  return true;
38850
38949
  }
38851
38950
  if (typeof value.type !== "string" || !SCHEMA_TYPES.has(value.type)) {
38852
- issues.push(issue2(`${path26}.type`, "INVALID_JSON_SCHEMA_TYPE", `${path26}.type must be a supported scalar, object or array type`));
38951
+ issues.push(issue2(`${path28}.type`, "INVALID_JSON_SCHEMA_TYPE", `${path28}.type must be a supported scalar, object or array type`));
38853
38952
  return false;
38854
38953
  }
38855
38954
  if (value.required !== void 0 && (!Array.isArray(value.required) || value.required.some((entry) => typeof entry !== "string"))) {
38856
- issues.push(issue2(`${path26}.required`, "INVALID_JSON_SCHEMA_REQUIRED", `${path26}.required must be a string array`));
38955
+ issues.push(issue2(`${path28}.required`, "INVALID_JSON_SCHEMA_REQUIRED", `${path28}.required must be a string array`));
38857
38956
  }
38858
38957
  if (value.type === "object") {
38859
38958
  if (!isPlainRecord(value.properties)) {
38860
38959
  if (options.requireCompleteStructures) {
38861
- issues.push(issue2(`${path26}.properties`, "INCOMPLETE_OBJECT_SCHEMA", "object schemas must declare properties"));
38960
+ issues.push(issue2(`${path28}.properties`, "INCOMPLETE_OBJECT_SCHEMA", "object schemas must declare properties"));
38862
38961
  }
38863
38962
  } else {
38864
38963
  for (const [name, child] of Object.entries(value.properties)) {
38865
- validateSchemaNode(child, `${path26}.properties.${name}`, issues, options);
38964
+ validateSchemaNode(child, `${path28}.properties.${name}`, issues, options);
38866
38965
  }
38867
38966
  const required2 = Array.isArray(value.required) ? value.required.filter((entry) => typeof entry === "string") : [];
38868
38967
  for (const name of required2) {
38869
38968
  if (!(name in value.properties)) {
38870
- issues.push(issue2(`${path26}.required`, "UNKNOWN_REQUIRED_PROPERTY", `required property ${name} is not declared`));
38969
+ issues.push(issue2(`${path28}.required`, "UNKNOWN_REQUIRED_PROPERTY", `required property ${name} is not declared`));
38871
38970
  }
38872
38971
  }
38873
38972
  }
38874
38973
  if (value.additionalProperties !== void 0 && typeof value.additionalProperties !== "boolean" && !isPlainRecord(value.additionalProperties)) {
38875
- issues.push(issue2(`${path26}.additionalProperties`, "INVALID_ADDITIONAL_PROPERTIES", "additionalProperties must be a boolean or schema"));
38974
+ issues.push(issue2(`${path28}.additionalProperties`, "INVALID_ADDITIONAL_PROPERTIES", "additionalProperties must be a boolean or schema"));
38876
38975
  }
38877
38976
  }
38878
38977
  if (value.type === "array") {
38879
38978
  if (!isPlainRecord(value.items)) {
38880
38979
  if (options.requireCompleteStructures) {
38881
- issues.push(issue2(`${path26}.items`, "INCOMPLETE_ARRAY_SCHEMA", "array schemas must declare items"));
38980
+ issues.push(issue2(`${path28}.items`, "INCOMPLETE_ARRAY_SCHEMA", "array schemas must declare items"));
38882
38981
  }
38883
38982
  } else {
38884
- validateSchemaNode(value.items, `${path26}.items`, issues, options);
38983
+ validateSchemaNode(value.items, `${path28}.items`, issues, options);
38885
38984
  }
38886
38985
  }
38887
38986
  return true;
@@ -38901,53 +39000,53 @@ function normalizeObjectDefaults(schema2) {
38901
39000
  normalizeObjectDefaults(schema2.items);
38902
39001
  }
38903
39002
  }
38904
- function validateValue(schema2, value, path26, issues) {
39003
+ function validateValue(schema2, value, path28, issues) {
38905
39004
  if (typeof schema2.type === "string" && !matchesType(schema2.type, value)) {
38906
- issues.push(issue2(path26, "SCHEMA_TYPE_MISMATCH", `expected ${schema2.type}, received ${valueType(value)}`));
39005
+ issues.push(issue2(path28, "SCHEMA_TYPE_MISMATCH", `expected ${schema2.type}, received ${valueType(value)}`));
38907
39006
  return;
38908
39007
  }
38909
39008
  if (Array.isArray(schema2.enum) && !schema2.enum.some((entry) => Object.is(entry, value))) {
38910
- issues.push(issue2(path26, "SCHEMA_ENUM_MISMATCH", "value is not in the declared enum"));
39009
+ issues.push(issue2(path28, "SCHEMA_ENUM_MISMATCH", "value is not in the declared enum"));
38911
39010
  return;
38912
39011
  }
38913
39012
  if (schema2.const !== void 0 && !Object.is(schema2.const, value)) {
38914
- issues.push(issue2(path26, "SCHEMA_CONST_MISMATCH", "value does not match const"));
39013
+ issues.push(issue2(path28, "SCHEMA_CONST_MISMATCH", "value does not match const"));
38915
39014
  return;
38916
39015
  }
38917
39016
  if (schema2.type === "object" && isPlainRecord(value)) {
38918
39017
  const required2 = Array.isArray(schema2.required) ? schema2.required.filter((entry) => typeof entry === "string") : [];
38919
39018
  for (const key of required2) {
38920
39019
  if (!(key in value)) {
38921
- issues.push(issue2(`${path26}/${key}`, "SCHEMA_REQUIRED_MISSING", `required property ${key} is missing`));
39020
+ issues.push(issue2(`${path28}/${key}`, "SCHEMA_REQUIRED_MISSING", `required property ${key} is missing`));
38922
39021
  }
38923
39022
  }
38924
39023
  const properties = isPlainRecord(schema2.properties) ? schema2.properties : {};
38925
39024
  for (const [key, childSchema] of Object.entries(properties)) {
38926
39025
  if (!(key in value) || !isPlainRecord(childSchema))
38927
39026
  continue;
38928
- validateValue(childSchema, value[key], `${path26}/${key}`, issues);
39027
+ validateValue(childSchema, value[key], `${path28}/${key}`, issues);
38929
39028
  }
38930
39029
  if (schema2.additionalProperties === false) {
38931
39030
  for (const key of Object.keys(value)) {
38932
39031
  if (!(key in properties)) {
38933
- issues.push(issue2(`${path26}/${key}`, "SCHEMA_ADDITIONAL_PROPERTY", `property ${key} is not allowed`));
39032
+ issues.push(issue2(`${path28}/${key}`, "SCHEMA_ADDITIONAL_PROPERTY", `property ${key} is not allowed`));
38934
39033
  }
38935
39034
  }
38936
39035
  }
38937
39036
  }
38938
39037
  if (schema2.type === "array" && Array.isArray(value) && isPlainRecord(schema2.items)) {
38939
39038
  value.forEach((entry, index) => {
38940
- validateValue(schema2.items, entry, `${path26}/${index}`, issues);
39039
+ validateValue(schema2.items, entry, `${path28}/${index}`, issues);
38941
39040
  });
38942
39041
  }
38943
39042
  }
38944
- function compareSchemas(source, target, path26, issues) {
39043
+ function compareSchemas(source, target, path28, issues) {
38945
39044
  if (!areJsonSchemaTypesCompatible(source.type, target.type)) {
38946
- issues.push(issue2(path26, "SCHEMA_TYPE_INCOMPATIBLE", `source type ${String(source.type)} cannot supply ${String(target.type)}`));
39045
+ issues.push(issue2(path28, "SCHEMA_TYPE_INCOMPATIBLE", `source type ${String(source.type)} cannot supply ${String(target.type)}`));
38947
39046
  return;
38948
39047
  }
38949
39048
  if (source.type === "array" && target.type === "array" && isPlainRecord(source.items) && isPlainRecord(target.items)) {
38950
- compareSchemas(source.items, target.items, `${path26}[*]`, issues);
39049
+ compareSchemas(source.items, target.items, `${path28}[*]`, issues);
38951
39050
  }
38952
39051
  if (source.type === "object" && target.type === "object" && isPlainRecord(source.properties) && isPlainRecord(target.properties)) {
38953
39052
  const required2 = Array.isArray(target.required) ? target.required.filter((entry) => typeof entry === "string") : [];
@@ -38955,10 +39054,10 @@ function compareSchemas(source, target, path26, issues) {
38955
39054
  const sourceChild = source.properties[name];
38956
39055
  const targetChild = target.properties[name];
38957
39056
  if (!isPlainRecord(sourceChild) || !isPlainRecord(targetChild)) {
38958
- issues.push(issue2(`${path26}.${name}`, "SCHEMA_REQUIRED_MISSING", `source does not provide required property ${name}`));
39057
+ issues.push(issue2(`${path28}.${name}`, "SCHEMA_REQUIRED_MISSING", `source does not provide required property ${name}`));
38959
39058
  continue;
38960
39059
  }
38961
- compareSchemas(sourceChild, targetChild, `${path26}.${name}`, issues);
39060
+ compareSchemas(sourceChild, targetChild, `${path28}.${name}`, issues);
38962
39061
  }
38963
39062
  }
38964
39063
  }
@@ -39047,37 +39146,37 @@ var A2UICardExpressionError = class extends Error {
39047
39146
  this.fieldId = fieldId;
39048
39147
  }
39049
39148
  };
39050
- function getA2UICardTransformIssues(value, path26 = "transform") {
39149
+ function getA2UICardTransformIssues(value, path28 = "transform") {
39051
39150
  if (!isPlainRecord(value)) {
39052
39151
  return [
39053
- issue2(path26, "CARD_EXPRESSION_INVALID", "transform must be an object")
39152
+ issue2(path28, "CARD_EXPRESSION_INVALID", "transform must be an object")
39054
39153
  ];
39055
39154
  }
39056
39155
  const issues = [];
39057
39156
  const allowedKeys = /* @__PURE__ */ new Set(["language", "profile", "expression"]);
39058
39157
  for (const key of Object.keys(value)) {
39059
39158
  if (!allowedKeys.has(key)) {
39060
- issues.push(issue2(`${path26}.${key}`, "CARD_EXPRESSION_INVALID", `${key} is not supported by transform`));
39159
+ issues.push(issue2(`${path28}.${key}`, "CARD_EXPRESSION_INVALID", `${key} is not supported by transform`));
39061
39160
  }
39062
39161
  }
39063
39162
  if (value.language !== A2UI_CARD_TRANSFORM_LANGUAGE) {
39064
- issues.push(issue2(`${path26}.language`, "CARD_EXPRESSION_INVALID", `language must be ${A2UI_CARD_TRANSFORM_LANGUAGE}`));
39163
+ issues.push(issue2(`${path28}.language`, "CARD_EXPRESSION_INVALID", `language must be ${A2UI_CARD_TRANSFORM_LANGUAGE}`));
39065
39164
  }
39066
39165
  if (value.profile !== A2UI_CARD_TRANSFORM_PROFILE) {
39067
- issues.push(issue2(`${path26}.profile`, "CARD_EXPRESSION_INVALID", `profile must be ${A2UI_CARD_TRANSFORM_PROFILE}`));
39166
+ issues.push(issue2(`${path28}.profile`, "CARD_EXPRESSION_INVALID", `profile must be ${A2UI_CARD_TRANSFORM_PROFILE}`));
39068
39167
  }
39069
39168
  if (typeof value.expression !== "string" || value.expression.trim().length === 0) {
39070
- issues.push(issue2(`${path26}.expression`, "CARD_EXPRESSION_INVALID", "expression must be a non-empty string"));
39169
+ issues.push(issue2(`${path28}.expression`, "CARD_EXPRESSION_INVALID", "expression must be a non-empty string"));
39071
39170
  return issues;
39072
39171
  }
39073
39172
  if (value.expression.length > A2UI_CARD_EXPRESSION_MAX_LENGTH) {
39074
- issues.push(issue2(`${path26}.expression`, "CARD_EXPRESSION_LIMIT_EXCEEDED", `expression exceeds ${A2UI_CARD_EXPRESSION_MAX_LENGTH} characters`));
39173
+ issues.push(issue2(`${path28}.expression`, "CARD_EXPRESSION_LIMIT_EXCEEDED", `expression exceeds ${A2UI_CARD_EXPRESSION_MAX_LENGTH} characters`));
39075
39174
  return issues;
39076
39175
  }
39077
39176
  try {
39078
39177
  validateAst((0, import_jmespath2.compile)(value.expression));
39079
39178
  } catch (error2) {
39080
- issues.push(issue2(`${path26}.expression`, error2 instanceof A2UICardExpressionError ? error2.code : "CARD_EXPRESSION_INVALID", error2 instanceof Error ? error2.message : "expression is invalid"));
39179
+ issues.push(issue2(`${path28}.expression`, error2 instanceof A2UICardExpressionError ? error2.code : "CARD_EXPRESSION_INVALID", error2 instanceof Error ? error2.message : "expression is invalid"));
39081
39180
  }
39082
39181
  return issues;
39083
39182
  }
@@ -39189,11 +39288,11 @@ function parseA2UICardBindingContext(value) {
39189
39288
  issues: []
39190
39289
  };
39191
39290
  }
39192
- function getA2UICardBindingContextIssues(value, path26 = "bindingContext") {
39291
+ function getA2UICardBindingContextIssues(value, path28 = "bindingContext") {
39193
39292
  const issues = [];
39194
39293
  if (!isPlainRecord(value)) {
39195
39294
  return [
39196
- issue2(path26, "CARD_BINDING_CONTEXT_INVALID", "binding context must be an object")
39295
+ issue2(path28, "CARD_BINDING_CONTEXT_INVALID", "binding context must be an object")
39197
39296
  ];
39198
39297
  }
39199
39298
  exactKeys(value, [
@@ -39205,36 +39304,36 @@ function getA2UICardBindingContextIssues(value, path26 = "bindingContext") {
39205
39304
  "generatedAt",
39206
39305
  "candidates",
39207
39306
  "preferredTools"
39208
- ], path26, issues);
39307
+ ], path28, issues);
39209
39308
  if (value.schemaVersion !== "1") {
39210
- issues.push(issue2(`${path26}.schemaVersion`, "CARD_BINDING_CONTEXT_INVALID", "schemaVersion must be 1"));
39309
+ issues.push(issue2(`${path28}.schemaVersion`, "CARD_BINDING_CONTEXT_INVALID", "schemaVersion must be 1"));
39211
39310
  }
39212
39311
  for (const key of ["draftId", "resourceId"]) {
39213
39312
  if (!isSafeIdentifier(value[key])) {
39214
- issues.push(issue2(`${path26}.${key}`, "CARD_BINDING_CONTEXT_INVALID", `${key} is invalid`));
39313
+ issues.push(issue2(`${path28}.${key}`, "CARD_BINDING_CONTEXT_INVALID", `${key} is invalid`));
39215
39314
  }
39216
39315
  }
39217
39316
  for (const key of ["draftStructureChecksum", "mcpConfigChecksum"]) {
39218
39317
  if (typeof value[key] !== "string" || !/^[0-9a-f]{64}$/u.test(value[key])) {
39219
- issues.push(issue2(`${path26}.${key}`, "CARD_BINDING_CONTEXT_INVALID", `${key} must be a sha256 checksum`));
39318
+ issues.push(issue2(`${path28}.${key}`, "CARD_BINDING_CONTEXT_INVALID", `${key} must be a sha256 checksum`));
39220
39319
  }
39221
39320
  }
39222
39321
  if (typeof value.generatedAt !== "string" || !Number.isFinite(Date.parse(value.generatedAt))) {
39223
- issues.push(issue2(`${path26}.generatedAt`, "CARD_BINDING_CONTEXT_INVALID", "generatedAt must be an ISO timestamp"));
39322
+ issues.push(issue2(`${path28}.generatedAt`, "CARD_BINDING_CONTEXT_INVALID", "generatedAt must be an ISO timestamp"));
39224
39323
  }
39225
- validateCandidates(value.candidates, `${path26}.candidates`, issues);
39226
- validatePreferences(value.preferredTools, `${path26}.preferredTools`, issues);
39324
+ validateCandidates(value.candidates, `${path28}.candidates`, issues);
39325
+ validatePreferences(value.preferredTools, `${path28}.preferredTools`, issues);
39227
39326
  return issues;
39228
39327
  }
39229
- function getA2UICardBindingSelectionIssues(value, path26 = "bindings", fields) {
39328
+ function getA2UICardBindingSelectionIssues(value, path28 = "bindings", fields) {
39230
39329
  const issues = [];
39231
39330
  if (!Array.isArray(value)) {
39232
- return [issue2(path26, "CARD_BINDING_INVALID", "bindings must be an array")];
39331
+ return [issue2(path28, "CARD_BINDING_INVALID", "bindings must be an array")];
39233
39332
  }
39234
39333
  const fieldById = new Map(fields?.map((field) => [field.fieldId, field]) ?? []);
39235
39334
  const seen = /* @__PURE__ */ new Set();
39236
39335
  value.forEach((candidate, index) => {
39237
- const itemPath = `${path26}[${index}]`;
39336
+ const itemPath = `${path28}[${index}]`;
39238
39337
  if (!isPlainRecord(candidate)) {
39239
39338
  issues.push(issue2(itemPath, "CARD_BINDING_INVALID", "binding must be an object"));
39240
39339
  return;
@@ -39347,14 +39446,14 @@ function validateA2UICardBindings(input, options = {}) {
39347
39446
  validateConsistencyGroups(input.draft.manifest.fields, bindings, issues, selectedFields);
39348
39447
  return issues;
39349
39448
  }
39350
- function validateCandidates(value, path26, issues) {
39449
+ function validateCandidates(value, path28, issues) {
39351
39450
  if (!Array.isArray(value) || value.length > 200) {
39352
- issues.push(issue2(path26, "CARD_BINDING_CONTEXT_INVALID", "candidates must be an array with at most 200 items"));
39451
+ issues.push(issue2(path28, "CARD_BINDING_CONTEXT_INVALID", "candidates must be an array with at most 200 items"));
39353
39452
  return;
39354
39453
  }
39355
39454
  const candidateKeys = /* @__PURE__ */ new Set();
39356
39455
  value.forEach((candidate, index) => {
39357
- const itemPath = `${path26}[${index}]`;
39456
+ const itemPath = `${path28}[${index}]`;
39358
39457
  if (!isPlainRecord(candidate)) {
39359
39458
  issues.push(issue2(itemPath, "CARD_BINDING_CONTEXT_INVALID", "candidate must be an object"));
39360
39459
  return;
@@ -39395,9 +39494,9 @@ function validateCandidates(value, path26, issues) {
39395
39494
  }
39396
39495
  });
39397
39496
  }
39398
- function validateTool(value, path26, resourceId, issues) {
39497
+ function validateTool(value, path28, resourceId, issues) {
39399
39498
  if (!isPlainRecord(value)) {
39400
- issues.push(issue2(path26, "CARD_BINDING_CONTEXT_INVALID", "tool must be an object"));
39499
+ issues.push(issue2(path28, "CARD_BINDING_CONTEXT_INVALID", "tool must be an object"));
39401
39500
  return;
39402
39501
  }
39403
39502
  exactKeys(value, [
@@ -39408,16 +39507,16 @@ function validateTool(value, path26, resourceId, issues) {
39408
39507
  "outputSchema",
39409
39508
  "outputSchemaMode",
39410
39509
  "annotations"
39411
- ], path26, issues);
39510
+ ], path28, issues);
39412
39511
  if (value.resourceId !== resourceId) {
39413
- issues.push(issue2(`${path26}.resourceId`, "CARD_BINDING_CONTEXT_INVALID", "tool resourceId must match candidate"));
39512
+ issues.push(issue2(`${path28}.resourceId`, "CARD_BINDING_CONTEXT_INVALID", "tool resourceId must match candidate"));
39414
39513
  }
39415
39514
  if (typeof value.toolName !== "string" || !value.toolName.trim()) {
39416
- issues.push(issue2(`${path26}.toolName`, "CARD_BINDING_CONTEXT_INVALID", "toolName is required"));
39515
+ issues.push(issue2(`${path28}.toolName`, "CARD_BINDING_CONTEXT_INVALID", "toolName is required"));
39417
39516
  }
39418
- issues.push(...getJsonSchemaIssues(value.inputSchema, `${path26}.inputSchema`));
39517
+ issues.push(...getJsonSchemaIssues(value.inputSchema, `${path28}.inputSchema`));
39419
39518
  if (value.outputSchemaMode !== void 0 && value.outputSchemaMode !== "declared" && value.outputSchemaMode !== "opaque") {
39420
- issues.push(issue2(`${path26}.outputSchemaMode`, "CARD_BINDING_CONTEXT_INVALID", "outputSchemaMode must be declared or opaque"));
39519
+ issues.push(issue2(`${path28}.outputSchemaMode`, "CARD_BINDING_CONTEXT_INVALID", "outputSchemaMode must be declared or opaque"));
39421
39520
  }
39422
39521
  }
39423
39522
  function normalizeBindingContext(context) {
@@ -39438,16 +39537,16 @@ function normalizeBindingContext(context) {
39438
39537
  });
39439
39538
  return cloned;
39440
39539
  }
39441
- function validatePreferences(value, path26, issues) {
39540
+ function validatePreferences(value, path28, issues) {
39442
39541
  if (value === void 0)
39443
39542
  return;
39444
39543
  if (!Array.isArray(value) || value.length > 512) {
39445
- issues.push(issue2(path26, "CARD_BINDING_CONTEXT_INVALID", "preferredTools must be an array"));
39544
+ issues.push(issue2(path28, "CARD_BINDING_CONTEXT_INVALID", "preferredTools must be an array"));
39446
39545
  return;
39447
39546
  }
39448
39547
  const fields = /* @__PURE__ */ new Set();
39449
39548
  value.forEach((preference, index) => {
39450
- const itemPath = `${path26}[${index}]`;
39549
+ const itemPath = `${path28}[${index}]`;
39451
39550
  if (!isPlainRecord(preference)) {
39452
39551
  issues.push(issue2(itemPath, "CARD_BINDING_CONTEXT_INVALID", "preference must be an object"));
39453
39552
  return;
@@ -39467,14 +39566,14 @@ function validatePreferences(value, path26, issues) {
39467
39566
  fields.add(preference.fieldId);
39468
39567
  });
39469
39568
  }
39470
- function validateInputBindings(value, path26, issues) {
39569
+ function validateInputBindings(value, path28, issues) {
39471
39570
  if (!Array.isArray(value) || value.length > 64) {
39472
- issues.push(issue2(path26, "CARD_BINDING_INVALID", "inputBindings must be an array with at most 64 items"));
39571
+ issues.push(issue2(path28, "CARD_BINDING_INVALID", "inputBindings must be an array with at most 64 items"));
39473
39572
  return;
39474
39573
  }
39475
39574
  const inputs = /* @__PURE__ */ new Set();
39476
39575
  value.forEach((binding, index) => {
39477
- const itemPath = `${path26}[${index}]`;
39576
+ const itemPath = `${path28}[${index}]`;
39478
39577
  if (!isPlainRecord(binding)) {
39479
39578
  issues.push(issue2(itemPath, "CARD_BINDING_INVALID", "input binding must be an object"));
39480
39579
  return;
@@ -39505,18 +39604,18 @@ function validateInputBindings(value, path26, issues) {
39505
39604
  }
39506
39605
  });
39507
39606
  }
39508
- function validateRequiredToolInputs(toolSchema, presentationSchema, bindings, path26, issues) {
39607
+ function validateRequiredToolInputs(toolSchema, presentationSchema, bindings, path28, issues) {
39509
39608
  const byInput = new Map(bindings.map((binding) => [binding.inputPath, binding]));
39510
39609
  for (const input of requiredLeafInputs(toolSchema)) {
39511
39610
  const binding = byInput.get(input.path);
39512
39611
  if (!binding) {
39513
- issues.push(issue2(path26, "CARD_BINDING_INCOMPLETE", `required Tool input ${input.path} is not bound`));
39612
+ issues.push(issue2(path28, "CARD_BINDING_INCOMPLETE", `required Tool input ${input.path} is not bound`));
39514
39613
  continue;
39515
39614
  }
39516
39615
  if (binding.source.kind === "invocation") {
39517
39616
  const source = getJsonSchemaAtDataPointer(presentationSchema, binding.source.path);
39518
39617
  if (!source || !areJsonSchemaTypesCompatible(source.type, input.schema.type)) {
39519
- issues.push(issue2(path26, "CARD_BINDING_INVALID", `invocation source ${binding.source.path} is incompatible with ${input.path}`));
39618
+ issues.push(issue2(path28, "CARD_BINDING_INVALID", `invocation source ${binding.source.path} is incompatible with ${input.path}`));
39520
39619
  }
39521
39620
  }
39522
39621
  }
@@ -39528,11 +39627,11 @@ function requiredLeafInputs(schema2, basePath = "", parentRequired = true) {
39528
39627
  return Object.entries(schema2.properties).flatMap(([name, child]) => {
39529
39628
  if (!isPlainRecord(child))
39530
39629
  return [];
39531
- const path26 = `${basePath}/${name.replace(/~/gu, "~0").replace(/\//gu, "~1")}`;
39630
+ const path28 = `${basePath}/${name.replace(/~/gu, "~0").replace(/\//gu, "~1")}`;
39532
39631
  const isRequired = parentRequired && required2.has(name);
39533
39632
  if (child.type === "object")
39534
- return requiredLeafInputs(child, path26, isRequired);
39535
- return isRequired ? [{ path: path26, schema: child }] : [];
39633
+ return requiredLeafInputs(child, path28, isRequired);
39634
+ return isRequired ? [{ path: path28, schema: child }] : [];
39536
39635
  });
39537
39636
  }
39538
39637
  function validateConsistencyGroups(fields, bindings, issues, selectedFields) {
@@ -39893,16 +39992,16 @@ var A2UI_V4_COMPONENT_CATALOG = Object.freeze({
39893
39992
  }
39894
39993
  }
39895
39994
  });
39896
- function getA2UIV4ProtocolIssues(value, path26 = "card") {
39995
+ function getA2UIV4ProtocolIssues(value, path28 = "card") {
39897
39996
  const issues = [];
39898
39997
  if (!Array.isArray(value) || value.length === 0)
39899
39998
  return [
39900
- issue2(path26, "INVALID_A2UI_PROTOCOL", "card must be a non-empty array")
39999
+ issue2(path28, "INVALID_A2UI_PROTOCOL", "card must be a non-empty array")
39901
40000
  ];
39902
40001
  const surfaces = /* @__PURE__ */ new Map();
39903
40002
  const createdSurfaces = /* @__PURE__ */ new Set();
39904
40003
  for (const [messageIndex, message] of value.entries()) {
39905
- const messagePath = `${path26}[${messageIndex}]`;
40004
+ const messagePath = `${path28}[${messageIndex}]`;
39906
40005
  if (!isPlainRecord(message) || message.version !== "0.9" || !Array.isArray(message.datas)) {
39907
40006
  issues.push(issue2(messagePath, "INVALID_A2UI_MESSAGE", "V4 messages require version 0.9 and a datas array"));
39908
40007
  continue;
@@ -39956,9 +40055,9 @@ function getA2UIV4ProtocolIssues(value, path26 = "card") {
39956
40055
  }
39957
40056
  surfaces.forEach((_components, surfaceId) => {
39958
40057
  if (!createdSurfaces.has(surfaceId))
39959
- issues.push(issue2(`${path26}.surfaces.${surfaceId}`, "MISSING_CREATE_SURFACE", "every V4 surface must declare createSurface with the V4 catalog"));
40058
+ issues.push(issue2(`${path28}.surfaces.${surfaceId}`, "MISSING_CREATE_SURFACE", "every V4 surface must declare createSurface with the V4 catalog"));
39960
40059
  });
39961
- validateReferences(surfaces, path26, issues);
40060
+ validateReferences(surfaces, path28, issues);
39962
40061
  return issues;
39963
40062
  }
39964
40063
  function validateV4Component(component, componentPath, issues) {
@@ -40001,15 +40100,15 @@ function validateV4Component(component, componentPath, issues) {
40001
40100
  if (component.action !== void 0)
40002
40101
  validateAction(component.action, `${componentPath}.action`, issues, 0);
40003
40102
  }
40004
- function validateComponents(payload, path26, surfaces, issues) {
40103
+ function validateComponents(payload, path28, surfaces, issues) {
40005
40104
  if (!Array.isArray(payload.components)) {
40006
- issues.push(issue2(`${path26}.updateComponents.components`, "INVALID_A2UI_COMPONENTS", "components must be an array"));
40105
+ issues.push(issue2(`${path28}.updateComponents.components`, "INVALID_A2UI_COMPONENTS", "components must be an array"));
40007
40106
  return;
40008
40107
  }
40009
40108
  const surface = surfaces.get(payload.surfaceId) ?? /* @__PURE__ */ new Map();
40010
40109
  surfaces.set(payload.surfaceId, surface);
40011
40110
  payload.components.forEach((component, index) => {
40012
- const componentPath = `${path26}.updateComponents.components[${index}]`;
40111
+ const componentPath = `${path28}.updateComponents.components[${index}]`;
40013
40112
  if (!isPlainRecord(component) || !isSafeIdentifier(component.id) || typeof component.component !== "string") {
40014
40113
  issues.push(issue2(componentPath, "INVALID_A2UI_COMPONENT", "component requires a safe id and component name"));
40015
40114
  return;
@@ -40020,23 +40119,23 @@ function validateComponents(payload, path26, surfaces, issues) {
40020
40119
  validateV4Component(component, componentPath, issues);
40021
40120
  });
40022
40121
  }
40023
- function validateProperty(value, schema2, path26, issues, propertyName) {
40122
+ function validateProperty(value, schema2, path28, issues, propertyName) {
40024
40123
  if (schema2.kind === "binding") {
40025
40124
  const stringOnly = propertyName === "label" || propertyName === "src" || propertyName === "alt" || propertyName === "image";
40026
40125
  const literalValid = typeof value === "string" || !stringOnly && typeof value === "number" && Number.isFinite(value);
40027
40126
  if (!literalValid && !isDisplayBinding(value, stringOnly))
40028
- issues.push(issue2(path26, "INVALID_DISPLAY_VALUE", `display value must be ${stringOnly ? "a string" : "a string or finite number"}, or a compatible display binding`));
40127
+ issues.push(issue2(path28, "INVALID_DISPLAY_VALUE", `display value must be ${stringOnly ? "a string" : "a string or finite number"}, or a compatible display binding`));
40029
40128
  return;
40030
40129
  }
40031
40130
  if (schema2.kind === "child") {
40032
40131
  if (!isSafeIdentifier(value))
40033
- issues.push(issue2(path26, "INVALID_CHILD", "child must be a safe component id"));
40132
+ issues.push(issue2(path28, "INVALID_CHILD", "child must be a safe component id"));
40034
40133
  return;
40035
40134
  }
40036
40135
  if (schema2.kind === "children") {
40037
40136
  const valid = Array.isArray(value) ? value.every(isSafeIdentifier) : isPlainRecord(value) && Object.keys(value).length === 2 && isSafeIdentifier(value.componentId) && typeof value.path === "string" && isSafePath(value.path);
40038
40137
  if (!valid)
40039
- issues.push(issue2(path26, "INVALID_CHILDREN", "children must be component ids or one dynamic children binding"));
40138
+ issues.push(issue2(path28, "INVALID_CHILDREN", "children must be component ids or one dynamic children binding"));
40040
40139
  return;
40041
40140
  }
40042
40141
  if (schema2.kind === "action")
@@ -40044,11 +40143,11 @@ function validateProperty(value, schema2, path26, issues, propertyName) {
40044
40143
  if (schema2.kind === "options" || schema2.kind === "format")
40045
40144
  return;
40046
40145
  if (schema2.kind === "boolean" && typeof value !== "boolean")
40047
- issues.push(issue2(path26, "INVALID_COMPONENT_PROP_TYPE", "value must be boolean"));
40146
+ issues.push(issue2(path28, "INVALID_COMPONENT_PROP_TYPE", "value must be boolean"));
40048
40147
  if (schema2.kind === "number" && !Number.isFinite(value))
40049
- issues.push(issue2(path26, "INVALID_COMPONENT_PROP_VALUE", "value must be a finite number"));
40148
+ issues.push(issue2(path28, "INVALID_COMPONENT_PROP_VALUE", "value must be a finite number"));
40050
40149
  if (schema2.kind === "string" && typeof value !== "string")
40051
- issues.push(issue2(path26, "INVALID_COMPONENT_PROP_VALUE", "value must be a string"));
40150
+ issues.push(issue2(path28, "INVALID_COMPONENT_PROP_VALUE", "value must be a string"));
40052
40151
  }
40053
40152
  function isDisplayBinding(value, stringOnly = false) {
40054
40153
  if (!isPlainRecord(value) || typeof value.path !== "string" || !isSafePath(value.path))
@@ -40062,89 +40161,89 @@ function isStrictBinding(value) {
40062
40161
  function isSafePath(value) {
40063
40162
  return (value === "/" || value.startsWith("/") || value.startsWith("./")) && !value.split("/").some((part) => ["__proto__", "constructor", "prototype"].includes(part));
40064
40163
  }
40065
- function validateAction(value, path26, issues, depth) {
40164
+ function validateAction(value, path28, issues, depth) {
40066
40165
  if (!isPlainRecord(value) || depth > 4) {
40067
- issues.push(issue2(path26, "INVALID_ACTION", "action must be an object with at most four nested selects"));
40166
+ issues.push(issue2(path28, "INVALID_ACTION", "action must be an object with at most four nested selects"));
40068
40167
  return;
40069
40168
  }
40070
40169
  const branches = ["event", "function", "local", "client", "select"].filter((key) => key in value);
40071
40170
  if (branches.length !== 1 || Object.keys(value).length !== 1) {
40072
- issues.push(issue2(path26, "INVALID_ACTION", "action must contain exactly one branch"));
40171
+ issues.push(issue2(path28, "INVALID_ACTION", "action must contain exactly one branch"));
40073
40172
  return;
40074
40173
  }
40075
40174
  const branch = branches[0];
40076
40175
  const body = value[branch];
40077
40176
  if (!isPlainRecord(body))
40078
- return void issues.push(issue2(`${path26}.${branch}`, "INVALID_ACTION", `${branch} must be an object`));
40177
+ return void issues.push(issue2(`${path28}.${branch}`, "INVALID_ACTION", `${branch} must be an object`));
40079
40178
  if (branch === "event") {
40080
- rejectUnknownKeys(body, ["name", "context", "x2-user-message", "target"], `${path26}.event`, issues);
40179
+ rejectUnknownKeys(body, ["name", "context", "x2-user-message", "target"], `${path28}.event`, issues);
40081
40180
  if (typeof body.name !== "string" || !/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/.test(body.name) || body.name.length > 96)
40082
- issues.push(issue2(`${path26}.event.name`, "INVALID_ACTION_NAME", "event name is invalid"));
40181
+ issues.push(issue2(`${path28}.event.name`, "INVALID_ACTION_NAME", "event name is invalid"));
40083
40182
  if (body.context !== void 0 && !isPlainRecord(body.context))
40084
- issues.push(issue2(`${path26}.event.context`, "INVALID_ACTION_CONTEXT", "event context must be an object"));
40183
+ issues.push(issue2(`${path28}.event.context`, "INVALID_ACTION_CONTEXT", "event context must be an object"));
40085
40184
  else if (body.context !== void 0)
40086
- validateActionDynamicValue(body.context, `${path26}.event.context`, issues);
40185
+ validateActionDynamicValue(body.context, `${path28}.event.context`, issues);
40087
40186
  if (body["x2-user-message"] !== void 0 && typeof body["x2-user-message"] !== "string" && !isStrictBinding(body["x2-user-message"]))
40088
- issues.push(issue2(`${path26}.event.x2-user-message`, "INVALID_ACTION_CONTEXT", "x2-user-message must be a string or strict binding"));
40187
+ issues.push(issue2(`${path28}.event.x2-user-message`, "INVALID_ACTION_CONTEXT", "x2-user-message must be a string or strict binding"));
40089
40188
  if (body.target !== void 0)
40090
- validateOverlayTarget(body.target, `${path26}.event.target`, issues);
40189
+ validateOverlayTarget(body.target, `${path28}.event.target`, issues);
40091
40190
  } else if (branch === "function") {
40092
- rejectUnknownKeys(body, ["ref"], `${path26}.function`, issues);
40191
+ rejectUnknownKeys(body, ["ref"], `${path28}.function`, issues);
40093
40192
  if (!isFunctionActionRef(body.ref))
40094
- issues.push(issue2(`${path26}.function.ref`, "INVALID_FUNCTION_ACTION_REF", "function ref must be a dot-separated identifier up to 128 characters"));
40193
+ issues.push(issue2(`${path28}.function.ref`, "INVALID_FUNCTION_ACTION_REF", "function ref must be a dot-separated identifier up to 128 characters"));
40095
40194
  } else if (branch === "local") {
40096
- rejectUnknownKeys(body, ["name", "path", "value"], `${path26}.local`, issues);
40195
+ rejectUnknownKeys(body, ["name", "path", "value"], `${path28}.local`, issues);
40097
40196
  if (body.name !== "data.set" || typeof body.path !== "string" || !isSafePath(body.path) || !Object.prototype.hasOwnProperty.call(body, "value"))
40098
- issues.push(issue2(`${path26}.local`, "INVALID_LOCAL_ACTION", "local action must be data.set with a safe path and value"));
40197
+ issues.push(issue2(`${path28}.local`, "INVALID_LOCAL_ACTION", "local action must be data.set with a safe path and value"));
40099
40198
  else
40100
- validateActionDynamicValue(body.value, `${path26}.local.value`, issues);
40199
+ validateActionDynamicValue(body.value, `${path28}.local.value`, issues);
40101
40200
  } else if (branch === "client") {
40102
- validateClientAction(body, `${path26}.client`, issues);
40201
+ validateClientAction(body, `${path28}.client`, issues);
40103
40202
  } else {
40104
- rejectUnknownKeys(body, ["value", "cases", "default"], `${path26}.select`, issues);
40203
+ rejectUnknownKeys(body, ["value", "cases", "default"], `${path28}.select`, issues);
40105
40204
  if (!isStrictBinding(body.value) || !Array.isArray(body.cases) || body.cases.length < 1 || body.cases.length > 16)
40106
- return void issues.push(issue2(`${path26}.select`, "INVALID_SELECT_ACTION", "select requires a strict binding and 1-16 cases"));
40205
+ return void issues.push(issue2(`${path28}.select`, "INVALID_SELECT_ACTION", "select requires a strict binding and 1-16 cases"));
40107
40206
  const seen = /* @__PURE__ */ new Set();
40108
40207
  body.cases.forEach((entry, index) => {
40109
40208
  if (!isPlainRecord(entry) || Object.keys(entry).some((key2) => key2 !== "equals" && key2 !== "action") || !["string", "number", "boolean"].includes(typeof entry.equals) && entry.equals !== null || !Object.prototype.hasOwnProperty.call(entry, "action"))
40110
- return void issues.push(issue2(`${path26}.select.cases[${index}]`, "INVALID_SELECT_CASE", "case requires only a primitive equals and action"));
40209
+ return void issues.push(issue2(`${path28}.select.cases[${index}]`, "INVALID_SELECT_CASE", "case requires only a primitive equals and action"));
40111
40210
  const key = JSON.stringify([typeof entry.equals, entry.equals]);
40112
40211
  if (seen.has(key))
40113
- issues.push(issue2(`${path26}.select.cases[${index}].equals`, "DUPLICATE_SELECT_CASE", "select case values must be unique"));
40212
+ issues.push(issue2(`${path28}.select.cases[${index}].equals`, "DUPLICATE_SELECT_CASE", "select case values must be unique"));
40114
40213
  seen.add(key);
40115
- validateAction(entry.action, `${path26}.select.cases[${index}].action`, issues, depth + 1);
40214
+ validateAction(entry.action, `${path28}.select.cases[${index}].action`, issues, depth + 1);
40116
40215
  });
40117
40216
  if (body.default !== void 0)
40118
- validateAction(body.default, `${path26}.select.default`, issues, depth + 1);
40217
+ validateAction(body.default, `${path28}.select.default`, issues, depth + 1);
40119
40218
  }
40120
40219
  }
40121
40220
  function isFunctionActionRef(value) {
40122
40221
  return typeof value === "string" && value.length <= 128 && /^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u.test(value);
40123
40222
  }
40124
- function validateClientAction(body, path26, issues) {
40125
- rejectUnknownKeys(body, ["name", "context"], path26, issues);
40223
+ function validateClientAction(body, path28, issues) {
40224
+ rejectUnknownKeys(body, ["name", "context"], path28, issues);
40126
40225
  if (body.name === "ui.overlay.close") {
40127
40226
  if (body.context !== void 0)
40128
- issues.push(issue2(`${path26}.context`, "INVALID_CLIENT_ACTION_CONTEXT", "ui.overlay.close does not accept context"));
40227
+ issues.push(issue2(`${path28}.context`, "INVALID_CLIENT_ACTION_CONTEXT", "ui.overlay.close does not accept context"));
40129
40228
  return;
40130
40229
  }
40131
40230
  if (body.name === "ui.surface.open") {
40132
40231
  if (!isPlainRecord(body.context) || Object.keys(body.context).length !== 1 || typeof body.context.surfaceId !== "string")
40133
- issues.push(issue2(`${path26}.context`, "INVALID_CLIENT_ACTION_CONTEXT", "ui.surface.open requires context.surfaceId"));
40232
+ issues.push(issue2(`${path28}.context`, "INVALID_CLIENT_ACTION_CONTEXT", "ui.surface.open requires context.surfaceId"));
40134
40233
  return;
40135
40234
  }
40136
40235
  if (body.name === "ui.page.open" || body.name === "ui.miniprogram.embed") {
40137
40236
  if (!isPlainRecord(body.context) || Object.keys(body.context).length !== 1 || typeof body.context.url !== "string" && !isStrictBinding(body.context.url))
40138
- issues.push(issue2(`${path26}.context`, "INVALID_CLIENT_ACTION_CONTEXT", `${body.name} requires one literal or bound URL`));
40237
+ issues.push(issue2(`${path28}.context`, "INVALID_CLIENT_ACTION_CONTEXT", `${body.name} requires one literal or bound URL`));
40139
40238
  else if (typeof body.context.url === "string" && !isSafePageUrl(body.context.url, body.name))
40140
- issues.push(issue2(`${path26}.context.url`, "INVALID_PAGE_URL", body.name === "ui.miniprogram.embed" ? "ui.miniprogram.embed URL must include appId parameter" : "ui.page.open URL must use https or the approved Alipay scheme"));
40239
+ issues.push(issue2(`${path28}.context.url`, "INVALID_PAGE_URL", body.name === "ui.miniprogram.embed" ? "ui.miniprogram.embed URL must include appId parameter" : "ui.page.open URL must use https or the approved Alipay scheme"));
40141
40240
  return;
40142
40241
  }
40143
- issues.push(issue2(`${path26}.name`, "UNSUPPORTED_CLIENT_ACTION", `unsupported client action ${String(body.name)}`));
40242
+ issues.push(issue2(`${path28}.name`, "UNSUPPORTED_CLIENT_ACTION", `unsupported client action ${String(body.name)}`));
40144
40243
  }
40145
- function validateActionDynamicValue(value, path26, issues) {
40244
+ function validateActionDynamicValue(value, path28, issues) {
40146
40245
  if (Array.isArray(value)) {
40147
- value.forEach((entry, index) => validateActionDynamicValue(entry, `${path26}[${index}]`, issues));
40246
+ value.forEach((entry, index) => validateActionDynamicValue(entry, `${path28}[${index}]`, issues));
40148
40247
  return;
40149
40248
  }
40150
40249
  if (!isPlainRecord(value))
@@ -40152,96 +40251,96 @@ function validateActionDynamicValue(value, path26, issues) {
40152
40251
  const keys2 = Object.keys(value);
40153
40252
  if (keys2.includes("path") && keys2.every((key) => key === "path" || key === "fallback")) {
40154
40253
  if (!isStrictBinding(value))
40155
- issues.push(issue2(path26, "INVALID_ACTION_BINDING", "action values require a strict binding without fallback"));
40254
+ issues.push(issue2(path28, "INVALID_ACTION_BINDING", "action values require a strict binding without fallback"));
40156
40255
  return;
40157
40256
  }
40158
- Object.entries(value).forEach(([key, entry]) => validateActionDynamicValue(entry, `${path26}.${key}`, issues));
40257
+ Object.entries(value).forEach(([key, entry]) => validateActionDynamicValue(entry, `${path28}.${key}`, issues));
40159
40258
  }
40160
- function validateOverlayTarget(value, path26, issues) {
40259
+ function validateOverlayTarget(value, path28, issues) {
40161
40260
  if (!isPlainRecord(value) || value.type !== "overlay" || !isPlainRecord(value.presentation) || value.presentation.kind !== "bottom-sheet")
40162
- issues.push(issue2(path26, "INVALID_EVENT_TARGET", "event target must be an overlay bottom-sheet presentation"));
40261
+ issues.push(issue2(path28, "INVALID_EVENT_TARGET", "event target must be an overlay bottom-sheet presentation"));
40163
40262
  }
40164
- function validateOptions(value, path26, issues) {
40263
+ function validateOptions(value, path28, issues) {
40165
40264
  if (isStrictBinding(value))
40166
40265
  return;
40167
40266
  if (!Array.isArray(value) || value.length === 0)
40168
- return void issues.push(issue2(path26, "INVALID_OPTIONS", "options must be a non-empty array"));
40267
+ return void issues.push(issue2(path28, "INVALID_OPTIONS", "options must be a non-empty array"));
40169
40268
  const seen = /* @__PURE__ */ new Set();
40170
40269
  value.forEach((entry, index) => {
40171
40270
  if (!isPlainRecord(entry) || Object.keys(entry).some((key) => key !== "label" && key !== "value") || typeof entry.label !== "string" || !entry.label || typeof entry.value !== "string" || !entry.value)
40172
- issues.push(issue2(`${path26}[${index}]`, "INVALID_OPTION", "option requires only non-empty label and value"));
40271
+ issues.push(issue2(`${path28}[${index}]`, "INVALID_OPTION", "option requires only non-empty label and value"));
40173
40272
  else if (seen.has(entry.value))
40174
- issues.push(issue2(`${path26}[${index}].value`, "DUPLICATE_OPTION_VALUE", "option values must be unique"));
40273
+ issues.push(issue2(`${path28}[${index}].value`, "DUPLICATE_OPTION_VALUE", "option values must be unique"));
40175
40274
  else
40176
40275
  seen.add(entry.value);
40177
40276
  });
40178
40277
  }
40179
- function validateTextField(component, path26, issues) {
40278
+ function validateTextField(component, path28, issues) {
40180
40279
  if (!isStrictBinding(component.value))
40181
- issues.push(issue2(`${path26}.value`, "INPUT_REQUIRES_BINDING", "TextField.value must be a strict writable binding"));
40280
+ issues.push(issue2(`${path28}.value`, "INPUT_REQUIRES_BINDING", "TextField.value must be a strict writable binding"));
40182
40281
  if (component["x2-limit"] !== void 0 && (!Number.isInteger(component["x2-limit"]) || Number(component["x2-limit"]) < 1 || Number(component["x2-limit"]) > 1e4))
40183
- issues.push(issue2(`${path26}.x2-limit`, "INVALID_TEXT_LIMIT", "x2-limit must be an integer from 1 to 10000"));
40282
+ issues.push(issue2(`${path28}.x2-limit`, "INVALID_TEXT_LIMIT", "x2-limit must be an integer from 1 to 10000"));
40184
40283
  if (typeof component.validationRegexp === "string") {
40185
40284
  if (component.validationRegexp.length > 512)
40186
- issues.push(issue2(`${path26}.validationRegexp`, "INVALID_VALIDATION_REGEXP", "validationRegexp is too long"));
40285
+ issues.push(issue2(`${path28}.validationRegexp`, "INVALID_VALIDATION_REGEXP", "validationRegexp is too long"));
40187
40286
  else
40188
40287
  try {
40189
40288
  RegExp(component.validationRegexp);
40190
40289
  } catch {
40191
- issues.push(issue2(`${path26}.validationRegexp`, "INVALID_VALIDATION_REGEXP", "validationRegexp is invalid"));
40290
+ issues.push(issue2(`${path28}.validationRegexp`, "INVALID_VALIDATION_REGEXP", "validationRegexp is invalid"));
40192
40291
  }
40193
40292
  }
40194
40293
  }
40195
- function validateStepper(component, path26, issues) {
40294
+ function validateStepper(component, path28, issues) {
40196
40295
  if (!isStrictBinding(component.value))
40197
- issues.push(issue2(`${path26}.value`, "INPUT_REQUIRES_BINDING", "Stepper.value must be a strict writable binding"));
40296
+ issues.push(issue2(`${path28}.value`, "INPUT_REQUIRES_BINDING", "Stepper.value must be a strict writable binding"));
40198
40297
  if (component.step !== void 0 && (!Number.isFinite(component.step) || Number(component.step) <= 0))
40199
- issues.push(issue2(`${path26}.step`, "INVALID_STEPPER_RANGE", "step must be greater than zero"));
40298
+ issues.push(issue2(`${path28}.step`, "INVALID_STEPPER_RANGE", "step must be greater than zero"));
40200
40299
  if (Number.isFinite(component.min) && Number.isFinite(component.max) && Number(component.min) > Number(component.max))
40201
- issues.push(issue2(`${path26}`, "INVALID_STEPPER_RANGE", "min must not exceed max"));
40300
+ issues.push(issue2(`${path28}`, "INVALID_STEPPER_RANGE", "min must not exceed max"));
40202
40301
  }
40203
- function validateChecks(value, path26, issues) {
40302
+ function validateChecks(value, path28, issues) {
40204
40303
  if (!Array.isArray(value))
40205
- return void issues.push(issue2(path26, "INVALID_CHECKS", "checks must be an array"));
40304
+ return void issues.push(issue2(path28, "INVALID_CHECKS", "checks must be an array"));
40206
40305
  value.forEach((entry, index) => {
40207
40306
  if (!isPlainRecord(entry) || Object.keys(entry).some((key) => key !== "required" && key !== "value" && key !== "message") || entry.required !== true || !isStrictBinding(entry.value) || entry.message !== void 0 && typeof entry.message !== "string") {
40208
- issues.push(issue2(`${path26}[${index}]`, "INVALID_CHECK", "check must be an implemented required check with a strict binding"));
40307
+ issues.push(issue2(`${path28}[${index}]`, "INVALID_CHECK", "check must be an implemented required check with a strict binding"));
40209
40308
  }
40210
40309
  });
40211
40310
  }
40212
- function validateOverflow(component, path26, issues) {
40311
+ function validateOverflow(component, path28, issues) {
40213
40312
  const value = component["x2-overflow"];
40214
40313
  const children = component.children;
40215
40314
  if (!isPlainRecord(children) || !isPlainRecord(value)) {
40216
- issues.push(issue2(`${path26}.x2-overflow`, "INVALID_OVERFLOW", "x2-overflow requires dynamic children and an object value"));
40315
+ issues.push(issue2(`${path28}.x2-overflow`, "INVALID_OVERFLOW", "x2-overflow requires dynamic children and an object value"));
40217
40316
  return;
40218
40317
  }
40219
- rejectUnknownKeys(value, ["mode", "previewCount", "trigger", "overlay"], `${path26}.x2-overflow`, issues);
40318
+ rejectUnknownKeys(value, ["mode", "previewCount", "trigger", "overlay"], `${path28}.x2-overflow`, issues);
40220
40319
  if (value.mode !== "overlay-all" || !Number.isInteger(value.previewCount) || Number(value.previewCount) < 0 || Number(value.previewCount) > 100) {
40221
- issues.push(issue2(`${path26}.x2-overflow`, "INVALID_OVERFLOW", "overlay-all requires an integer previewCount from 0 to 100"));
40320
+ issues.push(issue2(`${path28}.x2-overflow`, "INVALID_OVERFLOW", "overlay-all requires an integer previewCount from 0 to 100"));
40222
40321
  }
40223
40322
  if (!isPlainRecord(value.trigger)) {
40224
- issues.push(issue2(`${path26}.x2-overflow.trigger`, "INVALID_OVERFLOW_TRIGGER", "trigger must contain display text"));
40323
+ issues.push(issue2(`${path28}.x2-overflow.trigger`, "INVALID_OVERFLOW_TRIGGER", "trigger must contain display text"));
40225
40324
  } else {
40226
- rejectUnknownKeys(value.trigger, ["text"], `${path26}.x2-overflow.trigger`, issues);
40325
+ rejectUnknownKeys(value.trigger, ["text"], `${path28}.x2-overflow.trigger`, issues);
40227
40326
  if (!isDisplayBinding(value.trigger.text, true) && typeof value.trigger.text !== "string") {
40228
- issues.push(issue2(`${path26}.x2-overflow.trigger.text`, "INVALID_OVERFLOW_TRIGGER", "trigger.text must be a string or display binding"));
40327
+ issues.push(issue2(`${path28}.x2-overflow.trigger.text`, "INVALID_OVERFLOW_TRIGGER", "trigger.text must be a string or display binding"));
40229
40328
  }
40230
40329
  }
40231
40330
  if (!isPlainRecord(value.overlay)) {
40232
- issues.push(issue2(`${path26}.x2-overflow.overlay`, "INVALID_OVERFLOW_PRESENTATION", "overlay must be a bottom-sheet presentation"));
40331
+ issues.push(issue2(`${path28}.x2-overflow.overlay`, "INVALID_OVERFLOW_PRESENTATION", "overlay must be a bottom-sheet presentation"));
40233
40332
  } else {
40234
- rejectUnknownKeys(value.overlay, ["kind", "title", "size"], `${path26}.x2-overflow.overlay`, issues);
40333
+ rejectUnknownKeys(value.overlay, ["kind", "title", "size"], `${path28}.x2-overflow.overlay`, issues);
40235
40334
  if (value.overlay.kind !== "bottom-sheet" || value.overlay.title !== void 0 && typeof value.overlay.title !== "string" || value.overlay.size !== void 0 && !["medium", "large", "full"].includes(String(value.overlay.size))) {
40236
- issues.push(issue2(`${path26}.x2-overflow.overlay`, "INVALID_OVERFLOW_PRESENTATION", "overlay must be a bottom-sheet with an optional string title and supported size"));
40335
+ issues.push(issue2(`${path28}.x2-overflow.overlay`, "INVALID_OVERFLOW_PRESENTATION", "overlay must be a bottom-sheet with an optional string title and supported size"));
40237
40336
  }
40238
40337
  }
40239
40338
  }
40240
- function rejectUnknownKeys(value, allowed, path26, issues) {
40339
+ function rejectUnknownKeys(value, allowed, path28, issues) {
40241
40340
  const allowedKeys = new Set(allowed);
40242
40341
  Object.keys(value).forEach((key) => {
40243
40342
  if (!allowedKeys.has(key))
40244
- issues.push(issue2(`${path26}.${key}`, "UNKNOWN_PROTOCOL_FIELD", `unknown field ${key}`));
40343
+ issues.push(issue2(`${path28}.${key}`, "UNKNOWN_PROTOCOL_FIELD", `unknown field ${key}`));
40245
40344
  });
40246
40345
  }
40247
40346
  function isSafePageUrl(value, actionName) {
@@ -40256,23 +40355,23 @@ function isSafePageUrl(value, actionName) {
40256
40355
  }
40257
40356
  return value.startsWith("https://") || value.startsWith("alipays://");
40258
40357
  }
40259
- function validateReferences(surfaces, path26, issues) {
40358
+ function validateReferences(surfaces, path28, issues) {
40260
40359
  for (const [surfaceId, components] of surfaces) {
40261
40360
  if (!components.has("root"))
40262
- issues.push(issue2(`${path26}.surfaces.${surfaceId}`, "MISSING_ROOT_COMPONENT", "surface must define root"));
40361
+ issues.push(issue2(`${path28}.surfaces.${surfaceId}`, "MISSING_ROOT_COMPONENT", "surface must define root"));
40263
40362
  const edges = /* @__PURE__ */ new Map();
40264
40363
  for (const [id2, component] of components) {
40265
40364
  const refs = getComponentReferences(component);
40266
40365
  edges.set(id2, refs);
40267
40366
  refs.forEach((ref) => {
40268
40367
  if (!components.has(ref))
40269
- issues.push(issue2(`${path26}.surfaces.${surfaceId}.components.${id2}.${component.child !== void 0 ? "child" : "children"}`, "MISSING_COMPONENT_REFERENCE", `component ${ref} does not exist`));
40368
+ issues.push(issue2(`${path28}.surfaces.${surfaceId}.components.${id2}.${component.child !== void 0 ? "child" : "children"}`, "MISSING_COMPONENT_REFERENCE", `component ${ref} does not exist`));
40270
40369
  });
40271
40370
  if ((component.component === "Button" || component.component === "Card" && component.action !== void 0) && refs.some((ref) => hasInteractiveDescendant(ref, components, /* @__PURE__ */ new Set())))
40272
- issues.push(issue2(`${path26}.surfaces.${surfaceId}.components.${id2}.${component.child !== void 0 ? "child" : "children"}`, "NESTED_INTERACTION", "action components cannot contain interactive descendants"));
40371
+ issues.push(issue2(`${path28}.surfaces.${surfaceId}.components.${id2}.${component.child !== void 0 ? "child" : "children"}`, "NESTED_INTERACTION", "action components cannot contain interactive descendants"));
40273
40372
  collectSurfaceOpenReferences(component.action).forEach((targetSurfaceId) => {
40274
40373
  if (!surfaces.has(targetSurfaceId))
40275
- issues.push(issue2(`${path26}.surfaces.${surfaceId}.components.${id2}.action`, "MISSING_SURFACE_REFERENCE", `surface ${targetSurfaceId} does not exist`));
40374
+ issues.push(issue2(`${path28}.surfaces.${surfaceId}.components.${id2}.action`, "MISSING_SURFACE_REFERENCE", `surface ${targetSurfaceId} does not exist`));
40276
40375
  });
40277
40376
  }
40278
40377
  components.forEach((component, id2) => {
@@ -40280,14 +40379,14 @@ function validateReferences(surfaces, path26, issues) {
40280
40379
  return;
40281
40380
  const parents = [...components.values()].filter((parent) => getComponentReferences(parent).includes(id2));
40282
40381
  if (id2 === "root" || parents.length === 0 || parents.some((parent) => parent.component !== "Row" && parent.component !== "Column")) {
40283
- issues.push(issue2(`${path26}.surfaces.${surfaceId}.components.${id2}.grow`, "INVALID_LAYOUT_PARENT", "grow requires a direct Row or Column parent in every occurrence"));
40382
+ issues.push(issue2(`${path28}.surfaces.${surfaceId}.components.${id2}.grow`, "INVALID_LAYOUT_PARENT", "grow requires a direct Row or Column parent in every occurrence"));
40284
40383
  }
40285
40384
  });
40286
40385
  const visiting = /* @__PURE__ */ new Set();
40287
40386
  const visited = /* @__PURE__ */ new Set();
40288
40387
  const walk = (id2) => {
40289
40388
  if (visiting.has(id2))
40290
- return void issues.push(issue2(`${path26}.surfaces.${surfaceId}.components.${id2}`, "CIRCULAR_COMPONENT_REFERENCE", "component references must not contain a cycle"));
40389
+ return void issues.push(issue2(`${path28}.surfaces.${surfaceId}.components.${id2}`, "CIRCULAR_COMPONENT_REFERENCE", "component references must not contain a cycle"));
40291
40390
  if (visited.has(id2))
40292
40391
  return;
40293
40392
  visiting.add(id2);
@@ -40416,29 +40515,29 @@ function getA2UICardDraftBundleIssues(value) {
40416
40515
  }
40417
40516
  return issues;
40418
40517
  }
40419
- function getPersistedV4ProtocolIssues(card, path26) {
40518
+ function getPersistedV4ProtocolIssues(card, path28) {
40420
40519
  const issues = [];
40421
40520
  if (card.length !== 1) {
40422
- issues.push(issue2(path26, "INVALID_PERSISTED_V4_MESSAGES", "V4 persisted cards must use exactly one message"));
40521
+ issues.push(issue2(path28, "INVALID_PERSISTED_V4_MESSAGES", "V4 persisted cards must use exactly one message"));
40423
40522
  }
40424
40523
  const instructions = card.flatMap((message) => message.datas);
40425
40524
  const creates = instructions.filter((instruction) => "createSurface" in instruction);
40426
40525
  const updates = instructions.filter((instruction) => "updateComponents" in instruction);
40427
40526
  if (creates.length < 1 || creates.length !== updates.length || instructions.length !== creates.length + updates.length) {
40428
- issues.push(issue2(path26, "INVALID_PERSISTED_V4_INSTRUCTIONS", "V4 persisted cards require one createSurface and one complete updateComponents per Surface"));
40527
+ issues.push(issue2(path28, "INVALID_PERSISTED_V4_INSTRUCTIONS", "V4 persisted cards require one createSurface and one complete updateComponents per Surface"));
40429
40528
  }
40430
40529
  const createIds = creates.flatMap((instruction) => "createSurface" in instruction ? [instruction.createSurface.surfaceId] : []);
40431
40530
  const updateIds = updates.flatMap((instruction) => "updateComponents" in instruction ? [instruction.updateComponents.surfaceId] : []);
40432
40531
  for (const surfaceId of /* @__PURE__ */ new Set([...createIds, ...updateIds])) {
40433
40532
  if (createIds.filter((id2) => id2 === surfaceId).length !== 1 || updateIds.filter((id2) => id2 === surfaceId).length !== 1) {
40434
- issues.push(issue2(`${path26}.surfaces.${surfaceId}`, "SURFACE_INSTRUCTION_MISMATCH", "each persisted Surface requires exactly one create and one component update"));
40533
+ issues.push(issue2(`${path28}.surfaces.${surfaceId}`, "SURFACE_INSTRUCTION_MISMATCH", "each persisted Surface requires exactly one create and one component update"));
40435
40534
  }
40436
40535
  }
40437
40536
  return issues;
40438
40537
  }
40439
- function validateV4Fixture(value, fields, path26, issues) {
40538
+ function validateV4Fixture(value, fields, path28, issues) {
40440
40539
  if (!isPlainRecord(value)) {
40441
- issues.push(issue2(path26, "INVALID_FIXTURE", "fixture must be a JSON object"));
40540
+ issues.push(issue2(path28, "INVALID_FIXTURE", "fixture must be a JSON object"));
40442
40541
  return;
40443
40542
  }
40444
40543
  for (const field of fields) {
@@ -40447,17 +40546,17 @@ function validateV4Fixture(value, fields, path26, issues) {
40447
40546
  const resolved = getFixtureValue(value, field.path);
40448
40547
  if (!resolved.found) {
40449
40548
  if (field.required)
40450
- issues.push(issue2(`${path26}${field.path}`, "REQUIRED_FIXTURE_FIELD_MISSING", `fixture is missing required field ${field.fieldId}`));
40549
+ issues.push(issue2(`${path28}${field.path}`, "REQUIRED_FIXTURE_FIELD_MISSING", `fixture is missing required field ${field.fieldId}`));
40451
40550
  continue;
40452
40551
  }
40453
- issues.push(...validateJsonSchemaValue2(field.valueSchema, resolved.value, `${path26}${field.path}`));
40552
+ issues.push(...validateJsonSchemaValue2(field.valueSchema, resolved.value, `${path28}${field.path}`));
40454
40553
  }
40455
40554
  }
40456
- function validateV4BindingContracts(card, occurrences, fields, path26, issues, dataModelSchema) {
40555
+ function validateV4BindingContracts(card, occurrences, fields, path28, issues, dataModelSchema) {
40457
40556
  const ordered = fields.slice().sort((left, right) => right.path.length - left.path.length);
40458
40557
  for (const occurrence of occurrences) {
40459
40558
  const field = ordered.find((candidate) => occurrence.canonicalPath === candidate.path || occurrence.canonicalPath.startsWith(`${candidate.path}/*/`) || occurrence.canonicalPath.startsWith(`${candidate.path}/`));
40460
- const issuePath = `${path26}.surfaces.${occurrence.surfaceId ?? "unknown"}.components.${occurrence.componentId}.${occurrence.propertyPath}`;
40559
+ const issuePath = `${path28}.surfaces.${occurrence.surfaceId ?? "unknown"}.components.${occurrence.componentId}.${occurrence.propertyPath}`;
40461
40560
  if (!field && !dataModelSchema) {
40462
40561
  issues.push(issue2(issuePath, "UNDECLARED_BINDING_PATH", `binding path ${occurrence.rawPath} is not declared by a manifest field`));
40463
40562
  continue;
@@ -40665,14 +40764,14 @@ function getA2UICardResourceConfigV3Issues(value) {
40665
40764
  }
40666
40765
  return issues;
40667
40766
  }
40668
- function validateDataSources(value, path26, issues, options = {}) {
40767
+ function validateDataSources(value, path28, issues, options = {}) {
40669
40768
  if (!Array.isArray(value)) {
40670
- issues.push(issue2(path26, "INVALID_DATA_SOURCES", "dataSources must be a non-empty array"));
40769
+ issues.push(issue2(path28, "INVALID_DATA_SOURCES", "dataSources must be a non-empty array"));
40671
40770
  return void 0;
40672
40771
  }
40673
40772
  const ids = /* @__PURE__ */ new Set();
40674
40773
  value.forEach((candidate, index) => {
40675
- const itemPath = `${path26}[${index}]`;
40774
+ const itemPath = `${path28}[${index}]`;
40676
40775
  if (!isPlainRecord(candidate)) {
40677
40776
  issues.push(issue2(itemPath, "INVALID_DATA_SOURCE", "data source must be an object"));
40678
40777
  return;
@@ -40710,7 +40809,7 @@ function validateDataSources(value, path26, issues, options = {}) {
40710
40809
  for (const [index, source] of value.entries()) {
40711
40810
  for (const dependency of source.dependsOn ?? []) {
40712
40811
  if (!ids.has(dependency) || dependency === source.sourceId) {
40713
- issues.push(issue2(`${path26}[${index}].dependsOn`, "UNKNOWN_SOURCE_DEPENDENCY", `Unknown dependency ${dependency}`));
40812
+ issues.push(issue2(`${path28}[${index}].dependsOn`, "UNKNOWN_SOURCE_DEPENDENCY", `Unknown dependency ${dependency}`));
40714
40813
  }
40715
40814
  }
40716
40815
  }
@@ -40729,29 +40828,29 @@ function validateDataSources(value, path26, issues, options = {}) {
40729
40828
  return cyclic;
40730
40829
  };
40731
40830
  if ([...byId.keys()].some(visit)) {
40732
- issues.push(issue2(path26, "CYCLIC_SOURCE_DEPENDENCY", "data source dependencies must be acyclic"));
40831
+ issues.push(issue2(path28, "CYCLIC_SOURCE_DEPENDENCY", "data source dependencies must be acyclic"));
40733
40832
  }
40734
40833
  return value;
40735
40834
  }
40736
- function validateModelPipelineArguments(value, sources, path26, issues) {
40835
+ function validateModelPipelineArguments(value, sources, path28, issues) {
40737
40836
  sources.forEach((source, index) => {
40738
40837
  if (isPlainRecord(source.fixedInput) && Object.keys(source.fixedInput).length || Array.isArray(source.inputBindings) && source.inputBindings.length) {
40739
- issues.push(issue2(`${path26}.dataSources[${index}]`, "MODEL_ARGUMENTS_CONFLICT", "model arguments cannot be combined with fixedInput or inputBindings"));
40838
+ issues.push(issue2(`${path28}.dataSources[${index}]`, "MODEL_ARGUMENTS_CONFLICT", "model arguments cannot be combined with fixedInput or inputBindings"));
40740
40839
  }
40741
40840
  });
40742
40841
  const expected = createA2UICardPipelineModelInputSchema(sources);
40743
40842
  if (isJsonValue(value.presentationInputSchema) && stableJsonStringify(value.presentationInputSchema) !== stableJsonStringify(expected)) {
40744
- issues.push(issue2(`${path26}.presentationInputSchema`, "MODEL_ARGUMENT_SCHEMA_MISMATCH", "presentationInputSchema must match the configured MCP input schemas"));
40843
+ issues.push(issue2(`${path28}.presentationInputSchema`, "MODEL_ARGUMENT_SCHEMA_MISMATCH", "presentationInputSchema must match the configured MCP input schemas"));
40745
40844
  }
40746
40845
  }
40747
- function validatePipelineDataSources(value, path26, issues) {
40846
+ function validatePipelineDataSources(value, path28, issues) {
40748
40847
  if (!Array.isArray(value) || value.length === 0) {
40749
- issues.push(issue2(path26, "INVALID_DATA_SOURCES", "pipeline dataSources must be a non-empty array"));
40848
+ issues.push(issue2(path28, "INVALID_DATA_SOURCES", "pipeline dataSources must be a non-empty array"));
40750
40849
  return void 0;
40751
40850
  }
40752
40851
  const ids = /* @__PURE__ */ new Set();
40753
40852
  value.forEach((candidate, index) => {
40754
- const itemPath = `${path26}[${index}]`;
40853
+ const itemPath = `${path28}[${index}]`;
40755
40854
  if (!isPlainRecord(candidate)) {
40756
40855
  issues.push(issue2(itemPath, "INVALID_DATA_SOURCE", "data source must be an object"));
40757
40856
  return;
@@ -40795,22 +40894,22 @@ function validatePipelineDataSources(value, path26, issues) {
40795
40894
  });
40796
40895
  return value;
40797
40896
  }
40798
- function validateDataTransform(value, path26, issues) {
40897
+ function validateDataTransform(value, path28, issues) {
40799
40898
  if (!isPlainRecord(value)) {
40800
- issues.push(issue2(path26, "INVALID_DATA_TRANSFORM", "dataTransform must be an object"));
40899
+ issues.push(issue2(path28, "INVALID_DATA_TRANSFORM", "dataTransform must be an object"));
40801
40900
  return;
40802
40901
  }
40803
- exactKeys(value, ["language", "profile", "source"], path26, issues);
40902
+ exactKeys(value, ["language", "profile", "source"], path28, issues);
40804
40903
  if (value.language !== A2UI_CARD_DATA_TRANSFORM_LANGUAGE) {
40805
- issues.push(issue2(`${path26}.language`, "INVALID_DATA_TRANSFORM_LANGUAGE", `language must be ${A2UI_CARD_DATA_TRANSFORM_LANGUAGE}`));
40904
+ issues.push(issue2(`${path28}.language`, "INVALID_DATA_TRANSFORM_LANGUAGE", `language must be ${A2UI_CARD_DATA_TRANSFORM_LANGUAGE}`));
40806
40905
  }
40807
40906
  if (value.profile !== A2UI_CARD_DATA_TRANSFORM_PROFILE) {
40808
- issues.push(issue2(`${path26}.profile`, "INVALID_DATA_TRANSFORM_PROFILE", `profile must be ${A2UI_CARD_DATA_TRANSFORM_PROFILE}`));
40907
+ issues.push(issue2(`${path28}.profile`, "INVALID_DATA_TRANSFORM_PROFILE", `profile must be ${A2UI_CARD_DATA_TRANSFORM_PROFILE}`));
40809
40908
  }
40810
40909
  if (typeof value.source !== "string" || value.source.trim().length === 0) {
40811
- issues.push(issue2(`${path26}.source`, "INVALID_DATA_TRANSFORM_SOURCE", "source must be a non-empty string"));
40910
+ issues.push(issue2(`${path28}.source`, "INVALID_DATA_TRANSFORM_SOURCE", "source must be a non-empty string"));
40812
40911
  } else if (new TextEncoder().encode(value.source).byteLength > A2UI_CARD_DATA_TRANSFORM_MAX_SOURCE_BYTES) {
40813
- issues.push(issue2(`${path26}.source`, "DATA_TRANSFORM_SOURCE_TOO_LARGE", `source exceeds ${A2UI_CARD_DATA_TRANSFORM_MAX_SOURCE_BYTES} bytes`));
40912
+ issues.push(issue2(`${path28}.source`, "DATA_TRANSFORM_SOURCE_TOO_LARGE", `source exceeds ${A2UI_CARD_DATA_TRANSFORM_MAX_SOURCE_BYTES} bytes`));
40814
40913
  }
40815
40914
  }
40816
40915
  function validatePipelineFieldSchemas(fields, dataModelSchema, issues) {
@@ -40823,14 +40922,14 @@ function validatePipelineFieldSchemas(fields, dataModelSchema, issues) {
40823
40922
  }
40824
40923
  });
40825
40924
  }
40826
- function validateV3OutputBindings(value, path26, issues) {
40925
+ function validateV3OutputBindings(value, path28, issues) {
40827
40926
  if (!Array.isArray(value)) {
40828
- issues.push(issue2(path26, "INVALID_OUTPUT_BINDINGS", "bindings must be an array"));
40927
+ issues.push(issue2(path28, "INVALID_OUTPUT_BINDINGS", "bindings must be an array"));
40829
40928
  return void 0;
40830
40929
  }
40831
40930
  const fields = /* @__PURE__ */ new Set();
40832
40931
  value.forEach((candidate, index) => {
40833
- const itemPath = `${path26}[${index}]`;
40932
+ const itemPath = `${path28}[${index}]`;
40834
40933
  if (!isPlainRecord(candidate)) {
40835
40934
  issues.push(issue2(itemPath, "INVALID_OUTPUT_BINDING", "binding must be an object"));
40836
40935
  return;
@@ -40873,9 +40972,9 @@ function validateV3Coverage(fields, dataSources, bindings, issues, options = {})
40873
40972
  }
40874
40973
  }
40875
40974
  }
40876
- function validateV3BindingSelections(value, path26, fields, issues) {
40975
+ function validateV3BindingSelections(value, path28, fields, issues) {
40877
40976
  if (!Array.isArray(value)) {
40878
- issues.push(issue2(path26, "INVALID_BINDINGS", "bindings must be an array"));
40977
+ issues.push(issue2(path28, "INVALID_BINDINGS", "bindings must be an array"));
40879
40978
  return;
40880
40979
  }
40881
40980
  if (value.length === 0)
@@ -40884,7 +40983,7 @@ function validateV3BindingSelections(value, path26, fields, issues) {
40884
40983
  const outputBindings = [];
40885
40984
  const dataSources = [];
40886
40985
  value.forEach((candidate, index) => {
40887
- const itemPath = `${path26}[${index}]`;
40986
+ const itemPath = `${path28}[${index}]`;
40888
40987
  if (!isPlainRecord(candidate)) {
40889
40988
  issues.push(issue2(itemPath, "INVALID_BINDING", "binding must be an object"));
40890
40989
  return;
@@ -40929,19 +41028,19 @@ function validateV3BindingSelections(value, path26, fields, issues) {
40929
41028
  });
40930
41029
  }
40931
41030
  });
40932
- validateDataSources(dataSources, `${path26}.dataSources`, issues, {
41031
+ validateDataSources(dataSources, `${path28}.dataSources`, issues, {
40933
41032
  validateOutputSchema: false
40934
41033
  });
40935
- validateV3OutputBindings(outputBindings, `${path26}.outputs`, issues);
41034
+ validateV3OutputBindings(outputBindings, `${path28}.outputs`, issues);
40936
41035
  if (fields) {
40937
41036
  validateV3Coverage(fields, dataSources, outputBindings, issues, {
40938
41037
  requireComplete: false
40939
41038
  });
40940
41039
  }
40941
41040
  }
40942
- function validateManifest(value, path26, issues) {
41041
+ function validateManifest(value, path28, issues) {
40943
41042
  if (!isPlainRecord(value)) {
40944
- issues.push(issue2(path26, "INVALID_MANIFEST", `${path26} must be an object`));
41043
+ issues.push(issue2(path28, "INVALID_MANIFEST", `${path28} must be an object`));
40945
41044
  return void 0;
40946
41045
  }
40947
41046
  if (value.schemaVersion === "4" && value.dataMode === "pipeline") {
@@ -40961,35 +41060,35 @@ function validateManifest(value, path26, issues) {
40961
41060
  "dataSources",
40962
41061
  "dataTransform",
40963
41062
  "dataModelSchema"
40964
- ], path26, issues);
41063
+ ], path28, issues);
40965
41064
  if (!isSafeIdentifier(value.draftId)) {
40966
- issues.push(issue2(`${path26}.draftId`, "INVALID_DRAFT_ID", "draftId is invalid"));
41065
+ issues.push(issue2(`${path28}.draftId`, "INVALID_DRAFT_ID", "draftId is invalid"));
40967
41066
  }
40968
41067
  if (value.argumentMode !== void 0 && value.argumentMode !== "model") {
40969
- issues.push(issue2(`${path26}.argumentMode`, "INVALID_ARGUMENT_MODE", "argumentMode must be model"));
41068
+ issues.push(issue2(`${path28}.argumentMode`, "INVALID_ARGUMENT_MODE", "argumentMode must be model"));
40970
41069
  }
40971
41070
  if (!isSafeIdentifier(value.resourceId)) {
40972
- issues.push(issue2(`${path26}.resourceId`, "INVALID_RESOURCE_ID", "resourceId is invalid"));
40973
- }
40974
- optionalString(value.baseRevision, `${path26}.baseRevision`, issues);
40975
- requiredString(value.displayName, `${path26}.displayName`, issues);
40976
- requiredString(value.description, `${path26}.description`, issues);
40977
- requiredString(value.whenToUse, `${path26}.whenToUse`, issues);
40978
- optionalString(value.whenNotToUse, `${path26}.whenNotToUse`, issues);
40979
- validateLooseJsonSchema(value.presentationInputSchema, `${path26}.presentationInputSchema`, issues);
40980
- const fields2 = validateFields(value.fields, `${path26}.fields`, issues);
40981
- const pipelineSources = validatePipelineDataSources(value.dataSources, `${path26}.dataSources`, issues);
41071
+ issues.push(issue2(`${path28}.resourceId`, "INVALID_RESOURCE_ID", "resourceId is invalid"));
41072
+ }
41073
+ optionalString(value.baseRevision, `${path28}.baseRevision`, issues);
41074
+ requiredString(value.displayName, `${path28}.displayName`, issues);
41075
+ requiredString(value.description, `${path28}.description`, issues);
41076
+ requiredString(value.whenToUse, `${path28}.whenToUse`, issues);
41077
+ optionalString(value.whenNotToUse, `${path28}.whenNotToUse`, issues);
41078
+ validateLooseJsonSchema(value.presentationInputSchema, `${path28}.presentationInputSchema`, issues);
41079
+ const fields2 = validateFields(value.fields, `${path28}.fields`, issues);
41080
+ const pipelineSources = validatePipelineDataSources(value.dataSources, `${path28}.dataSources`, issues);
40982
41081
  if (value.argumentMode === "model" && pipelineSources) {
40983
- validateModelPipelineArguments(value, pipelineSources, path26, issues);
41082
+ validateModelPipelineArguments(value, pipelineSources, path28, issues);
40984
41083
  }
40985
- validateDataTransform(value.dataTransform, `${path26}.dataTransform`, issues);
40986
- const dataModelSchema = validateLooseJsonSchema(value.dataModelSchema, `${path26}.dataModelSchema`, issues);
41084
+ validateDataTransform(value.dataTransform, `${path28}.dataTransform`, issues);
41085
+ const dataModelSchema = validateLooseJsonSchema(value.dataModelSchema, `${path28}.dataModelSchema`, issues);
40987
41086
  if (fields2 && dataModelSchema) {
40988
41087
  fields2.forEach((field, index) => {
40989
41088
  if (field.source !== "business")
40990
41089
  return;
40991
41090
  if (!getJsonSchemaAtDataPointer(value.dataModelSchema, field.path)) {
40992
- issues.push(issue2(`${path26}.fields[${index}].path`, "DATA_MODEL_FIELD_MISSING", `dataModelSchema does not define ${field.path}`));
41091
+ issues.push(issue2(`${path28}.fields[${index}].path`, "DATA_MODEL_FIELD_MISSING", `dataModelSchema does not define ${field.path}`));
40993
41092
  }
40994
41093
  });
40995
41094
  }
@@ -40997,10 +41096,10 @@ function validateManifest(value, path26, issues) {
40997
41096
  }
40998
41097
  if (value.schemaVersion === "3" || value.schemaVersion === "4") {
40999
41098
  if (value.dataMode !== void 0 && (value.schemaVersion !== "4" || value.dataMode !== "bindings")) {
41000
- issues.push(issue2(`${path26}.dataMode`, "INVALID_DATA_MODE", "bindings dataMode is only available for schemaVersion 4"));
41099
+ issues.push(issue2(`${path28}.dataMode`, "INVALID_DATA_MODE", "bindings dataMode is only available for schemaVersion 4"));
41001
41100
  }
41002
41101
  if (value.actionBindings !== void 0) {
41003
- issues.push(issue2(`${path26}.actionBindings`, "LEGACY_PAYMENT_ACTION_BINDINGS_UNSUPPORTED", "payment actions must be defined inline in card JSON"));
41102
+ issues.push(issue2(`${path28}.actionBindings`, "LEGACY_PAYMENT_ACTION_BINDINGS_UNSUPPORTED", "payment actions must be defined inline in card JSON"));
41004
41103
  }
41005
41104
  exactKeys(value, [
41006
41105
  "schemaVersion",
@@ -41014,24 +41113,24 @@ function validateManifest(value, path26, issues) {
41014
41113
  "whenNotToUse",
41015
41114
  "fields",
41016
41115
  "bindings"
41017
- ], path26, issues);
41116
+ ], path28, issues);
41018
41117
  if (!isSafeIdentifier(value.draftId)) {
41019
- issues.push(issue2(`${path26}.draftId`, "INVALID_DRAFT_ID", "draftId is invalid"));
41118
+ issues.push(issue2(`${path28}.draftId`, "INVALID_DRAFT_ID", "draftId is invalid"));
41020
41119
  }
41021
41120
  if (!isSafeIdentifier(value.resourceId)) {
41022
- issues.push(issue2(`${path26}.resourceId`, "INVALID_RESOURCE_ID", "resourceId is invalid"));
41023
- }
41024
- optionalString(value.baseRevision, `${path26}.baseRevision`, issues);
41025
- requiredString(value.displayName, `${path26}.displayName`, issues);
41026
- requiredString(value.description, `${path26}.description`, issues);
41027
- requiredString(value.whenToUse, `${path26}.whenToUse`, issues);
41028
- optionalString(value.whenNotToUse, `${path26}.whenNotToUse`, issues);
41029
- const fields2 = validateFields(value.fields, `${path26}.fields`, issues);
41121
+ issues.push(issue2(`${path28}.resourceId`, "INVALID_RESOURCE_ID", "resourceId is invalid"));
41122
+ }
41123
+ optionalString(value.baseRevision, `${path28}.baseRevision`, issues);
41124
+ requiredString(value.displayName, `${path28}.displayName`, issues);
41125
+ requiredString(value.description, `${path28}.description`, issues);
41126
+ requiredString(value.whenToUse, `${path28}.whenToUse`, issues);
41127
+ optionalString(value.whenNotToUse, `${path28}.whenNotToUse`, issues);
41128
+ const fields2 = validateFields(value.fields, `${path28}.fields`, issues);
41030
41129
  if (fields2?.some((field) => field.source === "invocation")) {
41031
- issues.push(issue2(`${path26}.fields`, "INVOCATION_FIELD_UNSUPPORTED", `schema v${value.schemaVersion} does not support invocation fields`));
41130
+ issues.push(issue2(`${path28}.fields`, "INVOCATION_FIELD_UNSUPPORTED", `schema v${value.schemaVersion} does not support invocation fields`));
41032
41131
  }
41033
41132
  if (value.bindings !== void 0) {
41034
- validateV3BindingSelections(value.bindings, `${path26}.bindings`, fields2, issues);
41133
+ validateV3BindingSelections(value.bindings, `${path28}.bindings`, fields2, issues);
41035
41134
  }
41036
41135
  return fields2 ? value : void 0;
41037
41136
  }
@@ -41047,37 +41146,37 @@ function validateManifest(value, path26, issues) {
41047
41146
  "presentationInputSchema",
41048
41147
  "fields",
41049
41148
  "bindings"
41050
- ], path26, issues);
41149
+ ], path28, issues);
41051
41150
  if (value.schemaVersion !== "2") {
41052
- issues.push(issue2(`${path26}.schemaVersion`, "UNSUPPORTED_DRAFT_VERSION", "schemaVersion must be 2, 3 or 4"));
41151
+ issues.push(issue2(`${path28}.schemaVersion`, "UNSUPPORTED_DRAFT_VERSION", "schemaVersion must be 2, 3 or 4"));
41053
41152
  }
41054
41153
  if (!isSafeIdentifier(value.draftId)) {
41055
- issues.push(issue2(`${path26}.draftId`, "INVALID_DRAFT_ID", "draftId is invalid"));
41154
+ issues.push(issue2(`${path28}.draftId`, "INVALID_DRAFT_ID", "draftId is invalid"));
41056
41155
  }
41057
41156
  if (!isSafeIdentifier(value.resourceId)) {
41058
- issues.push(issue2(`${path26}.resourceId`, "INVALID_RESOURCE_ID", "resourceId is invalid"));
41059
- }
41060
- optionalString(value.baseRevision, `${path26}.baseRevision`, issues);
41061
- requiredString(value.displayName, `${path26}.displayName`, issues);
41062
- requiredString(value.description, `${path26}.description`, issues);
41063
- requiredString(value.whenToUse, `${path26}.whenToUse`, issues);
41064
- optionalString(value.whenNotToUse, `${path26}.whenNotToUse`, issues);
41065
- const schema2 = validateLooseJsonSchema(value.presentationInputSchema, `${path26}.presentationInputSchema`, issues);
41066
- const fields = validateFields(value.fields, `${path26}.fields`, issues);
41157
+ issues.push(issue2(`${path28}.resourceId`, "INVALID_RESOURCE_ID", "resourceId is invalid"));
41158
+ }
41159
+ optionalString(value.baseRevision, `${path28}.baseRevision`, issues);
41160
+ requiredString(value.displayName, `${path28}.displayName`, issues);
41161
+ requiredString(value.description, `${path28}.description`, issues);
41162
+ requiredString(value.whenToUse, `${path28}.whenToUse`, issues);
41163
+ optionalString(value.whenNotToUse, `${path28}.whenNotToUse`, issues);
41164
+ const schema2 = validateLooseJsonSchema(value.presentationInputSchema, `${path28}.presentationInputSchema`, issues);
41165
+ const fields = validateFields(value.fields, `${path28}.fields`, issues);
41067
41166
  if (value.bindings !== void 0) {
41068
- issues.push(...getA2UICardBindingSelectionIssues(value.bindings, `${path26}.bindings`, fields));
41167
+ issues.push(...getA2UICardBindingSelectionIssues(value.bindings, `${path28}.bindings`, fields));
41069
41168
  }
41070
41169
  return schema2 && fields ? value : void 0;
41071
41170
  }
41072
41171
  function hasOverlappingJsonPointer(fixedInput, inputPath) {
41073
41172
  const fixedPaths = [];
41074
- const visit = (value, path26) => {
41075
- fixedPaths.push(path26);
41173
+ const visit = (value, path28) => {
41174
+ fixedPaths.push(path28);
41076
41175
  if (!isPlainRecord(value))
41077
41176
  return;
41078
41177
  for (const [key, child] of Object.entries(value)) {
41079
41178
  const escaped = key.replace(/~/gu, "~0").replace(/\//gu, "~1");
41080
- visit(child, `${path26}/${escaped}`);
41179
+ visit(child, `${path28}/${escaped}`);
41081
41180
  }
41082
41181
  };
41083
41182
  for (const [key, value] of Object.entries(fixedInput)) {
@@ -41086,15 +41185,15 @@ function hasOverlappingJsonPointer(fixedInput, inputPath) {
41086
41185
  }
41087
41186
  return fixedPaths.some((fixedPath) => fixedPath === inputPath || fixedPath.startsWith(`${inputPath}/`) || inputPath.startsWith(`${fixedPath}/`));
41088
41187
  }
41089
- function validateFields(value, path26, issues) {
41188
+ function validateFields(value, path28, issues) {
41090
41189
  if (!Array.isArray(value)) {
41091
- issues.push(issue2(path26, "INVALID_FIELDS", `${path26} must be an array`));
41190
+ issues.push(issue2(path28, "INVALID_FIELDS", `${path28} must be an array`));
41092
41191
  return void 0;
41093
41192
  }
41094
41193
  const ids = /* @__PURE__ */ new Set();
41095
41194
  const paths = /* @__PURE__ */ new Set();
41096
41195
  value.forEach((candidate, index) => {
41097
- const itemPath = `${path26}[${index}]`;
41196
+ const itemPath = `${path28}[${index}]`;
41098
41197
  if (!isPlainRecord(candidate)) {
41099
41198
  issues.push(issue2(itemPath, "INVALID_FIELD", `${itemPath} must be an object`));
41100
41199
  return;
@@ -41153,24 +41252,24 @@ function validateFields(value, path26, issues) {
41153
41252
  function validateFieldPresentation(value, itemPath, issues) {
41154
41253
  if (value === void 0)
41155
41254
  return;
41156
- const path26 = `${itemPath}.presentation`;
41255
+ const path28 = `${itemPath}.presentation`;
41157
41256
  if (!isPlainRecord(value)) {
41158
- issues.push(issue2(path26, "INVALID_FIELD_PRESENTATION", `${path26} must be an object`));
41257
+ issues.push(issue2(path28, "INVALID_FIELD_PRESENTATION", `${path28} must be an object`));
41159
41258
  return;
41160
41259
  }
41161
41260
  if (!["echo", "reference-only", "never"].includes(String(value.visibility))) {
41162
- issues.push(issue2(`${path26}.visibility`, "INVALID_PRESENTATION_VISIBILITY", "presentation visibility must be echo, reference-only or never"));
41261
+ issues.push(issue2(`${path28}.visibility`, "INVALID_PRESENTATION_VISIBILITY", "presentation visibility must be echo, reference-only or never"));
41163
41262
  }
41164
41263
  if (value.labelPath !== void 0 && !isSafeJsonPointer(value.labelPath)) {
41165
- issues.push(issue2(`${path26}.labelPath`, "INVALID_PRESENTATION_PATH", "labelPath must be a safe JSON pointer"));
41264
+ issues.push(issue2(`${path28}.labelPath`, "INVALID_PRESENTATION_PATH", "labelPath must be a safe JSON pointer"));
41166
41265
  }
41167
41266
  if (value.attributePaths !== void 0) {
41168
41267
  if (!Array.isArray(value.attributePaths) || value.attributePaths.length > 3 || value.attributePaths.some((candidate) => !isSafeJsonPointer(candidate))) {
41169
- issues.push(issue2(`${path26}.attributePaths`, "INVALID_PRESENTATION_PATHS", "attributePaths must contain at most 3 safe JSON pointers"));
41268
+ issues.push(issue2(`${path28}.attributePaths`, "INVALID_PRESENTATION_PATHS", "attributePaths must contain at most 3 safe JSON pointers"));
41170
41269
  }
41171
41270
  }
41172
41271
  if (value.maxItems !== void 0 && (!Number.isInteger(value.maxItems) || Number(value.maxItems) < 1 || Number(value.maxItems) > 10)) {
41173
- issues.push(issue2(`${path26}.maxItems`, "INVALID_PRESENTATION_MAX_ITEMS", "maxItems must be an integer between 1 and 10"));
41272
+ issues.push(issue2(`${path28}.maxItems`, "INVALID_PRESENTATION_MAX_ITEMS", "maxItems must be an integer between 1 and 10"));
41174
41273
  }
41175
41274
  }
41176
41275
  function validateFieldSource(candidate, itemPath, issues) {
@@ -41189,35 +41288,35 @@ function validateFieldSource(candidate, itemPath, issues) {
41189
41288
  issues.push(issue2(`${itemPath}.runtimeContextKey`, "UNEXPECTED_RUNTIME_CONTEXT", "runtimeContextKey is only allowed for runtime-context fields"));
41190
41289
  }
41191
41290
  }
41192
- function validateResolver(value, path26, issues) {
41291
+ function validateResolver(value, path28, issues) {
41193
41292
  if (!isPlainRecord(value)) {
41194
- issues.push(issue2(path26, "INVALID_RESOLVER", "resolver must be an object"));
41293
+ issues.push(issue2(path28, "INVALID_RESOLVER", "resolver must be an object"));
41195
41294
  return void 0;
41196
41295
  }
41197
- exactKeys(value, ["version", "calls", "outputBindings"], path26, issues);
41296
+ exactKeys(value, ["version", "calls", "outputBindings"], path28, issues);
41198
41297
  if (value.version !== 2) {
41199
- issues.push(issue2(`${path26}.version`, "UNSUPPORTED_RESOLVER_VERSION", "resolver version must be 2"));
41298
+ issues.push(issue2(`${path28}.version`, "UNSUPPORTED_RESOLVER_VERSION", "resolver version must be 2"));
41200
41299
  }
41201
- const calls = validateResolverCalls(value.calls, `${path26}.calls`, issues);
41202
- const outputs = validateOutputBindings(value.outputBindings, `${path26}.outputBindings`, issues);
41300
+ const calls = validateResolverCalls(value.calls, `${path28}.calls`, issues);
41301
+ const outputs = validateOutputBindings(value.outputBindings, `${path28}.outputBindings`, issues);
41203
41302
  if (!calls || !outputs)
41204
41303
  return void 0;
41205
41304
  const callIds = new Set(calls.map((call) => call.callId));
41206
41305
  outputs.forEach((binding, index) => {
41207
41306
  if (!callIds.has(binding.callId)) {
41208
- issues.push(issue2(`${path26}.outputBindings[${index}].callId`, "UNKNOWN_RESOLVER_CALL", `Unknown resolver call ${binding.callId}`));
41307
+ issues.push(issue2(`${path28}.outputBindings[${index}].callId`, "UNKNOWN_RESOLVER_CALL", `Unknown resolver call ${binding.callId}`));
41209
41308
  }
41210
41309
  });
41211
41310
  return value;
41212
41311
  }
41213
- function validateResolverCalls(value, path26, issues) {
41312
+ function validateResolverCalls(value, path28, issues) {
41214
41313
  if (!Array.isArray(value)) {
41215
- issues.push(issue2(path26, "INVALID_RESOLVER_CALLS", "calls must be an array"));
41314
+ issues.push(issue2(path28, "INVALID_RESOLVER_CALLS", "calls must be an array"));
41216
41315
  return void 0;
41217
41316
  }
41218
41317
  const callIds = /* @__PURE__ */ new Set();
41219
41318
  value.forEach((candidate, index) => {
41220
- const itemPath = `${path26}[${index}]`;
41319
+ const itemPath = `${path28}[${index}]`;
41221
41320
  if (!isPlainRecord(candidate)) {
41222
41321
  issues.push(issue2(itemPath, "INVALID_RESOLVER_CALL", "call must be an object"));
41223
41322
  return;
@@ -41238,14 +41337,14 @@ function validateResolverCalls(value, path26, issues) {
41238
41337
  });
41239
41338
  return value;
41240
41339
  }
41241
- function validateInputBindings2(value, path26, issues) {
41340
+ function validateInputBindings2(value, path28, issues) {
41242
41341
  if (!Array.isArray(value)) {
41243
- issues.push(issue2(path26, "INVALID_INPUT_BINDINGS", "inputBindings must be an array"));
41342
+ issues.push(issue2(path28, "INVALID_INPUT_BINDINGS", "inputBindings must be an array"));
41244
41343
  return void 0;
41245
41344
  }
41246
41345
  const paths = /* @__PURE__ */ new Set();
41247
41346
  value.forEach((candidate, index) => {
41248
- const itemPath = `${path26}[${index}]`;
41347
+ const itemPath = `${path28}[${index}]`;
41249
41348
  if (!isPlainRecord(candidate)) {
41250
41349
  issues.push(issue2(itemPath, "INVALID_INPUT_BINDING", "binding must be an object"));
41251
41350
  return;
@@ -41262,35 +41361,35 @@ function validateInputBindings2(value, path26, issues) {
41262
41361
  });
41263
41362
  return value;
41264
41363
  }
41265
- function validateInputSource(value, path26, issues) {
41364
+ function validateInputSource(value, path28, issues) {
41266
41365
  if (!isPlainRecord(value)) {
41267
- issues.push(issue2(path26, "INVALID_INPUT_SOURCE", "source must be an object"));
41366
+ issues.push(issue2(path28, "INVALID_INPUT_SOURCE", "source must be an object"));
41268
41367
  return;
41269
41368
  }
41270
41369
  if (value.kind === "invocation") {
41271
- exactKeys(value, ["kind", "path"], path26, issues);
41370
+ exactKeys(value, ["kind", "path"], path28, issues);
41272
41371
  if (!isSafeJsonPointer(value.path)) {
41273
- issues.push(issue2(`${path26}.path`, "INVALID_INPUT_SOURCE_PATH", "invocation source path must be a safe JSON pointer"));
41372
+ issues.push(issue2(`${path28}.path`, "INVALID_INPUT_SOURCE_PATH", "invocation source path must be a safe JSON pointer"));
41274
41373
  }
41275
41374
  return;
41276
41375
  }
41277
41376
  if (value.kind === "runtime-context") {
41278
- exactKeys(value, ["kind", "key"], path26, issues);
41377
+ exactKeys(value, ["kind", "key"], path28, issues);
41279
41378
  if (!RUNTIME_CONTEXT_KEYS2.has(value.key)) {
41280
- issues.push(issue2(`${path26}.key`, "INVALID_RUNTIME_CONTEXT", "runtime context key is invalid"));
41379
+ issues.push(issue2(`${path28}.key`, "INVALID_RUNTIME_CONTEXT", "runtime context key is invalid"));
41281
41380
  }
41282
41381
  return;
41283
41382
  }
41284
- issues.push(issue2(`${path26}.kind`, "INVALID_INPUT_SOURCE", "source.kind must be invocation or runtime-context"));
41383
+ issues.push(issue2(`${path28}.kind`, "INVALID_INPUT_SOURCE", "source.kind must be invocation or runtime-context"));
41285
41384
  }
41286
- function validateOutputBindings(value, path26, issues) {
41385
+ function validateOutputBindings(value, path28, issues) {
41287
41386
  if (!Array.isArray(value)) {
41288
- issues.push(issue2(path26, "INVALID_OUTPUT_BINDINGS", "outputBindings must be an array"));
41387
+ issues.push(issue2(path28, "INVALID_OUTPUT_BINDINGS", "outputBindings must be an array"));
41289
41388
  return void 0;
41290
41389
  }
41291
41390
  const fields = /* @__PURE__ */ new Set();
41292
41391
  value.forEach((candidate, index) => {
41293
- const itemPath = `${path26}[${index}]`;
41392
+ const itemPath = `${path28}[${index}]`;
41294
41393
  if (!isPlainRecord(candidate)) {
41295
41394
  issues.push(issue2(itemPath, "INVALID_OUTPUT_BINDING", "binding must be an object"));
41296
41395
  return;
@@ -41310,33 +41409,33 @@ function validateOutputBindings(value, path26, issues) {
41310
41409
  });
41311
41410
  return value;
41312
41411
  }
41313
- function validateTransformShape(value, path26, issues) {
41412
+ function validateTransformShape(value, path28, issues) {
41314
41413
  if (!isPlainRecord(value)) {
41315
- issues.push(issue2(path26, "INVALID_TRANSFORM", "transform must be an object"));
41414
+ issues.push(issue2(path28, "INVALID_TRANSFORM", "transform must be an object"));
41316
41415
  return false;
41317
41416
  }
41318
- exactKeys(value, ["language", "profile", "expression"], path26, issues);
41417
+ exactKeys(value, ["language", "profile", "expression"], path28, issues);
41319
41418
  if (value.language !== A2UI_CARD_TRANSFORM_LANGUAGE) {
41320
- issues.push(issue2(`${path26}.language`, "INVALID_TRANSFORM_LANGUAGE", `language must be ${A2UI_CARD_TRANSFORM_LANGUAGE}`));
41419
+ issues.push(issue2(`${path28}.language`, "INVALID_TRANSFORM_LANGUAGE", `language must be ${A2UI_CARD_TRANSFORM_LANGUAGE}`));
41321
41420
  }
41322
41421
  if (value.profile !== A2UI_CARD_TRANSFORM_PROFILE) {
41323
- issues.push(issue2(`${path26}.profile`, "INVALID_TRANSFORM_PROFILE", `profile must be ${A2UI_CARD_TRANSFORM_PROFILE}`));
41422
+ issues.push(issue2(`${path28}.profile`, "INVALID_TRANSFORM_PROFILE", `profile must be ${A2UI_CARD_TRANSFORM_PROFILE}`));
41324
41423
  }
41325
41424
  if (typeof value.expression !== "string" || value.expression.trim().length === 0) {
41326
- issues.push(issue2(`${path26}.expression`, "INVALID_TRANSFORM_EXPRESSION", "expression must be a non-empty string"));
41425
+ issues.push(issue2(`${path28}.expression`, "INVALID_TRANSFORM_EXPRESSION", "expression must be a non-empty string"));
41327
41426
  } else if (value.expression.length > A2UI_CARD_EXPRESSION_MAX_LENGTH) {
41328
- issues.push(issue2(`${path26}.expression`, "TRANSFORM_EXPRESSION_TOO_LONG", `expression exceeds ${A2UI_CARD_EXPRESSION_MAX_LENGTH} characters`));
41427
+ issues.push(issue2(`${path28}.expression`, "TRANSFORM_EXPRESSION_TOO_LONG", `expression exceeds ${A2UI_CARD_EXPRESSION_MAX_LENGTH} characters`));
41329
41428
  }
41330
41429
  return true;
41331
41430
  }
41332
- function validateProtocol(value, path26, issues) {
41431
+ function validateProtocol(value, path28, issues) {
41333
41432
  if (!Array.isArray(value) || value.length === 0) {
41334
- issues.push(issue2(path26, "INVALID_A2UI_PROTOCOL", "card must be a non-empty array"));
41433
+ issues.push(issue2(path28, "INVALID_A2UI_PROTOCOL", "card must be a non-empty array"));
41335
41434
  return void 0;
41336
41435
  }
41337
41436
  const issueCountBeforeValidation = issues.length;
41338
41437
  value.forEach((message, messageIndex) => {
41339
- const messagePath = `${path26}[${messageIndex}]`;
41438
+ const messagePath = `${path28}[${messageIndex}]`;
41340
41439
  if (!isPlainRecord(message)) {
41341
41440
  issues.push(issue2(messagePath, "INVALID_A2UI_MESSAGE", "A2UI message must be an object"));
41342
41441
  return;
@@ -41365,7 +41464,7 @@ function validateProtocol(value, path26, issues) {
41365
41464
  return void 0;
41366
41465
  return value;
41367
41466
  }
41368
- function validateInstructionShape(instruction, path26, issues) {
41467
+ function validateInstructionShape(instruction, path28, issues) {
41369
41468
  const knownKeys = [
41370
41469
  "createSurface",
41371
41470
  "updateComponents",
@@ -41374,31 +41473,31 @@ function validateInstructionShape(instruction, path26, issues) {
41374
41473
  "x2DeleteComponent"
41375
41474
  ].filter((key) => key in instruction);
41376
41475
  if (knownKeys.length !== 1) {
41377
- issues.push(issue2(path26, "INVALID_A2UI_INSTRUCTION", "instruction must contain exactly one supported operation"));
41476
+ issues.push(issue2(path28, "INVALID_A2UI_INSTRUCTION", "instruction must contain exactly one supported operation"));
41378
41477
  return;
41379
41478
  }
41380
41479
  const operation = knownKeys[0];
41381
41480
  const payload = instruction[operation];
41382
41481
  if (!isPlainRecord(payload)) {
41383
- issues.push(issue2(`${path26}.${operation}`, "INVALID_A2UI_INSTRUCTION_PAYLOAD", `${operation} must be an object`));
41482
+ issues.push(issue2(`${path28}.${operation}`, "INVALID_A2UI_INSTRUCTION_PAYLOAD", `${operation} must be an object`));
41384
41483
  return;
41385
41484
  }
41386
41485
  if (!isSafeIdentifier(payload.surfaceId)) {
41387
- issues.push(issue2(`${path26}.${operation}.surfaceId`, "INVALID_SURFACE_ID", "surfaceId must be a non-empty safe identifier"));
41486
+ issues.push(issue2(`${path28}.${operation}.surfaceId`, "INVALID_SURFACE_ID", "surfaceId must be a non-empty safe identifier"));
41388
41487
  }
41389
41488
  if (operation === "updateComponents") {
41390
41489
  if (!Array.isArray(payload.components)) {
41391
- issues.push(issue2(`${path26}.${operation}.components`, "INVALID_A2UI_COMPONENTS", "components must be an array"));
41490
+ issues.push(issue2(`${path28}.${operation}.components`, "INVALID_A2UI_COMPONENTS", "components must be an array"));
41392
41491
  return;
41393
41492
  }
41394
41493
  payload.components.forEach((component, componentIndex) => {
41395
41494
  if (!isPlainRecord(component) || !isJsonValue(component)) {
41396
- issues.push(issue2(`${path26}.${operation}.components[${componentIndex}]`, "INVALID_A2UI_COMPONENT", "component must be a JSON object"));
41495
+ issues.push(issue2(`${path28}.${operation}.components[${componentIndex}]`, "INVALID_A2UI_COMPONENT", "component must be a JSON object"));
41397
41496
  }
41398
41497
  });
41399
41498
  }
41400
41499
  if (operation === "x2DeleteComponent" && !isSafeIdentifier(payload.componentId)) {
41401
- issues.push(issue2(`${path26}.${operation}.componentId`, "INVALID_COMPONENT_ID", "componentId must be a non-empty safe identifier"));
41500
+ issues.push(issue2(`${path28}.${operation}.componentId`, "INVALID_COMPONENT_ID", "componentId must be a non-empty safe identifier"));
41402
41501
  }
41403
41502
  }
41404
41503
  function validateTemplate(value, fields, issues) {
@@ -41424,8 +41523,8 @@ function validateTemplate(value, fields, issues) {
41424
41523
  }
41425
41524
  return void 0;
41426
41525
  }
41427
- function validateLooseJsonSchema(value, path26, issues) {
41428
- const schemaIssues = getJsonSchemaIssues(value, path26, {
41526
+ function validateLooseJsonSchema(value, path28, issues) {
41527
+ const schemaIssues = getJsonSchemaIssues(value, path28, {
41429
41528
  allowMissingType: true
41430
41529
  });
41431
41530
  issues.push(...schemaIssues);
@@ -41447,14 +41546,14 @@ function validateResolverCoverage(fields, resolver, issues, card) {
41447
41546
  }
41448
41547
  }
41449
41548
  }
41450
- function requiredString(value, path26, issues) {
41549
+ function requiredString(value, path28, issues) {
41451
41550
  if (typeof value !== "string" || value.trim().length === 0) {
41452
- issues.push(issue2(path26, "REQUIRED_STRING", `${path26} must be a non-empty string`));
41551
+ issues.push(issue2(path28, "REQUIRED_STRING", `${path28} must be a non-empty string`));
41453
41552
  }
41454
41553
  }
41455
- function optionalString(value, path26, issues) {
41554
+ function optionalString(value, path28, issues) {
41456
41555
  if (value !== void 0 && typeof value !== "string") {
41457
- issues.push(issue2(path26, "INVALID_STRING", `${path26} must be a string`));
41556
+ issues.push(issue2(path28, "INVALID_STRING", `${path28} must be a string`));
41458
41557
  }
41459
41558
  }
41460
41559
 
@@ -41810,7 +41909,7 @@ function sha256Hex(value) {
41810
41909
  const bitLength = bytes.length * 8;
41811
41910
  words[bitLength >> 5] = (words[bitLength >> 5] ?? 0) | 128 << 24 - bitLength % 32;
41812
41911
  words[(bitLength + 64 >> 9 << 4) + 15] = bitLength;
41813
- const constants = SHA256_CONSTANTS;
41912
+ const constants2 = SHA256_CONSTANTS;
41814
41913
  let state = [
41815
41914
  1779033703,
41816
41915
  3144134277,
@@ -41837,7 +41936,7 @@ function sha256Hex(value) {
41837
41936
  for (let index = 0; index < 64; index += 1) {
41838
41937
  const sum1 = rotateRight(e3, 6) ^ rotateRight(e3, 11) ^ rotateRight(e3, 25);
41839
41938
  const choice = e3 & f3 ^ ~e3 & g2;
41840
- const temporary1 = add(h, sum1, choice, constants[index], schedule[index]);
41939
+ const temporary1 = add(h, sum1, choice, constants2[index], schedule[index]);
41841
41940
  const sum0 = rotateRight(a, 2) ^ rotateRight(a, 13) ^ rotateRight(a, 22);
41842
41941
  const majority = a & b3 ^ a & c ^ b3 & c;
41843
41942
  const temporary2 = add(sum0, majority);
@@ -41980,8 +42079,8 @@ function extractA2UICardAuthoringModel(bundle, options = {}) {
41980
42079
  const fields = bundle.manifest.fields.filter((field) => field.source === "business");
41981
42080
  if (bundle.manifest.schemaVersion === "4" && bundle.manifest.dataMode === "pipeline") {
41982
42081
  for (const [key, schema2] of Object.entries(bundle.manifest.dataModelSchema.properties ?? {})) {
41983
- const path26 = `/${key.replace(/~/g, "~0").replace(/\//g, "~1")}`;
41984
- if (!isPlainRecord(schema2) || fields.some((field) => field.path === path26))
42082
+ const path28 = `/${key.replace(/~/g, "~0").replace(/\//g, "~1")}`;
42083
+ if (!isPlainRecord(schema2) || fields.some((field) => field.path === path28))
41985
42084
  continue;
41986
42085
  if (!["string", "number", "integer", "boolean", "object", "array"].includes(String(schema2.type)))
41987
42086
  continue;
@@ -41990,7 +42089,7 @@ function extractA2UICardAuthoringModel(bundle, options = {}) {
41990
42089
  idIndex += 1;
41991
42090
  fields.push({
41992
42091
  fieldId: `pipeline-field-${idIndex}`,
41993
- path: path26,
42092
+ path: path28,
41994
42093
  label: key,
41995
42094
  type: schema2.type,
41996
42095
  source: "business",
@@ -42142,8 +42241,8 @@ function isSafePageUrl2(url2, actionName) {
42142
42241
  tokenCount++;
42143
42242
  if (tokenCount > 32)
42144
42243
  return false;
42145
- const path26 = match[1]?.trim() ?? "";
42146
- if (!(path26 === "/" || path26.startsWith("/") || path26.startsWith("./")) || path26.split("/").some((part) => ["..", "__proto__", "constructor", "prototype"].includes(part))) {
42244
+ const path28 = match[1]?.trim() ?? "";
42245
+ if (!(path28 === "/" || path28.startsWith("/") || path28.startsWith("./")) || path28.split("/").some((part) => ["..", "__proto__", "constructor", "prototype"].includes(part))) {
42147
42246
  return false;
42148
42247
  }
42149
42248
  }
@@ -43257,8 +43356,8 @@ function getErrorMap() {
43257
43356
 
43258
43357
  // ../../node_modules/zod/v3/helpers/parseUtil.js
43259
43358
  var makeIssue = (params) => {
43260
- const { data, path: path26, errorMaps, issueData } = params;
43261
- const fullPath = [...path26, ...issueData.path || []];
43359
+ const { data, path: path28, errorMaps, issueData } = params;
43360
+ const fullPath = [...path28, ...issueData.path || []];
43262
43361
  const fullIssue = {
43263
43362
  ...issueData,
43264
43363
  path: fullPath
@@ -43374,11 +43473,11 @@ var errorUtil;
43374
43473
 
43375
43474
  // ../../node_modules/zod/v3/types.js
43376
43475
  var ParseInputLazyPath = class {
43377
- constructor(parent, value, path26, key) {
43476
+ constructor(parent, value, path28, key) {
43378
43477
  this._cachedPath = [];
43379
43478
  this.parent = parent;
43380
43479
  this.data = value;
43381
- this._path = path26;
43480
+ this._path = path28;
43382
43481
  this._key = key;
43383
43482
  }
43384
43483
  get path() {
@@ -47354,6 +47453,10 @@ var MCP_PROXY_DESCRIPTION = [
47354
47453
  "\u4EC5 mcp({}) \u5217\u51FA\u7684\u5DE5\u5177\u53EF\u8C03\u7528(\u672A\u58F0\u660E\u7684\u5DE5\u5177\u4E0D\u4F1A\u51FA\u73B0)\u3002"
47355
47454
  ].join("\n");
47356
47455
 
47456
+ // ../linkque-agent-runtime/dist/esm/impl/mcp/alipay/argsMapper.js
47457
+ var USER_ID = Symbol("\u7CFB\u7EDF\u53D8\u91CF\u7528\u6237\u6807\u8BC6");
47458
+ var APP_ID = Symbol("\u7CFB\u7EDF\u53D8\u91CF\u5C0F\u7A0B\u5E8F\u6807\u8BC6");
47459
+
47357
47460
  // ../linkque-agent-runtime/dist/esm/core/telemetry/telemetryEnums.js
47358
47461
  var ETelemetryDiagnosticCode;
47359
47462
  (function(ETelemetryDiagnosticCode2) {
@@ -47645,10 +47748,10 @@ function assignProp(target, prop, value) {
47645
47748
  configurable: true
47646
47749
  });
47647
47750
  }
47648
- function getElementAtPath(obj, path26) {
47649
- if (!path26)
47751
+ function getElementAtPath(obj, path28) {
47752
+ if (!path28)
47650
47753
  return obj;
47651
- return path26.reduce((acc, key) => acc?.[key], obj);
47754
+ return path28.reduce((acc, key) => acc?.[key], obj);
47652
47755
  }
47653
47756
  function promiseAllObject(promisesObj) {
47654
47757
  const keys2 = Object.keys(promisesObj);
@@ -47968,11 +48071,11 @@ function aborted(x, startIndex = 0) {
47968
48071
  }
47969
48072
  return false;
47970
48073
  }
47971
- function prefixIssues(path26, issues) {
48074
+ function prefixIssues(path28, issues) {
47972
48075
  return issues.map((iss) => {
47973
48076
  var _a;
47974
48077
  (_a = iss).path ?? (_a.path = []);
47975
- iss.path.unshift(path26);
48078
+ iss.path.unshift(path28);
47976
48079
  return iss;
47977
48080
  });
47978
48081
  }
@@ -53113,10 +53216,6 @@ var OAUTH_ERRORS = {
53113
53216
  var TokenResponseSchema = OAuthTokensSchema.omit({ issuer: true });
53114
53217
  var RegistrationResponseSchema = OAuthClientInformationFullSchema.omit({ issuer: true });
53115
53218
 
53116
- // ../linkque-agent-runtime/dist/esm/impl/mcp/alipay/argsMapper.js
53117
- var USER_ID = Symbol("\u7CFB\u7EDF\u53D8\u91CF\u7528\u6237\u6807\u8BC6");
53118
- var APP_ID = Symbol("\u7CFB\u7EDF\u53D8\u91CF\u5C0F\u7A0B\u5E8F\u6807\u8BC6");
53119
-
53120
53219
  // ../linkque-agent-runtime/dist/esm/impl/knowledge/linkqueKnowledgeSearchPort.js
53121
53220
  var DEFAULT_LINKQUEGW_KNOWLEDGE_BASE_URL = RUNTIME_CONFIG_DEFAULTS.LINKQUEGW_KNOWLEDGE_BASE_URL;
53122
53221
 
@@ -53363,6 +53462,8 @@ var APPBASE_RUNTIME_CONFIG_DEFAULTS = Object.freeze({
53363
53462
  LINKQUE_EMBEDDED_QUERY_ENABLED: "false",
53364
53463
  RUN_DATABASE_ID: "linkque",
53365
53464
  RUN_TABLE_ID: "linkque_conversation_runs",
53465
+ SESSION_MEMORY_DATABASE_ID: "linkque",
53466
+ SESSION_MEMORY_TABLE_ID: "linkque_session_memories",
53366
53467
  SESSION_DATABASE_ID: "linkque",
53367
53468
  SESSION_TABLE_ID: "linkque_sessions",
53368
53469
  SESSION_LEASE_DATABASE_ID: "linkque",
@@ -53379,7 +53480,7 @@ var APPBASE_RUNTIME_CONFIG_DEFAULTS = Object.freeze({
53379
53480
  });
53380
53481
 
53381
53482
  // src/commands/agentbuild/configTemplate.ts
53382
- var import_path7 = __toESM(require("path"));
53483
+ var import_path8 = __toESM(require("path"));
53383
53484
  var APPWRITE_CONFIG_NAME = "appwrite.config.json";
53384
53485
  var CLIENT_CAPABILITY_TABLE_COLUMNS = [
53385
53486
  ...["ownerId", "agentId", "threadId", "runId", "toolCallId"].map((key) => ({
@@ -54098,7 +54199,7 @@ function mergeVars(vars, overrides) {
54098
54199
  return merged;
54099
54200
  }
54100
54201
  var writeAppwriteConfigTemplate = async (outDir, envOverrides = {}) => {
54101
- const configPath = import_path7.default.join(outDir, APPWRITE_CONFIG_NAME);
54202
+ const configPath = import_path8.default.join(outDir, APPWRITE_CONFIG_NAME);
54102
54203
  try {
54103
54204
  await ensureParentDir(configPath);
54104
54205
  await writeJsonAtomically(
@@ -54116,7 +54217,7 @@ var writeAppwriteConfigTemplate = async (outDir, envOverrides = {}) => {
54116
54217
  };
54117
54218
 
54118
54219
  // src/commands/agentbuild/envOverrides.ts
54119
- var import_path8 = __toESM(require("path"));
54220
+ var import_path9 = __toESM(require("path"));
54120
54221
  var ENV_KEY_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
54121
54222
  async function resolveEnvOverrides(env, envFile, cwd) {
54122
54223
  const overrides = {};
@@ -54125,7 +54226,7 @@ async function resolveEnvOverrides(env, envFile, cwd) {
54125
54226
  if (parsed) overrides[parsed.key] = parsed.value;
54126
54227
  }
54127
54228
  if (envFile && envFile.trim()) {
54128
- const filePath = import_path8.default.resolve(cwd, envFile);
54229
+ const filePath = import_path9.default.resolve(cwd, envFile);
54129
54230
  const content = await readUtf8IfExists(filePath);
54130
54231
  if (content === null) {
54131
54232
  throw new LinkqueCliError(
@@ -54158,12 +54259,12 @@ function parseEnvEntry(raw) {
54158
54259
 
54159
54260
  // src/commands/agentbuild/pkgResolver.ts
54160
54261
  var import_fs6 = require("fs");
54161
- var import_path9 = require("path");
54262
+ var import_path10 = require("path");
54162
54263
  var INTEGRATE_PKG = "@alipay/linkque-agent-appwrite-integrate";
54163
54264
  var resolveIntegrateRoot = () => resolvePortableIntegrateRoot() ?? resolveInstalledIntegrateRoot();
54164
54265
  var resolveInstalledIntegrateRoot = () => {
54165
54266
  try {
54166
- return (0, import_path9.dirname)(require.resolve(`${INTEGRATE_PKG}/package.json`));
54267
+ return (0, import_path10.dirname)(require.resolve(`${INTEGRATE_PKG}/package.json`));
54167
54268
  } catch {
54168
54269
  throw new LinkqueCliError(
54169
54270
  "AGENTBUILD_INTEGRATE_NOT_BUILT",
@@ -54174,16 +54275,16 @@ var resolveInstalledIntegrateRoot = () => {
54174
54275
  var resolvePortableIntegrateRoot = () => {
54175
54276
  let dir = __dirname;
54176
54277
  while (true) {
54177
- const candidate = (0, import_path9.join)(dir, "vendor", "linkque-agent-appwrite-integrate");
54178
- if ((0, import_fs6.existsSync)((0, import_path9.join)(candidate, "package.json"))) return candidate;
54179
- const parent = (0, import_path9.dirname)(dir);
54278
+ const candidate = (0, import_path10.join)(dir, "vendor", "linkque-agent-appwrite-integrate");
54279
+ if ((0, import_fs6.existsSync)((0, import_path10.join)(candidate, "package.json"))) return candidate;
54280
+ const parent = (0, import_path10.dirname)(dir);
54180
54281
  if (parent === dir) break;
54181
54282
  dir = parent;
54182
54283
  }
54183
54284
  return void 0;
54184
54285
  };
54185
54286
  var assertIntegrateBuilt = (pkgRoot) => {
54186
- const distEsm = (0, import_path9.join)(pkgRoot, "dist", "esm");
54287
+ const distEsm = (0, import_path10.join)(pkgRoot, "dist", "esm");
54187
54288
  if (!(0, import_fs6.existsSync)(distEsm)) {
54188
54289
  throw new LinkqueCliError(
54189
54290
  "AGENTBUILD_INTEGRATE_NOT_BUILT",
@@ -54194,13 +54295,13 @@ var assertIntegrateBuilt = (pkgRoot) => {
54194
54295
 
54195
54296
  // src/commands/agentbuild/buildCommand.ts
54196
54297
  var bundleWhileLocked = async (cwd, protocol, minify, pkgRoot, archive, archiveOutDir, envOverrides) => {
54197
- const outDir = import_path10.default.join(cwd, AGENT_BUNDLE_DIR);
54298
+ const outDir = import_path11.default.join(cwd, AGENT_BUNDLE_DIR);
54198
54299
  const start = Date.now();
54199
- await (0, import_promises5.rm)(outDir, { force: true, recursive: true });
54300
+ await (0, import_promises6.rm)(outDir, { force: true, recursive: true });
54200
54301
  const stats = [];
54201
54302
  try {
54202
54303
  for (const def of FUNCTION_DEFS) {
54203
- const fnOutDir = import_path10.default.join(outDir, def.$id);
54304
+ const fnOutDir = import_path11.default.join(outDir, def.$id);
54204
54305
  const result = await bundleAgentInstallation({
54205
54306
  // loadAgentProtocol 仅做最小校验(可读+JSON 对象+不含 apiKey),返回 Record;
54206
54307
  // bundler 的 assertProtocolValid 会做运行时 IAgentProtocol 字段校验,这里 cast。
@@ -54225,14 +54326,14 @@ var bundleWhileLocked = async (cwd, protocol, minify, pkgRoot, archive, archiveO
54225
54326
  );
54226
54327
  }
54227
54328
  const configAbsPath = await writeAppwriteConfigTemplate(outDir, envOverrides);
54228
- await (0, import_promises5.writeFile)(
54229
- import_path10.default.join(outDir, AGENT_DEPLOY_META_NAME),
54329
+ await (0, import_promises6.writeFile)(
54330
+ import_path11.default.join(outDir, AGENT_DEPLOY_META_NAME),
54230
54331
  `${JSON.stringify({ agentId: protocol.agentId }, null, 2)}
54231
54332
  `,
54232
54333
  "utf8"
54233
54334
  );
54234
- const configPath = import_path10.default.relative(cwd, configAbsPath);
54235
- const bundleDir = import_path10.default.relative(cwd, outDir) || AGENT_BUNDLE_DIR;
54335
+ const configPath = import_path11.default.relative(cwd, configAbsPath);
54336
+ const bundleDir = import_path11.default.relative(cwd, outDir) || AGENT_BUNDLE_DIR;
54236
54337
  const totalBytes = stats.reduce((sum, s4) => sum + s4.bytes, 0);
54237
54338
  const durationMs = Date.now() - start;
54238
54339
  await writePerFunctionArchives(outDir);
@@ -54253,7 +54354,7 @@ var bundleWhileLocked = async (cwd, protocol, minify, pkgRoot, archive, archiveO
54253
54354
  // archive 模式:对外交付物是 code.tar,bundle 目录是中间态。
54254
54355
  bundleDir: "",
54255
54356
  configPath,
54256
- archivePath: import_path10.default.relative(cwd, archiveAbsPath),
54357
+ archivePath: import_path11.default.relative(cwd, archiveAbsPath),
54257
54358
  functions: stats,
54258
54359
  totalBytes,
54259
54360
  durationMs
@@ -54262,8 +54363,8 @@ var bundleWhileLocked = async (cwd, protocol, minify, pkgRoot, archive, archiveO
54262
54363
  var writePerFunctionArchives = async (outDir) => {
54263
54364
  try {
54264
54365
  for (const def of FUNCTION_DEFS) {
54265
- const fnOutDir = import_path10.default.join(outDir, def.$id);
54266
- const fnArchive = import_path10.default.join(outDir, `${def.$id}.tar.gz`);
54366
+ const fnOutDir = import_path11.default.join(outDir, def.$id);
54367
+ const fnArchive = import_path11.default.join(outDir, `${def.$id}.tar.gz`);
54267
54368
  await Qn(
54268
54369
  { gzip: true, cwd: fnOutDir, file: fnArchive, portable: true },
54269
54370
  ["."]
@@ -54278,11 +54379,11 @@ var writePerFunctionArchives = async (outDir) => {
54278
54379
  }
54279
54380
  };
54280
54381
  var writeCodeTar = async (cwd, outDir, archiveOutDir) => {
54281
- const archiveDirAbs = import_path10.default.resolve(
54382
+ const archiveDirAbs = import_path11.default.resolve(
54282
54383
  cwd,
54283
54384
  archiveOutDir === "" ? DEFAULT_ARCHIVE_DIR : archiveOutDir
54284
54385
  );
54285
- const archiveAbsPath = import_path10.default.join(archiveDirAbs, AGENT_ARCHIVE_NAME);
54386
+ const archiveAbsPath = import_path11.default.join(archiveDirAbs, AGENT_ARCHIVE_NAME);
54286
54387
  await ensureParentDir(archiveAbsPath);
54287
54388
  try {
54288
54389
  await Qn(
@@ -54309,7 +54410,7 @@ var agentBuild = async (cwd, rawConfigPath, minify, archive, archiveOutDir, env,
54309
54410
  const envOverrides = await resolveEnvOverrides(env, envFile, cwd);
54310
54411
  return withWorkspaceLock(
54311
54412
  {
54312
- path: import_path10.default.join(cwd, AGENTBUILD_LOCK),
54413
+ path: import_path11.default.join(cwd, AGENTBUILD_LOCK),
54313
54414
  name: "agentbuild",
54314
54415
  acquireErrorCode: "AGENTBUILD_LOCK_TIMEOUT",
54315
54416
  releaseErrorCode: "AGENTBUILD_STATE_WRITE_FAILED",
@@ -54330,12 +54431,12 @@ var agentBuild = async (cwd, rawConfigPath, minify, archive, archiveOutDir, env,
54330
54431
 
54331
54432
  // src/commands/agentdeploy/deployCommand.ts
54332
54433
  var import_fs7 = require("fs");
54333
- var import_path12 = __toESM(require("path"));
54434
+ var import_path13 = __toESM(require("path"));
54334
54435
 
54335
54436
  // src/commands/agentdeploy/configLoader.ts
54336
- var import_promises6 = require("fs/promises");
54437
+ var import_promises7 = require("fs/promises");
54337
54438
  var import_os2 = require("os");
54338
- var import_path11 = __toESM(require("path"));
54439
+ var import_path12 = __toESM(require("path"));
54339
54440
 
54340
54441
  // src/commands/agentdeploy/types.ts
54341
54442
  var AGENTDEPLOY_LOCK = ".linkque/runtime/agentdeploy.lock";
@@ -54354,24 +54455,24 @@ var BUNDLE_CONFIG_NAME = "appwrite.config.json";
54354
54455
  var readBundleAgentId = async (bundlePath) => {
54355
54456
  let content;
54356
54457
  if (await pathHasKind(bundlePath, "dir")) {
54357
- content = await (0, import_promises6.readFile)(
54358
- import_path11.default.join(bundlePath, AGENT_DEPLOY_META_NAME),
54458
+ content = await (0, import_promises7.readFile)(
54459
+ import_path12.default.join(bundlePath, AGENT_DEPLOY_META_NAME),
54359
54460
  "utf8"
54360
54461
  ).catch(() => "");
54361
54462
  } else if (isArchivePath(bundlePath)) {
54362
- const tmpDir = await (0, import_promises6.mkdtemp)(import_path11.default.join((0, import_os2.tmpdir)(), "linkquejs-bundle-meta-"));
54463
+ const tmpDir = await (0, import_promises7.mkdtemp)(import_path12.default.join((0, import_os2.tmpdir)(), "linkquejs-bundle-meta-"));
54363
54464
  try {
54364
54465
  await So({
54365
54466
  file: bundlePath,
54366
54467
  cwd: tmpDir,
54367
54468
  filter: (entryPath) => entryPath.replace(/^\.\//, "") === AGENT_DEPLOY_META_NAME
54368
54469
  });
54369
- content = await (0, import_promises6.readFile)(
54370
- import_path11.default.join(tmpDir, AGENT_DEPLOY_META_NAME),
54470
+ content = await (0, import_promises7.readFile)(
54471
+ import_path12.default.join(tmpDir, AGENT_DEPLOY_META_NAME),
54371
54472
  "utf8"
54372
54473
  ).catch(() => "");
54373
54474
  } finally {
54374
- await (0, import_promises6.rm)(tmpDir, { force: true, recursive: true });
54475
+ await (0, import_promises7.rm)(tmpDir, { force: true, recursive: true });
54375
54476
  }
54376
54477
  } else {
54377
54478
  content = "";
@@ -54390,7 +54491,7 @@ var readBundleAgentId = async (bundlePath) => {
54390
54491
  };
54391
54492
  var isArchivePath = (bundlePath) => bundlePath.endsWith(".tar") || bundlePath.endsWith(".tar.gz") || bundlePath.endsWith(".tgz");
54392
54493
  var readConfigFromTar = async (tarPath) => {
54393
- const tmpDir = await (0, import_promises6.mkdtemp)(import_path11.default.join((0, import_os2.tmpdir)(), "linkquejs-bundle-cfg-"));
54494
+ const tmpDir = await (0, import_promises7.mkdtemp)(import_path12.default.join((0, import_os2.tmpdir)(), "linkquejs-bundle-cfg-"));
54394
54495
  try {
54395
54496
  await So({
54396
54497
  file: tarPath,
@@ -54399,7 +54500,7 @@ var readConfigFromTar = async (tarPath) => {
54399
54500
  filter: (entryPath) => entryPath.replace(/^\.\//, "") === BUNDLE_CONFIG_NAME
54400
54501
  });
54401
54502
  const content = await readUtf8IfExists(
54402
- import_path11.default.join(tmpDir, BUNDLE_CONFIG_NAME)
54503
+ import_path12.default.join(tmpDir, BUNDLE_CONFIG_NAME)
54403
54504
  );
54404
54505
  if (content === null) {
54405
54506
  throw new LinkqueCliError(
@@ -54415,12 +54516,12 @@ var readConfigFromTar = async (tarPath) => {
54415
54516
  `failed to read appwrite config from bundle archive ${tarPath}: ${error2 instanceof Error ? error2.message : String(error2)}`
54416
54517
  );
54417
54518
  } finally {
54418
- await (0, import_promises6.rm)(tmpDir, { force: true, recursive: true });
54519
+ await (0, import_promises7.rm)(tmpDir, { force: true, recursive: true });
54419
54520
  }
54420
54521
  };
54421
54522
  var readBundleConfigContent = async (bundlePath) => {
54422
54523
  if (await pathHasKind(bundlePath, "dir")) {
54423
- const configPath = import_path11.default.join(bundlePath, BUNDLE_CONFIG_NAME);
54524
+ const configPath = import_path12.default.join(bundlePath, BUNDLE_CONFIG_NAME);
54424
54525
  const content = await readUtf8IfExists(configPath);
54425
54526
  if (content === null) {
54426
54527
  throw new LinkqueCliError(
@@ -54488,7 +54589,7 @@ var parseAppwriteConfig = (content, configPath) => {
54488
54589
  };
54489
54590
  };
54490
54591
  var loadDeployManifest = async (rawPath, cwd) => {
54491
- const manifestPath = import_path11.default.resolve(
54592
+ const manifestPath = import_path12.default.resolve(
54492
54593
  cwd,
54493
54594
  rawPath === "" ? DEFAULT_MANIFEST_NAME : rawPath
54494
54595
  );
@@ -54740,7 +54841,7 @@ var deployWhileLocked = async (cwd, cfg, apiKey, agentId, bundlePath, options) =
54740
54841
  { cause: error2 }
54741
54842
  );
54742
54843
  }
54743
- const statePath = import_path12.default.join(cwd, AGENTDEPLOY_STATE);
54844
+ const statePath = import_path13.default.join(cwd, AGENTDEPLOY_STATE);
54744
54845
  await ensureParentDir(statePath);
54745
54846
  try {
54746
54847
  await writeJsonAtomically(statePath, { deployedAt: Date.now(), results });
@@ -54763,7 +54864,7 @@ var deployWhileLocked = async (cwd, cfg, apiKey, agentId, bundlePath, options) =
54763
54864
  return { results, okCount, totalCount, allOk: true };
54764
54865
  };
54765
54866
  var agentDeploy = async (cwd, options) => {
54766
- const bundlePath = options.bundlePath ?? import_path12.default.join(cwd, AGENT_BUNDLE_DIR);
54867
+ const bundlePath = options.bundlePath ?? import_path13.default.join(cwd, AGENT_BUNDLE_DIR);
54767
54868
  if (!(0, import_fs7.existsSync)(bundlePath)) {
54768
54869
  throw new LinkqueCliError(
54769
54870
  "AGENTDEPLOY_BUNDLE_NOT_FOUND",
@@ -54800,7 +54901,7 @@ var agentDeploy = async (cwd, options) => {
54800
54901
  }
54801
54902
  return withWorkspaceLock(
54802
54903
  {
54803
- path: import_path12.default.join(cwd, AGENTDEPLOY_LOCK),
54904
+ path: import_path13.default.join(cwd, AGENTDEPLOY_LOCK),
54804
54905
  name: "agentdeploy",
54805
54906
  acquireErrorCode: "AGENTDEPLOY_LOCK_TIMEOUT",
54806
54907
  releaseErrorCode: "AGENTDEPLOY_STATE_WRITE_FAILED",
@@ -54847,7 +54948,7 @@ var SandboxRuntimeConfigProvider = class extends RuntimeConfigProvider {
54847
54948
 
54848
54949
  // src/commands/agentdev/configLoader.ts
54849
54950
  var import_crypto3 = require("crypto");
54850
- var import_path13 = __toESM(require("path"));
54951
+ var import_path14 = __toESM(require("path"));
54851
54952
 
54852
54953
  // src/commands/agentdev/types.ts
54853
54954
  var MODEL_PROVIDER_BY_GATEWAY = Object.freeze({ LINKQUE: "LINKQUE", TEST: "TEST" });
@@ -54884,7 +54985,7 @@ var stopped = (health) => ({
54884
54985
  // src/commands/agentdev/configLoader.ts
54885
54986
  var DEFAULT_CONFIG_NAME2 = "agent_config.json";
54886
54987
  var loadAgentConfig = async (rawConfigPath, cwd) => {
54887
- const configPath = import_path13.default.resolve(
54988
+ const configPath = import_path14.default.resolve(
54888
54989
  cwd,
54889
54990
  rawConfigPath === "" ? DEFAULT_CONFIG_NAME2 : rawConfigPath
54890
54991
  );
@@ -54992,9 +55093,9 @@ var normalizeModelProvider = (provider, configPath) => {
54992
55093
  };
54993
55094
 
54994
55095
  // src/commands/agentdev/ownerState.ts
54995
- var import_promises7 = require("fs/promises");
55096
+ var import_promises8 = require("fs/promises");
54996
55097
  var import_net = require("net");
54997
- var import_path14 = __toESM(require("path"));
55098
+ var import_path15 = __toESM(require("path"));
54998
55099
  var isAgentHttpHealthy = async (port) => {
54999
55100
  const probeUrl = new URL(`http://127.0.0.1:${port}${HEALTH_PATH}`);
55000
55101
  try {
@@ -55040,7 +55141,7 @@ var readOwnedAgentState = async (statePath) => {
55040
55141
  };
55041
55142
  async function removeMatchingState(statePath, pid) {
55042
55143
  const owned = await readOwnedAgentState(statePath);
55043
- if (owned?.state.pid === pid) await (0, import_promises7.rm)(statePath, { force: true });
55144
+ if (owned?.state.pid === pid) await (0, import_promises8.rm)(statePath, { force: true });
55044
55145
  }
55045
55146
  async function terminateOwner(statePath, pid) {
55046
55147
  if (!isProcessAlive(pid)) {
@@ -55086,14 +55187,14 @@ var statusFromState = async (state) => ({
55086
55187
  startedAt: state.startedAt
55087
55188
  });
55088
55189
  var inspectRecordedAgentServer = async (cwd, legacyFailureCode = "AGENTDEV_STOP_FAILED") => {
55089
- const statePath = import_path14.default.join(cwd, RUNTIME_DIR, AGENT_STATE);
55190
+ const statePath = import_path15.default.join(cwd, RUNTIME_DIR, AGENT_STATE);
55090
55191
  const content = await readUtf8IfExists(statePath);
55091
55192
  if (content === null) {
55092
55193
  return { state: null, status: stopped("STOPPED") };
55093
55194
  }
55094
55195
  const owned = parseOwnedAgentState(content);
55095
55196
  if (owned === null) {
55096
- await (0, import_promises7.rm)(statePath, { force: true });
55197
+ await (0, import_promises8.rm)(statePath, { force: true });
55097
55198
  return { state: null, status: stopped("STALE") };
55098
55199
  }
55099
55200
  if (owned.kind === "legacy") {
@@ -55122,9 +55223,9 @@ var inspectAgentServer = async (cwd) => (await inspectRecordedAgentServer(cwd)).
55122
55223
 
55123
55224
  // src/commands/agentdev/startCommand.ts
55124
55225
  var import_child_process = require("child_process");
55125
- var import_path15 = __toESM(require("path"));
55226
+ var import_path16 = __toESM(require("path"));
55126
55227
  var spawnAgentOwner = (cwd, config3, port, apiKey, statePath) => {
55127
- const workerPath = import_path15.default.resolve(__dirname, "worker.js");
55228
+ const workerPath = import_path16.default.resolve(__dirname, "worker.js");
55128
55229
  const input = Buffer.from(
55129
55230
  JSON.stringify({
55130
55231
  agentId: config3.agentId,
@@ -55133,7 +55234,7 @@ var spawnAgentOwner = (cwd, config3, port, apiKey, statePath) => {
55133
55234
  healthPath: HEALTH_PATH,
55134
55235
  homeDataPath: HOME_DATA_PATH,
55135
55236
  functionActionMcpPath: FUNCTION_ACTION_MCP_PATH,
55136
- logPath: import_path15.default.join(cwd, AGENT_LOG),
55237
+ logPath: import_path16.default.join(cwd, AGENT_LOG),
55137
55238
  port,
55138
55239
  runsPath: RUNS_PATH,
55139
55240
  statePath
@@ -55232,9 +55333,9 @@ var startAgentServerWhileLocked = async (cwd, config3, apiKey, port, statePath)
55232
55333
  var startAgentServer = async (cwd, rawConfigPath, port) => {
55233
55334
  const config3 = await loadAgentConfig(rawConfigPath, cwd);
55234
55335
  const { apiKey } = resolveAuth(config3);
55235
- const runtimeDir = import_path15.default.join(cwd, RUNTIME_DIR);
55236
- const lockPath = import_path15.default.join(runtimeDir, AGENT_LOCK);
55237
- const statePath = import_path15.default.join(runtimeDir, AGENT_STATE);
55336
+ const runtimeDir = import_path16.default.join(cwd, RUNTIME_DIR);
55337
+ const lockPath = import_path16.default.join(runtimeDir, AGENT_LOCK);
55338
+ const statePath = import_path16.default.join(runtimeDir, AGENT_STATE);
55238
55339
  await ensureParentDir(statePath);
55239
55340
  return withWorkspaceLock(
55240
55341
  {
@@ -55250,11 +55351,11 @@ var startAgentServer = async (cwd, rawConfigPath, port) => {
55250
55351
  };
55251
55352
 
55252
55353
  // src/commands/agentdev/stopCommand.ts
55253
- var import_promises8 = require("fs/promises");
55254
- var import_path16 = __toESM(require("path"));
55354
+ var import_promises9 = require("fs/promises");
55355
+ var import_path17 = __toESM(require("path"));
55255
55356
  var stopAgentServer = async (cwd) => {
55256
- const lockPath = import_path16.default.join(cwd, RUNTIME_DIR, AGENT_LOCK);
55257
- const statePath = import_path16.default.join(cwd, RUNTIME_DIR, AGENT_STATE);
55357
+ const lockPath = import_path17.default.join(cwd, RUNTIME_DIR, AGENT_LOCK);
55358
+ const statePath = import_path17.default.join(cwd, RUNTIME_DIR, AGENT_STATE);
55258
55359
  await ensureParentDir(statePath);
55259
55360
  return withWorkspaceLock(
55260
55361
  {
@@ -55268,7 +55369,7 @@ var stopAgentServer = async (cwd) => {
55268
55369
  async () => {
55269
55370
  const owned = await readOwnedAgentState(statePath);
55270
55371
  if (owned !== null) await terminateOwner(statePath, owned.state.pid);
55271
- await (0, import_promises8.rm)(statePath, { force: true });
55372
+ await (0, import_promises9.rm)(statePath, { force: true });
55272
55373
  return { stopped: true };
55273
55374
  }
55274
55375
  );
@@ -55276,15 +55377,15 @@ var stopAgentServer = async (cwd) => {
55276
55377
 
55277
55378
  // src/commands/build/dist.ts
55278
55379
  var import_crypto7 = require("crypto");
55279
- var import_promises13 = require("fs/promises");
55280
- var import_path20 = __toESM(require("path"));
55380
+ var import_promises15 = require("fs/promises");
55381
+ var import_path21 = __toESM(require("path"));
55281
55382
 
55282
55383
  // src/utils/spawn.ts
55283
55384
  var import_child_process2 = require("child_process");
55284
- var import_promises9 = require("fs/promises");
55385
+ var import_promises10 = require("fs/promises");
55285
55386
  var spawnManaged = async (options) => {
55286
55387
  await ensureParentDir(options.logPath);
55287
- const log = await (0, import_promises9.open)(options.logPath, "a");
55388
+ const log = await (0, import_promises10.open)(options.logPath, "a");
55288
55389
  try {
55289
55390
  await log.writeFile(
55290
55391
  `
@@ -55349,8 +55450,101 @@ var spawnManaged = async (options) => {
55349
55450
  // src/commands/install.ts
55350
55451
  var import_child_process3 = require("child_process");
55351
55452
  var import_crypto4 = require("crypto");
55352
- var import_promises10 = require("fs/promises");
55353
- var import_path17 = __toESM(require("path"));
55453
+ var import_promises12 = require("fs/promises");
55454
+ var import_path18 = __toESM(require("path"));
55455
+
55456
+ // src/utils/installObservation.ts
55457
+ var import_fs8 = require("fs");
55458
+ var import_promises11 = require("fs/promises");
55459
+ var import_util5 = require("util");
55460
+ var MAX_LOG_TAIL_BYTES = 64 * 1024;
55461
+ var COUNTS_LINE = /^\+ (\d+) added · (\d+) reused · (\d+) downloaded(?: \(\d+(?:\.\d+)? (?:B|kB|MB|GB)(?: @ \d+(?:\.\d+)? (?:B|kB|MB|GB)\/s)?\))?$/u;
55462
+ var DURATION_LINE = /^All packages installed \[(?:(?:(\d+)h)?(\d+)m(\d+)s|(\d+(?:\.\d+)?)s)\]$/u;
55463
+ var readInstallLogStart = async (logPath) => {
55464
+ try {
55465
+ const start = await (0, import_promises11.stat)(logPath);
55466
+ return start.isFile() ? start : void 0;
55467
+ } catch (error2) {
55468
+ return isNodeError(error2, "ENOENT") ? null : void 0;
55469
+ }
55470
+ };
55471
+ var readInstallLogSummary = async (logPath, start) => {
55472
+ if (start === void 0) return {};
55473
+ try {
55474
+ const log = await (0, import_promises11.open)(logPath, import_fs8.constants.O_RDONLY | import_fs8.constants.O_NONBLOCK);
55475
+ try {
55476
+ const end = await log.stat();
55477
+ if (!end.isFile() || start && (end.dev !== start.dev || end.ino !== start.ino)) {
55478
+ return {};
55479
+ }
55480
+ const offset = Math.max(start?.size ?? 0, end.size - MAX_LOG_TAIL_BYTES);
55481
+ if (offset >= end.size) return {};
55482
+ const buffer2 = Buffer.alloc(end.size - offset);
55483
+ const { bytesRead } = await log.read(buffer2, 0, buffer2.length, offset);
55484
+ if (bytesRead !== buffer2.length) return {};
55485
+ let tail = buffer2.toString("utf8");
55486
+ if (offset > (start?.size ?? 0)) {
55487
+ const firstLineEnd = tail.search(/[\r\n]/u);
55488
+ if (firstLineEnd === -1) return {};
55489
+ tail = tail.slice(firstLineEnd + 1);
55490
+ }
55491
+ const lines = (0, import_util5.stripVTControlCharacters)(tail).split(/[\r\n]+/u).filter((line) => line.trim());
55492
+ const lastLine = lines.at(-1) ?? "";
55493
+ const hasCompletionLine = lastLine === "All packages installed" || lastLine.startsWith("All packages installed [");
55494
+ const countsLine = hasCompletionLine ? lines.at(-2) ?? "" : lastLine;
55495
+ const counts = COUNTS_LINE.exec(countsLine);
55496
+ const duration3 = DURATION_LINE.exec(lastLine);
55497
+ const summary = {};
55498
+ if (counts && (hasCompletionLine || !lines.slice(0, -1).some((line) => COUNTS_LINE.test(line)))) {
55499
+ const [, rawAdded, rawReused, rawDownloaded] = counts;
55500
+ const added = Number(rawAdded);
55501
+ const reused = Number(rawReused);
55502
+ const downloaded = Number(rawDownloaded);
55503
+ if ([added, reused, downloaded, reused + downloaded].every(
55504
+ Number.isSafeInteger
55505
+ )) {
55506
+ summary.counts = { added, reused, downloaded };
55507
+ }
55508
+ }
55509
+ if (duration3) {
55510
+ const [, hours, minutes, seconds, secondsOnly] = duration3;
55511
+ const durationMs = Math.round(
55512
+ (Number(hours ?? 0) * 3600 + Number(minutes ?? 0) * 60 + Number(seconds ?? secondsOnly)) * 1e3
55513
+ );
55514
+ if (Number.isSafeInteger(durationMs)) {
55515
+ summary.utReportedDurationMs = durationMs;
55516
+ }
55517
+ }
55518
+ return summary;
55519
+ } finally {
55520
+ await log.close();
55521
+ }
55522
+ } catch {
55523
+ return {};
55524
+ }
55525
+ };
55526
+ var runWorkspaceInstall = async (command, cwd, logPath) => {
55527
+ const logStart = await readInstallLogStart(logPath);
55528
+ const startedAt = performance.now();
55529
+ const { exitCode } = await spawnManaged({
55530
+ command,
55531
+ args: ["install"],
55532
+ cwd,
55533
+ logPath,
55534
+ logHeader: `${command} install`
55535
+ });
55536
+ const durationMs = Math.round(performance.now() - startedAt);
55537
+ if (exitCode !== 0) return { exitCode };
55538
+ return {
55539
+ exitCode,
55540
+ installMetrics: {
55541
+ durationMs,
55542
+ ...await readInstallLogSummary(logPath, logStart)
55543
+ }
55544
+ };
55545
+ };
55546
+
55547
+ // src/commands/install.ts
55354
55548
  var RUNTIME_DIR2 = ".linkque/runtime";
55355
55549
  var LOG_DIR = ".linkque/logs";
55356
55550
  var INSTALL_LOCK = "install.lock";
@@ -55403,7 +55597,7 @@ var readLockfiles = async (cwd) => {
55403
55597
  const lockfiles = /* @__PURE__ */ new Map();
55404
55598
  await Promise.all(
55405
55599
  LOCKFILES.map(async (name) => {
55406
- const content = await readUtf8IfExists(import_path17.default.join(cwd, name));
55600
+ const content = await readUtf8IfExists(import_path18.default.join(cwd, name));
55407
55601
  if (content !== null) lockfiles.set(name, content);
55408
55602
  })
55409
55603
  );
@@ -55424,7 +55618,7 @@ var readDependencyInputs = async (cwd) => {
55424
55618
  let lockfiles;
55425
55619
  try {
55426
55620
  [packageJson, lockfiles] = await Promise.all([
55427
- (0, import_promises10.readFile)(import_path17.default.join(cwd, "package.json"), "utf8"),
55621
+ (0, import_promises12.readFile)(import_path18.default.join(cwd, "package.json"), "utf8"),
55428
55622
  readLockfiles(cwd)
55429
55623
  ]);
55430
55624
  } catch (error2) {
@@ -55451,10 +55645,10 @@ var readInstallState = async (statePath) => {
55451
55645
  }
55452
55646
  };
55453
55647
  var hasInstalledDependencies = async (cwd) => {
55454
- if (await pathHasKind(import_path17.default.join(cwd, "node_modules"), "dir")) return true;
55648
+ if (await pathHasKind(import_path18.default.join(cwd, "node_modules"), "dir")) return true;
55455
55649
  const [pnpCjs, pnpJs] = await Promise.all([
55456
- pathHasKind(import_path17.default.join(cwd, ".pnp.cjs"), "file"),
55457
- pathHasKind(import_path17.default.join(cwd, ".pnp.js"), "file")
55650
+ pathHasKind(import_path18.default.join(cwd, ".pnp.cjs"), "file"),
55651
+ pathHasKind(import_path18.default.join(cwd, ".pnp.js"), "file")
55458
55652
  ]);
55459
55653
  return pnpCjs || pnpJs;
55460
55654
  };
@@ -55482,9 +55676,9 @@ var writeInstallState = async (statePath, fingerprint, toolchain) => {
55482
55676
  );
55483
55677
  }
55484
55678
  };
55485
- var installLockPath = (cwd) => import_path17.default.join(cwd, RUNTIME_DIR2, INSTALL_LOCK);
55486
- var installStatePath = (cwd) => import_path17.default.join(cwd, RUNTIME_DIR2, INSTALL_STATE);
55487
- var installLogPath = (cwd) => import_path17.default.join(cwd, LOG_DIR, INSTALL_LOG);
55679
+ var installLockPath = (cwd) => import_path18.default.join(cwd, RUNTIME_DIR2, INSTALL_LOCK);
55680
+ var installStatePath = (cwd) => import_path18.default.join(cwd, RUNTIME_DIR2, INSTALL_STATE);
55681
+ var installLogPath = (cwd) => import_path18.default.join(cwd, LOG_DIR, INSTALL_LOG);
55488
55682
  var inspectInstallation = async (cwd) => {
55489
55683
  if (await pathExists(installLockPath(cwd))) {
55490
55684
  return {
@@ -55536,7 +55730,7 @@ var installDependenciesWhileLocked = async (cwd, { force }) => {
55536
55730
  }
55537
55731
  if (previousState?.fingerprint === fingerprint) {
55538
55732
  try {
55539
- await (0, import_promises10.rm)(statePath, { force: true });
55733
+ await (0, import_promises12.rm)(statePath, { force: true });
55540
55734
  } catch (error2) {
55541
55735
  throw new LinkqueCliError(
55542
55736
  "INSTALL_STATE_WRITE_FAILED",
@@ -55545,17 +55739,15 @@ var installDependenciesWhileLocked = async (cwd, { force }) => {
55545
55739
  );
55546
55740
  }
55547
55741
  }
55548
- const result = await spawnManaged({
55549
- command: toolchain.name,
55550
- args: ["install"],
55742
+ const { exitCode, installMetrics } = await runWorkspaceInstall(
55743
+ toolchain.name,
55551
55744
  cwd,
55552
- logPath: installLogPath(cwd),
55553
- logHeader: `${toolchain.name} install`
55554
- });
55555
- if (result.exitCode !== 0) {
55745
+ installLogPath(cwd)
55746
+ );
55747
+ if (exitCode !== 0) {
55556
55748
  throw new LinkqueCliError(
55557
55749
  "INSTALL_DEPENDENCY_RESOLVE_FAILED",
55558
- `dependency installation failed with exit code ${result.exitCode}; see ${LOG_DIR}/${INSTALL_LOG}`
55750
+ `dependency installation failed with exit code ${exitCode}; see ${LOG_DIR}/${INSTALL_LOG}`
55559
55751
  );
55560
55752
  }
55561
55753
  const installedFingerprint = await computeFingerprint(
@@ -55567,6 +55759,7 @@ var installDependenciesWhileLocked = async (cwd, { force }) => {
55567
55759
  fingerprint: installedFingerprint,
55568
55760
  forced: force,
55569
55761
  installed: true,
55762
+ installMetrics,
55570
55763
  packageManager: toolchain.name,
55571
55764
  skipped: false
55572
55765
  };
@@ -55584,14 +55777,14 @@ var installDependencies = async (cwd, { force = false } = {}) => withWorkspaceLo
55584
55777
  );
55585
55778
 
55586
55779
  // src/commands/setup.ts
55587
- var import_path18 = __toESM(require("path"));
55780
+ var import_path19 = __toESM(require("path"));
55588
55781
  var CONFIG_FILE = "linkque.config.json";
55589
55782
  var INITIAL_CONFIG = {
55590
55783
  managedBy: "linkquejs",
55591
55784
  schemaVersion: 1
55592
55785
  };
55593
55786
  var assertSupportedProject = async (cwd) => {
55594
- const packageJson = await readUtf8IfExists(import_path18.default.join(cwd, "package.json"));
55787
+ const packageJson = await readUtf8IfExists(import_path19.default.join(cwd, "package.json"));
55595
55788
  if (packageJson === null) {
55596
55789
  throw new LinkqueCliError(
55597
55790
  "SETUP_PROJECT_UNSUPPORTED",
@@ -55630,11 +55823,11 @@ var inspectExistingConfig = async (configPath) => {
55630
55823
  };
55631
55824
  var inspectProjectSetup = async (cwd) => {
55632
55825
  await assertSupportedProject(cwd);
55633
- return await inspectExistingConfig(import_path18.default.join(cwd, CONFIG_FILE));
55826
+ return await inspectExistingConfig(import_path19.default.join(cwd, CONFIG_FILE));
55634
55827
  };
55635
55828
  var setupProject = async (cwd) => {
55636
55829
  await assertSupportedProject(cwd);
55637
- const configPath = import_path18.default.join(cwd, CONFIG_FILE);
55830
+ const configPath = import_path19.default.join(cwd, CONFIG_FILE);
55638
55831
  if (await inspectExistingConfig(configPath)) {
55639
55832
  return { changed: false, managedFiles: [] };
55640
55833
  }
@@ -55681,10 +55874,10 @@ var inspectWorkspaceStatus = async (cwd) => {
55681
55874
 
55682
55875
  // src/commands/build/archive.ts
55683
55876
  var import_crypto6 = require("crypto");
55684
- var import_promises11 = require("fs/promises");
55685
- var import_path19 = __toESM(require("path"));
55877
+ var import_promises13 = require("fs/promises");
55878
+ var import_path20 = __toESM(require("path"));
55686
55879
  var import_stream = require("stream");
55687
- var import_promises12 = require("stream/promises");
55880
+ var import_promises14 = require("stream/promises");
55688
55881
 
55689
55882
  // ../../node_modules/@zip.js/zip.js/lib/zip-fs-wasm.js
55690
55883
  init_configuration();
@@ -56282,46 +56475,52 @@ var ZipWriter = class {
56282
56475
  }
56283
56476
  return false;
56284
56477
  }
56285
- async close(comment = EMPTY_UINT8_ARRAY, options = {}) {
56478
+ close(comment = EMPTY_UINT8_ARRAY, options = {}) {
56286
56479
  const zipWriter = this;
56287
- const { pendingAddFileCalls, writer } = this;
56288
- const { writable } = writer;
56289
56480
  if (zipWriter.archiveClosed) {
56290
- return getWriterData(writer);
56291
- }
56292
- if (!(comment instanceof Uint8Array)) {
56293
- throw new Error(ERR_INVALID_COMMENT_TYPE);
56294
- }
56295
- if (getLength(comment) > MAX_16_BITS) {
56296
- throw new Error(ERR_INVALID_COMMENT);
56297
- }
56298
- while (pendingAddFileCalls.size) {
56299
- await Promise.allSettled(Array.from(pendingAddFileCalls));
56300
- }
56301
- await Promise.allSettled(zipWriter.pendingErrors.map((watcher) => watcher.recorded));
56302
- const unobservedWatchers = zipWriter.pendingErrors.filter((watcher) => watcher.failed && !watcher.observed);
56303
- if (unobservedWatchers.length) {
56304
- const unobservedErrors = unobservedWatchers.map((watcher) => watcher.error);
56305
- unobservedWatchers.forEach((watcher) => watcher.observed = true);
56306
- const [error2] = unobservedErrors;
56307
- try {
56308
- error2.entryErrors = unobservedErrors;
56309
- } catch {
56310
- }
56311
- throw error2;
56481
+ return Promise.resolve(getWriterData(zipWriter.writer));
56312
56482
  }
56313
- await closeFile(zipWriter, comment, options);
56314
- zipWriter.archiveClosed = true;
56315
- const preventClose = !ownsWritable(writer) && getOptionValue2(zipWriter, options, OPTION_PREVENT_CLOSE);
56316
- if (!preventClose) {
56317
- await writable.getWriter().close();
56483
+ if (!zipWriter.pendingClose) {
56484
+ zipWriter.pendingClose = closeArchive(zipWriter, comment, options).finally(() => zipWriter.pendingClose = UNDEFINED_VALUE);
56318
56485
  }
56319
- return getWriterData(writer);
56486
+ return zipWriter.pendingClose;
56320
56487
  }
56321
56488
  [SYMBOL_ASYNC_DISPOSE]() {
56322
56489
  return this.close();
56323
56490
  }
56324
56491
  };
56492
+ async function closeArchive(zipWriter, comment, options) {
56493
+ const { pendingAddFileCalls, writer } = zipWriter;
56494
+ const { writable } = writer;
56495
+ if (!(comment instanceof Uint8Array)) {
56496
+ throw new Error(ERR_INVALID_COMMENT_TYPE);
56497
+ }
56498
+ if (getLength(comment) > MAX_16_BITS) {
56499
+ throw new Error(ERR_INVALID_COMMENT);
56500
+ }
56501
+ while (pendingAddFileCalls.size) {
56502
+ await Promise.allSettled(Array.from(pendingAddFileCalls));
56503
+ }
56504
+ await Promise.allSettled(zipWriter.pendingErrors.map((watcher) => watcher.recorded));
56505
+ const unobservedWatchers = zipWriter.pendingErrors.filter((watcher) => watcher.failed && !watcher.observed);
56506
+ if (unobservedWatchers.length) {
56507
+ const unobservedErrors = unobservedWatchers.map((watcher) => watcher.error);
56508
+ unobservedWatchers.forEach((watcher) => watcher.observed = true);
56509
+ const [error2] = unobservedErrors;
56510
+ try {
56511
+ error2.entryErrors = unobservedErrors;
56512
+ } catch {
56513
+ }
56514
+ throw error2;
56515
+ }
56516
+ await closeFile(zipWriter, comment, options);
56517
+ zipWriter.archiveClosed = true;
56518
+ const preventClose = !ownsWritable(writer) && getOptionValue2(zipWriter, options, OPTION_PREVENT_CLOSE);
56519
+ if (!preventClose) {
56520
+ await writable.getWriter().close();
56521
+ }
56522
+ return getWriterData(writer);
56523
+ }
56325
56524
  var WatchedPromise = class extends Promise {
56326
56525
  then(onFulfilled, onRejected) {
56327
56526
  const { watcher } = this;
@@ -59020,7 +59219,7 @@ var walkFiles = async (root, exclude = /* @__PURE__ */ new Set()) => {
59020
59219
  const visit = async (current) => {
59021
59220
  let entries;
59022
59221
  try {
59023
- entries = await (0, import_promises11.readdir)(current, { withFileTypes: true });
59222
+ entries = await (0, import_promises13.readdir)(current, { withFileTypes: true });
59024
59223
  } catch (error2) {
59025
59224
  if (isNodeError(error2, "ENOENT")) return [];
59026
59225
  throw error2;
@@ -59028,13 +59227,13 @@ var walkFiles = async (root, exclude = /* @__PURE__ */ new Set()) => {
59028
59227
  const files = [];
59029
59228
  for (const entry of entries) {
59030
59229
  if (exclude.has(entry.name)) continue;
59031
- const absolutePath = import_path19.default.join(current, entry.name);
59230
+ const absolutePath = import_path20.default.join(current, entry.name);
59032
59231
  if (entry.isDirectory()) {
59033
59232
  files.push(...await visit(absolutePath));
59034
59233
  } else if (entry.isFile()) {
59035
59234
  files.push({
59036
59235
  absolutePath,
59037
- archivePath: import_path19.default.relative(root, absolutePath).split(import_path19.default.sep).join("/")
59236
+ archivePath: import_path20.default.relative(root, absolutePath).split(import_path20.default.sep).join("/")
59038
59237
  });
59039
59238
  }
59040
59239
  }
@@ -59053,7 +59252,7 @@ var HashingArchiveWriter = class extends import_stream.Writable {
59053
59252
  handle;
59054
59253
  size = 0;
59055
59254
  async initialize() {
59056
- this.handle = await (0, import_promises11.open)(this.archivePath, "wx");
59255
+ this.handle = await (0, import_promises13.open)(this.archivePath, "wx");
59057
59256
  }
59058
59257
  identity() {
59059
59258
  return { sha256: this.hash.digest("hex"), size: this.size };
@@ -59115,7 +59314,7 @@ var writeArchive = async (files, tempPath, options = {}, frozenContents = /* @__
59115
59314
  try {
59116
59315
  for (const file of files) {
59117
59316
  const frozen = frozenContents.get(file.archivePath);
59118
- const content = frozen ?? await (0, import_promises11.readFile)(file.absolutePath);
59317
+ const content = frozen ?? await (0, import_promises13.readFile)(file.absolutePath);
59119
59318
  await appendFile(file.archivePath, content);
59120
59319
  }
59121
59320
  await zip.close();
@@ -59129,7 +59328,7 @@ var writeArchive = async (files, tempPath, options = {}, frozenContents = /* @__
59129
59328
  };
59130
59329
  } catch (error2) {
59131
59330
  output.destroy();
59132
- await (0, import_promises12.finished)(output).catch(() => void 0);
59331
+ await (0, import_promises14.finished)(output).catch(() => void 0);
59133
59332
  if (error2 instanceof LinkqueCliError) throw error2;
59134
59333
  throw new LinkqueCliError(
59135
59334
  "BUILD_ARCHIVE_FAILED",
@@ -59152,14 +59351,14 @@ var runBuild = async (cwd) => {
59152
59351
  command: TOOLCHAIN2,
59153
59352
  args: ["run", "build"],
59154
59353
  cwd,
59155
- logPath: import_path20.default.join(cwd, LOG_PATH),
59354
+ logPath: import_path21.default.join(cwd, LOG_PATH),
59156
59355
  logHeader: `${TOOLCHAIN2} run build`
59157
59356
  });
59158
59357
  return exitCode;
59159
59358
  };
59160
59359
  var assertBuildCommand = async (cwd) => {
59161
59360
  const packageJson = parseJsonObject(
59162
- await (0, import_promises13.readFile)(import_path20.default.join(cwd, "package.json"), "utf8").catch((error2) => {
59361
+ await (0, import_promises15.readFile)(import_path21.default.join(cwd, "package.json"), "utf8").catch((error2) => {
59163
59362
  throw new LinkqueCliError(
59164
59363
  "BUILD_COMMAND_NOT_FOUND",
59165
59364
  "workspace package.json must contain a build script",
@@ -59189,10 +59388,10 @@ var assertBuildOutput = (files) => {
59189
59388
  }
59190
59389
  };
59191
59390
  var buildDistWhileLocked = async (cwd) => {
59192
- const outputPath = import_path20.default.join(cwd, OUTPUT_DIR);
59193
- const finalPath = import_path20.default.join(cwd, ARCHIVE_PATH);
59391
+ const outputPath = import_path21.default.join(cwd, OUTPUT_DIR);
59392
+ const finalPath = import_path21.default.join(cwd, ARCHIVE_PATH);
59194
59393
  const tempPath = `${finalPath}.${process.pid}.${(0, import_crypto7.randomUUID)()}.tmp`;
59195
- await (0, import_promises13.rm)(finalPath, { force: true }).catch((error2) => {
59394
+ await (0, import_promises15.rm)(finalPath, { force: true }).catch((error2) => {
59196
59395
  throw new LinkqueCliError(
59197
59396
  "BUILD_ARCHIVE_FAILED",
59198
59397
  "stale build archive could not be removed",
@@ -59217,7 +59416,7 @@ var buildDistWhileLocked = async (cwd) => {
59217
59416
  );
59218
59417
  }
59219
59418
  await assertBuildCommand(cwd);
59220
- await (0, import_promises13.rm)(outputPath, { force: true, recursive: true }).catch(
59419
+ await (0, import_promises15.rm)(outputPath, { force: true, recursive: true }).catch(
59221
59420
  (error2) => {
59222
59421
  throw new LinkqueCliError(
59223
59422
  "BUILD_FAILED",
@@ -59252,7 +59451,7 @@ var buildDistWhileLocked = async (cwd) => {
59252
59451
  );
59253
59452
  }
59254
59453
  );
59255
- await (0, import_promises13.rename)(tempPath, finalPath).catch((error2) => {
59454
+ await (0, import_promises15.rename)(tempPath, finalPath).catch((error2) => {
59256
59455
  throw new LinkqueCliError(
59257
59456
  "BUILD_ARCHIVE_FAILED",
59258
59457
  "build archive could not be finalized",
@@ -59269,8 +59468,8 @@ var buildDistWhileLocked = async (cwd) => {
59269
59468
  } catch (error2) {
59270
59469
  try {
59271
59470
  await Promise.all([
59272
- (0, import_promises13.rm)(finalPath, { force: true }),
59273
- (0, import_promises13.rm)(tempPath, { force: true })
59471
+ (0, import_promises15.rm)(finalPath, { force: true }),
59472
+ (0, import_promises15.rm)(tempPath, { force: true })
59274
59473
  ]);
59275
59474
  } catch (cleanupError) {
59276
59475
  throw preservePrimaryFailure(error2, cleanupError);
@@ -59280,21 +59479,22 @@ var buildDistWhileLocked = async (cwd) => {
59280
59479
  };
59281
59480
  var buildDist = async (cwd) => withWorkspaceLock(
59282
59481
  {
59283
- path: import_path20.default.join(cwd, LOCK_PATH),
59482
+ path: import_path21.default.join(cwd, LOCK_PATH),
59284
59483
  name: "build",
59285
59484
  acquireErrorCode: "BUILD_LOCK_TIMEOUT",
59286
59485
  releaseErrorCode: "BUILD_ARCHIVE_FAILED",
59287
59486
  retryMs: LOCK_RETRY_MS3,
59288
59487
  timeoutMs: LOCK_TIMEOUT_MS4,
59289
- onReleaseFailure: () => (0, import_promises13.rm)(import_path20.default.join(cwd, ARCHIVE_PATH), { force: true })
59488
+ onReleaseFailure: () => (0, import_promises15.rm)(import_path21.default.join(cwd, ARCHIVE_PATH), { force: true })
59290
59489
  },
59291
59490
  () => buildDistWhileLocked(cwd)
59292
59491
  );
59293
59492
 
59294
59493
  // src/commands/build/snapshot.ts
59295
59494
  var import_crypto8 = require("crypto");
59296
- var import_promises14 = require("fs/promises");
59297
- var import_path21 = __toESM(require("path"));
59495
+ var import_promises16 = require("fs/promises");
59496
+ var import_path22 = __toESM(require("path"));
59497
+ var import_promises17 = require("fs/promises");
59298
59498
  var ARTIFACTS_DIR = ".linkque/artifacts";
59299
59499
  var AGENT_CONFIG_SOURCE_PATH = "agent_config.json";
59300
59500
  var TEMPLATE_ARTIFACT_SOURCE_PATH = "template-artifact.json";
@@ -59314,8 +59514,8 @@ var snapshotFailure = (message, cause) => cause instanceof LinkqueCliError ? cau
59314
59514
  var readTemplateVersion = async (cwd) => {
59315
59515
  let content;
59316
59516
  try {
59317
- content = await (0, import_promises14.readFile)(
59318
- import_path21.default.join(cwd, TEMPLATE_ARTIFACT_SOURCE_PATH),
59517
+ content = await (0, import_promises16.readFile)(
59518
+ import_path22.default.join(cwd, TEMPLATE_ARTIFACT_SOURCE_PATH),
59319
59519
  "utf8"
59320
59520
  );
59321
59521
  } catch (error2) {
@@ -59335,15 +59535,15 @@ var readTemplateVersion = async (cwd) => {
59335
59535
  };
59336
59536
  var buildSnapshotWhileLocked = async (cwd, options) => {
59337
59537
  const snapshotDir = `snapshot-${(0, import_crypto8.randomUUID)()}`;
59338
- const relDir = import_path21.default.join(ARTIFACTS_DIR, snapshotDir);
59339
- const dirPath = import_path21.default.join(cwd, relDir);
59340
- const archiveRel = import_path21.default.join(relDir, "source.zip");
59341
- const finalPath = import_path21.default.join(cwd, archiveRel);
59538
+ const relDir = import_path22.default.join(ARTIFACTS_DIR, snapshotDir);
59539
+ const dirPath = import_path22.default.join(cwd, relDir);
59540
+ const archiveRel = import_path22.default.join(relDir, "source.zip");
59541
+ const finalPath = import_path22.default.join(cwd, archiveRel);
59342
59542
  const tempPath = `${finalPath}.${process.pid}.tmp`;
59343
59543
  try {
59344
59544
  let rootStat;
59345
59545
  try {
59346
- rootStat = await (0, import_promises14.lstat)(cwd, { bigint: true });
59546
+ rootStat = await (0, import_promises16.lstat)(cwd, { bigint: true });
59347
59547
  } catch (error2) {
59348
59548
  throw snapshotFailure("workspace source could not be inspected", error2);
59349
59549
  }
@@ -59353,32 +59553,45 @@ var buildSnapshotWhileLocked = async (cwd, options) => {
59353
59553
  "snapshot root must be a directory"
59354
59554
  );
59355
59555
  }
59556
+ const cardSource = splitAgentCards(
59557
+ await readAgentCards(import_path22.default.join(cwd, AGENT_CONFIG_SOURCE_PATH))
59558
+ );
59559
+ const cardFilesPath = import_path22.default.join(relDir, "card-files.json");
59560
+ await ensureParentDir(import_path22.default.join(cwd, cardFilesPath));
59561
+ await (0, import_promises17.writeFile)(import_path22.default.join(cwd, cardFilesPath), canonicalJson(cardSource));
59356
59562
  const excludedComponents = new Set(BASE_EXCLUDED_COMPONENTS);
59357
59563
  if (options.excludePlatformSdk) excludedComponents.add(".platform-sdk");
59358
- const files = await walkFiles(cwd, excludedComponents).catch(
59564
+ const walkedFiles = await walkFiles(cwd, excludedComponents).catch(
59359
59565
  (error2) => {
59360
59566
  throw snapshotFailure("workspace source could not be inspected", error2);
59361
59567
  }
59362
59568
  );
59363
- const agentConfigContent = await (0, import_promises14.readFile)(
59364
- import_path21.default.join(cwd, AGENT_CONFIG_SOURCE_PATH)
59365
- ).catch((error2) => {
59366
- if (isNodeError(error2, "ENOENT")) {
59367
- throw new LinkqueCliError(
59368
- "SNAPSHOT_FAILED",
59369
- "workspace is missing agent_config.json"
59370
- );
59371
- }
59372
- throw snapshotFailure("agent_config.json could not be read", error2);
59373
- });
59569
+ const files = [
59570
+ ...walkedFiles.filter((file) => !file.archivePath.startsWith("cards/")),
59571
+ ...Object.keys(cardSource.files).map((archivePath) => ({
59572
+ archivePath,
59573
+ absolutePath: import_path22.default.join(cwd, archivePath)
59574
+ }))
59575
+ ].sort(
59576
+ (a, b3) => a.archivePath < b3.archivePath ? -1 : a.archivePath > b3.archivePath ? 1 : 0
59577
+ );
59578
+ const agentConfigContent = Buffer.from(
59579
+ JSON.stringify(cardSource.config, null, 2) + "\n"
59580
+ );
59374
59581
  if (!files.some((file) => file.archivePath === AGENT_CONFIG_SOURCE_PATH)) {
59375
59582
  throw new LinkqueCliError(
59376
59583
  "SNAPSHOT_FAILED",
59377
59584
  "agent_config.json is not part of the walked source tree"
59378
59585
  );
59379
59586
  }
59380
- const frozenContents = /* @__PURE__ */ new Map([
59381
- [AGENT_CONFIG_SOURCE_PATH, agentConfigContent]
59587
+ const frozenContents = new Map([
59588
+ [AGENT_CONFIG_SOURCE_PATH, agentConfigContent],
59589
+ ...Object.entries(cardSource.files).map(
59590
+ ([file, value]) => [
59591
+ file,
59592
+ Buffer.from(canonicalJson(value))
59593
+ ]
59594
+ )
59382
59595
  ]);
59383
59596
  const templateVersion = await readTemplateVersion(cwd);
59384
59597
  await ensureParentDir(finalPath);
@@ -59394,7 +59607,7 @@ var buildSnapshotWhileLocked = async (cwd, options) => {
59394
59607
  error2
59395
59608
  );
59396
59609
  });
59397
- await (0, import_promises14.rename)(tempPath, finalPath).catch((error2) => {
59610
+ await (0, import_promises16.rename)(tempPath, finalPath).catch((error2) => {
59398
59611
  throw new LinkqueCliError(
59399
59612
  "SNAPSHOT_FAILED",
59400
59613
  "source archive could not be finalized",
@@ -59409,20 +59622,21 @@ var buildSnapshotWhileLocked = async (cwd, options) => {
59409
59622
  totalBytes: identity.sourceBytes,
59410
59623
  sourceChecksum: identity.sourceChecksum,
59411
59624
  agentConfigBase64: agentConfigContent.toString("base64"),
59625
+ cardFilesPath,
59412
59626
  ...templateVersion ? { templateVersion } : {}
59413
59627
  };
59414
59628
  } catch (error2) {
59415
59629
  try {
59416
- await (0, import_promises14.rm)(dirPath, { force: true, recursive: true });
59630
+ await (0, import_promises16.rm)(dirPath, { force: true, recursive: true });
59417
59631
  } catch (cleanupError) {
59418
59632
  throw preservePrimaryFailure(error2, cleanupError);
59419
59633
  }
59420
- throw error2;
59634
+ throw snapshotFailure("workspace snapshot could not be created", error2);
59421
59635
  }
59422
59636
  };
59423
59637
  var buildSnapshot = async (cwd, options = {}) => withWorkspaceLock(
59424
59638
  {
59425
- path: import_path21.default.join(cwd, LOCK_PATH2),
59639
+ path: import_path22.default.join(cwd, LOCK_PATH2),
59426
59640
  name: "snapshot",
59427
59641
  acquireErrorCode: "SNAPSHOT_FAILED",
59428
59642
  releaseErrorCode: "SNAPSHOT_FAILED",
@@ -59435,12 +59649,12 @@ var buildSnapshot = async (cwd, options = {}) => withWorkspaceLock(
59435
59649
 
59436
59650
  // src/commands/card/index.ts
59437
59651
  var import_crypto9 = require("crypto");
59438
- var import_promises16 = require("fs/promises");
59439
- var import_path23 = __toESM(require("path"));
59652
+ var import_promises19 = require("fs/promises");
59653
+ var import_path24 = __toESM(require("path"));
59440
59654
 
59441
59655
  // src/commands/mcpDescribe.ts
59442
- var import_promises15 = require("fs/promises");
59443
- var import_path22 = __toESM(require("path"));
59656
+ var import_promises18 = require("fs/promises");
59657
+ var import_path23 = __toESM(require("path"));
59444
59658
  var MCP_DETAIL_ENDPOINT_ENV = "LINKQUE_MCP_DETAIL_ENDPOINT";
59445
59659
  var MCP_DETAIL_ENABLED_ENV = "LINKQUE_MCP_DETAIL_ENABLED";
59446
59660
  var TIMEOUT_MS = 15e3;
@@ -59509,7 +59723,7 @@ function requireEnabled(env) {
59509
59723
  async function readMountedMcp(cwd, resourceId) {
59510
59724
  let content;
59511
59725
  try {
59512
- content = await (0, import_promises15.readFile)(import_path22.default.join(cwd, "agent_config.json"));
59726
+ content = await (0, import_promises18.readFile)(import_path23.default.join(cwd, "agent_config.json"));
59513
59727
  } catch {
59514
59728
  throw new LinkqueCliError(
59515
59729
  "MCP_CONFIG_READ_FAILED",
@@ -59790,7 +60004,7 @@ var SHA256_PATTERN = /^[0-9a-f]{64}$/u;
59790
60004
  async function listCardDrafts(cwd) {
59791
60005
  const [directories, configModifiedAt, runtimeSupportedSchemaVersions] = await Promise.all([
59792
60006
  listDraftDirectories(cwd),
59793
- readModifiedAt(import_path23.default.join(cwd, AGENT_CONFIG_PATH)),
60007
+ readModifiedAt(import_path24.default.join(cwd, AGENT_CONFIG_PATH)),
59794
60008
  readRuntimeSupportedSchemaVersions(cwd)
59795
60009
  ]);
59796
60010
  const drafts = await Promise.all(
@@ -59802,7 +60016,7 @@ async function readCardDraft(cwd, draftId) {
59802
60016
  assertDraftId(draftId);
59803
60017
  const directory = draftDirectory(cwd, draftId);
59804
60018
  const stateValue = await readRequiredJson(
59805
- import_path23.default.join(directory, "state.json"),
60019
+ import_path24.default.join(directory, "state.json"),
59806
60020
  "CARD_DRAFT_NOT_FOUND"
59807
60021
  );
59808
60022
  const state = parseCardDraftState(stateValue);
@@ -59814,8 +60028,8 @@ async function readCardDraft(cwd, draftId) {
59814
60028
  }
59815
60029
  const [bundle, savedValue, theme] = await Promise.all([
59816
60030
  readBundle(directory, draftId),
59817
- readOptionalJson(import_path23.default.join(directory, "saved.json")),
59818
- readOptionalJsonObject(import_path23.default.join(cwd, THEME_PATH))
60031
+ readOptionalJson(import_path24.default.join(directory, "saved.json")),
60032
+ readOptionalJsonObject(import_path24.default.join(cwd, THEME_PATH))
59819
60033
  ]);
59820
60034
  const saved = parseSavedMarker(savedValue);
59821
60035
  return {
@@ -59843,13 +60057,13 @@ async function prepareCardBindingContext(cwd, draftId, resourceIds, env = proces
59843
60057
  }
59844
60058
  const selectedIds = [...new Set(resourceIds)];
59845
60059
  const directory = draftDirectory(cwd, draftId);
59846
- const contextPath = import_path23.default.join(DRAFT_ROOT, draftId, "binding-context.json");
59847
- const file = import_path23.default.join(cwd, contextPath);
60060
+ const contextPath = import_path24.default.join(DRAFT_ROOT, draftId, "binding-context.json");
60061
+ const file = import_path24.default.join(cwd, contextPath);
59848
60062
  await assertBindingContextDirectory(cwd, directory);
59849
60063
  const bundle = await readBundle(directory, draftId);
59850
60064
  const readConfig = async () => parseAgentConfig(
59851
60065
  await readRequiredJsonWithLimit(
59852
- import_path23.default.join(cwd, AGENT_CONFIG_PATH),
60066
+ import_path24.default.join(cwd, AGENT_CONFIG_PATH),
59853
60067
  AGENT_CONFIG_MAX_BYTES
59854
60068
  )
59855
60069
  );
@@ -59953,15 +60167,15 @@ async function prepareCardBindingContext(cwd, draftId, resourceIds, env = proces
59953
60167
  }
59954
60168
  async function assertBindingContextDirectory(cwd, directory) {
59955
60169
  try {
59956
- const canonicalWorkspace = await (0, import_promises16.realpath)(cwd);
59957
- if (await (0, import_promises16.realpath)(directory) !== import_path23.default.join(canonicalWorkspace, import_path23.default.relative(cwd, directory))) {
60170
+ const canonicalWorkspace = await (0, import_promises19.realpath)(cwd);
60171
+ if (await (0, import_promises19.realpath)(directory) !== import_path24.default.join(canonicalWorkspace, import_path24.default.relative(cwd, directory))) {
59958
60172
  throw new LinkqueCliError(
59959
60173
  "CARD_DRAFT_INVALID",
59960
60174
  "\u7ED1\u5B9A\u4E0A\u4E0B\u6587\u4E0D\u80FD\u4F4D\u4E8E\u7B26\u53F7\u94FE\u63A5\u76EE\u5F55"
59961
60175
  );
59962
60176
  }
59963
- const entry = await (0, import_promises16.lstat)(
59964
- import_path23.default.join(directory, "binding-context.json")
60177
+ const entry = await (0, import_promises19.lstat)(
60178
+ import_path24.default.join(directory, "binding-context.json")
59965
60179
  ).catch((cause) => {
59966
60180
  if (isNodeError(cause, "ENOENT")) return void 0;
59967
60181
  throw cause;
@@ -59986,7 +60200,7 @@ async function finalizeCard(cwd, draftId, expectedDraftChecksum, _contextChecksu
59986
60200
  assertChecksum(expectedDraftChecksum, "\u8349\u7A3F checksum");
59987
60201
  return withWorkspaceLock(
59988
60202
  {
59989
- path: import_path23.default.join(cwd, FINALIZE_LOCK_PATH),
60203
+ path: import_path24.default.join(cwd, FINALIZE_LOCK_PATH),
59990
60204
  name: "card finalize",
59991
60205
  acquireErrorCode: "CARD_FINALIZE_LOCK_TIMEOUT",
59992
60206
  releaseErrorCode: "CARD_FINALIZE_LOCK_RELEASE_FAILED",
@@ -59997,7 +60211,7 @@ async function finalizeCard(cwd, draftId, expectedDraftChecksum, _contextChecksu
59997
60211
  );
59998
60212
  }
59999
60213
  async function finalizeCardFromRequest(cwd, requestFile) {
60000
- const value = await readRequiredJson(import_path23.default.resolve(cwd, requestFile));
60214
+ const value = await readRequiredJson(import_path24.default.resolve(cwd, requestFile));
60001
60215
  if (!isJsonObject(value) || value.version !== 1 || typeof value.draftId !== "string" || typeof value.expectedDraftChecksum !== "string" || value.contextChecksum !== void 0 && typeof value.contextChecksum !== "string" || Object.keys(value).some(
60002
60216
  (key) => ![
60003
60217
  "version",
@@ -60021,7 +60235,7 @@ async function finalizeCardFromRequest(cwd, requestFile) {
60021
60235
  }
60022
60236
  async function previewCardTransformFromRequest(cwd, requestFile) {
60023
60237
  const value = await readRequiredJsonWithLimit(
60024
- import_path23.default.resolve(cwd, requestFile),
60238
+ import_path24.default.resolve(cwd, requestFile),
60025
60239
  TRANSFORM_PREVIEW_REQUEST_MAX_BYTES
60026
60240
  );
60027
60241
  if (!isCardTransformPreviewRequest(value)) {
@@ -60070,7 +60284,7 @@ async function rollbackCardFinalize(cwd, rollbackToken) {
60070
60284
  const payload = parseRollbackToken(rollbackToken);
60071
60285
  return withWorkspaceLock(
60072
60286
  {
60073
- path: import_path23.default.join(cwd, FINALIZE_LOCK_PATH),
60287
+ path: import_path24.default.join(cwd, FINALIZE_LOCK_PATH),
60074
60288
  name: "card rollback",
60075
60289
  acquireErrorCode: "CARD_FINALIZE_LOCK_TIMEOUT",
60076
60290
  releaseErrorCode: "CARD_FINALIZE_LOCK_RELEASE_FAILED",
@@ -60078,8 +60292,8 @@ async function rollbackCardFinalize(cwd, rollbackToken) {
60078
60292
  timeoutMs: FINALIZE_LOCK_TIMEOUT_MS
60079
60293
  },
60080
60294
  async () => {
60081
- const configPath = import_path23.default.join(cwd, AGENT_CONFIG_PATH);
60082
- const current = await (0, import_promises16.readFile)(configPath);
60295
+ const configPath = import_path24.default.join(cwd, AGENT_CONFIG_PATH);
60296
+ const current = await (0, import_promises19.readFile)(configPath);
60083
60297
  if (checksumBytes(current) !== payload.expectedConfigChecksum) {
60084
60298
  throw new LinkqueCliError(
60085
60299
  "CARD_FINALIZE_CONFLICT",
@@ -60106,8 +60320,8 @@ async function validateCardBindingsFromDisk(cwd, draftId, fieldId) {
60106
60320
  async function validateCardBindingsForBundle(cwd, draftId, bundle, fieldId) {
60107
60321
  const directory = draftDirectory(cwd, draftId);
60108
60322
  const [contextValue, configValue] = await Promise.all([
60109
- readOptionalJson(import_path23.default.join(directory, "binding-context.json")),
60110
- readRequiredJson(import_path23.default.join(cwd, AGENT_CONFIG_PATH))
60323
+ readOptionalJson(import_path24.default.join(directory, "binding-context.json")),
60324
+ readAgentCards(import_path24.default.join(cwd, AGENT_CONFIG_PATH))
60111
60325
  ]);
60112
60326
  const context = parseOptionalBindingContext(contextValue);
60113
60327
  const draftStructureChecksum = createA2UICardDraftStructureChecksum(bundle);
@@ -60215,13 +60429,11 @@ async function finalizeCardWhileLocked(cwd, draftId, expectedDraftChecksum) {
60215
60429
  }
60216
60430
  }
60217
60431
  const context = parseOptionalBindingContext(
60218
- await readOptionalJson(import_path23.default.join(directory, "binding-context.json"))
60219
- );
60220
- const configPath = import_path23.default.join(cwd, AGENT_CONFIG_PATH);
60221
- const oldConfigBytes = await (0, import_promises16.readFile)(configPath);
60222
- const config3 = parseAgentConfig(
60223
- JSON.parse(oldConfigBytes.toString("utf8"))
60432
+ await readOptionalJson(import_path24.default.join(directory, "binding-context.json"))
60224
60433
  );
60434
+ const configPath = import_path24.default.join(cwd, AGENT_CONFIG_PATH);
60435
+ const oldConfigBytes = await (0, import_promises19.readFile)(configPath);
60436
+ const config3 = parseAgentConfig(await readAgentCards(configPath));
60225
60437
  const resources = config3.agent.resources;
60226
60438
  const existingIndex = resources.findIndex(
60227
60439
  (resource) => resource.resourceType === "CARD" && resource.resourceId === bundle.manifest.resourceId
@@ -60255,7 +60467,7 @@ async function finalizeCardWhileLocked(cwd, draftId, expectedDraftChecksum) {
60255
60467
  agent: { ...config3.agent, resources: nextResources }
60256
60468
  };
60257
60469
  const nextConfigBytes = Buffer.from(
60258
- `${JSON.stringify(nextConfig, null, 2)}
60470
+ `${JSON.stringify(splitAgentCards(nextConfig).config, null, 2)}
60259
60471
  `,
60260
60472
  "utf8"
60261
60473
  );
@@ -60272,12 +60484,15 @@ async function finalizeCardWhileLocked(cwd, draftId, expectedDraftChecksum) {
60272
60484
  manifest: { ...bundle.manifest, baseRevision: cardRevision }
60273
60485
  };
60274
60486
  const rebasedDraftChecksum = draftChecksum(rebasedBundle);
60275
- await atomicWrite(configPath, nextConfigBytes);
60487
+ await writeAgentCards(
60488
+ configPath,
60489
+ nextConfig
60490
+ );
60276
60491
  const savedAt = (/* @__PURE__ */ new Date()).toISOString();
60277
60492
  try {
60278
60493
  await Promise.all([
60279
60494
  atomicWrite(
60280
- import_path23.default.join(directory, "saved.json"),
60495
+ import_path24.default.join(directory, "saved.json"),
60281
60496
  Buffer.from(
60282
60497
  `${JSON.stringify(
60283
60498
  {
@@ -60294,7 +60509,7 @@ async function finalizeCardWhileLocked(cwd, draftId, expectedDraftChecksum) {
60294
60509
  )
60295
60510
  ),
60296
60511
  atomicWrite(
60297
- import_path23.default.join(directory, "state.json"),
60512
+ import_path24.default.join(directory, "state.json"),
60298
60513
  Buffer.from(
60299
60514
  `${JSON.stringify(
60300
60515
  { version: 1, status: "ready", updatedAt: savedAt },
@@ -60339,7 +60554,7 @@ async function inspectDraft(cwd, directory) {
60339
60554
  );
60340
60555
  }
60341
60556
  const root = draftDirectory(cwd, draftId);
60342
- const stateValue = await readOptionalJson(import_path23.default.join(root, "state.json"));
60557
+ const stateValue = await readOptionalJson(import_path24.default.join(root, "state.json"));
60343
60558
  if (stateValue === void 0) {
60344
60559
  return invalidDraft(
60345
60560
  draftId,
@@ -60370,7 +60585,7 @@ async function inspectDraft(cwd, directory) {
60370
60585
  try {
60371
60586
  const bundle = await readBundle(root, draftId);
60372
60587
  const saved = parseSavedMarker(
60373
- await readOptionalJson(import_path23.default.join(root, "saved.json"))
60588
+ await readOptionalJson(import_path24.default.join(root, "saved.json"))
60374
60589
  );
60375
60590
  return {
60376
60591
  checksum: draftChecksum(bundle),
@@ -60391,9 +60606,9 @@ async function inspectDraft(cwd, directory) {
60391
60606
  }
60392
60607
  async function readBundle(directory, draftId) {
60393
60608
  const [manifest, card, fixture] = await Promise.all([
60394
- readRequiredJson(import_path23.default.join(directory, "manifest.json")),
60395
- readRequiredJson(import_path23.default.join(directory, "card.json")),
60396
- readRequiredJson(import_path23.default.join(directory, "fixture.json"))
60609
+ readRequiredJson(import_path24.default.join(directory, "manifest.json")),
60610
+ readRequiredJson(import_path24.default.join(directory, "card.json")),
60611
+ readRequiredJson(import_path24.default.join(directory, "fixture.json"))
60397
60612
  ]);
60398
60613
  const parsed = parseA2UICardDraftBundle({ manifest, card, fixture });
60399
60614
  if (!parsed.success || parsed.data.manifest.draftId !== draftId) {
@@ -60405,10 +60620,10 @@ async function readBundle(directory, draftId) {
60405
60620
  return parsed.data;
60406
60621
  }
60407
60622
  async function listDraftDirectories(cwd) {
60408
- const root = import_path23.default.join(cwd, DRAFT_ROOT);
60623
+ const root = import_path24.default.join(cwd, DRAFT_ROOT);
60409
60624
  let entries;
60410
60625
  try {
60411
- entries = await (0, import_promises16.readdir)(root, { withFileTypes: true });
60626
+ entries = await (0, import_promises19.readdir)(root, { withFileTypes: true });
60412
60627
  } catch (cause) {
60413
60628
  if (isNodeError(cause, "ENOENT")) return [];
60414
60629
  throw new LinkqueCliError(
@@ -60420,7 +60635,7 @@ async function listDraftDirectories(cwd) {
60420
60635
  const directories = await Promise.all(
60421
60636
  entries.filter((entry) => entry.isDirectory()).map(async (entry) => ({
60422
60637
  draftId: entry.name,
60423
- modifiedAt: await readModifiedAt(import_path23.default.join(root, entry.name))
60638
+ modifiedAt: await readModifiedAt(import_path24.default.join(root, entry.name))
60424
60639
  }))
60425
60640
  );
60426
60641
  if (directories.length > DRAFT_LIST_LIMIT) {
@@ -60447,11 +60662,11 @@ function draftIssue(code, message, recoverable, severity) {
60447
60662
  }
60448
60663
  async function readRequiredJson(file, missingCode = "CARD_DRAFT_INVALID") {
60449
60664
  try {
60450
- const content = await (0, import_promises16.readFile)(file, "utf8");
60665
+ const content = await (0, import_promises19.readFile)(file, "utf8");
60451
60666
  if (Buffer.byteLength(content, "utf8") > DRAFT_FILE_MAX_BYTES) {
60452
60667
  throw new LinkqueCliError(
60453
60668
  "CARD_DRAFT_INVALID",
60454
- `${import_path23.default.basename(file)} \u8D85\u8FC7\u5927\u5C0F\u9650\u5236`
60669
+ `${import_path24.default.basename(file)} \u8D85\u8FC7\u5927\u5C0F\u9650\u5236`
60455
60670
  );
60456
60671
  }
60457
60672
  return JSON.parse(content);
@@ -60460,31 +60675,31 @@ async function readRequiredJson(file, missingCode = "CARD_DRAFT_INVALID") {
60460
60675
  if (isNodeError(cause, "ENOENT")) {
60461
60676
  throw new LinkqueCliError(
60462
60677
  missingCode,
60463
- `\u8349\u7A3F\u6587\u4EF6\u7F3A\u5931: ${import_path23.default.basename(file)}`,
60678
+ `\u8349\u7A3F\u6587\u4EF6\u7F3A\u5931: ${import_path24.default.basename(file)}`,
60464
60679
  { cause }
60465
60680
  );
60466
60681
  }
60467
60682
  if (cause instanceof SyntaxError) {
60468
60683
  throw new LinkqueCliError(
60469
60684
  "CARD_DRAFT_INVALID",
60470
- `\u8349\u7A3F\u6587\u4EF6\u4E0D\u662F\u6709\u6548 JSON: ${import_path23.default.basename(file)}`,
60685
+ `\u8349\u7A3F\u6587\u4EF6\u4E0D\u662F\u6709\u6548 JSON: ${import_path24.default.basename(file)}`,
60471
60686
  { cause }
60472
60687
  );
60473
60688
  }
60474
60689
  throw new LinkqueCliError(
60475
60690
  "CARD_DRAFT_READ_FAILED",
60476
- `\u8349\u7A3F\u6587\u4EF6\u8BFB\u53D6\u5931\u8D25: ${import_path23.default.basename(file)}`,
60691
+ `\u8349\u7A3F\u6587\u4EF6\u8BFB\u53D6\u5931\u8D25: ${import_path24.default.basename(file)}`,
60477
60692
  { cause: cause instanceof Error ? cause : void 0 }
60478
60693
  );
60479
60694
  }
60480
60695
  }
60481
60696
  async function readRequiredJsonWithLimit(file, maxBytes) {
60482
60697
  try {
60483
- const content = await (0, import_promises16.readFile)(file, "utf8");
60698
+ const content = await (0, import_promises19.readFile)(file, "utf8");
60484
60699
  if (Buffer.byteLength(content, "utf8") > maxBytes) {
60485
60700
  throw new LinkqueCliError(
60486
60701
  "CARD_DRAFT_INVALID",
60487
- `${import_path23.default.basename(file)} \u8D85\u8FC7\u5927\u5C0F\u9650\u5236`
60702
+ `${import_path24.default.basename(file)} \u8D85\u8FC7\u5927\u5C0F\u9650\u5236`
60488
60703
  );
60489
60704
  }
60490
60705
  return JSON.parse(content);
@@ -60493,20 +60708,20 @@ async function readRequiredJsonWithLimit(file, maxBytes) {
60493
60708
  if (isNodeError(cause, "ENOENT")) {
60494
60709
  throw new LinkqueCliError(
60495
60710
  "CARD_DRAFT_NOT_FOUND",
60496
- `\u8BF7\u6C42\u6587\u4EF6\u7F3A\u5931: ${import_path23.default.basename(file)}`,
60711
+ `\u8BF7\u6C42\u6587\u4EF6\u7F3A\u5931: ${import_path24.default.basename(file)}`,
60497
60712
  { cause }
60498
60713
  );
60499
60714
  }
60500
60715
  if (cause instanceof SyntaxError) {
60501
60716
  throw new LinkqueCliError(
60502
60717
  "CARD_DRAFT_INVALID",
60503
- `\u8BF7\u6C42\u6587\u4EF6\u4E0D\u662F\u6709\u6548 JSON: ${import_path23.default.basename(file)}`,
60718
+ `\u8BF7\u6C42\u6587\u4EF6\u4E0D\u662F\u6709\u6548 JSON: ${import_path24.default.basename(file)}`,
60504
60719
  { cause }
60505
60720
  );
60506
60721
  }
60507
60722
  throw new LinkqueCliError(
60508
60723
  "CARD_DRAFT_READ_FAILED",
60509
- `\u8BF7\u6C42\u6587\u4EF6\u8BFB\u53D6\u5931\u8D25: ${import_path23.default.basename(file)}`,
60724
+ `\u8BF7\u6C42\u6587\u4EF6\u8BFB\u53D6\u5931\u8D25: ${import_path24.default.basename(file)}`,
60510
60725
  { cause: cause instanceof Error ? cause : void 0 }
60511
60726
  );
60512
60727
  }
@@ -60530,7 +60745,7 @@ async function readOptionalJson(file) {
60530
60745
  }
60531
60746
  async function readRuntimeSupportedSchemaVersions(cwd) {
60532
60747
  const value = await readOptionalJson(
60533
- import_path23.default.join(cwd, RUNTIME_CAPABILITIES_PATH)
60748
+ import_path24.default.join(cwd, RUNTIME_CAPABILITIES_PATH)
60534
60749
  ).catch(() => void 0);
60535
60750
  if (!isJsonObject(value) || value.schemaVersion !== 1) {
60536
60751
  return [...LEGACY_RUNTIME_CARD_SCHEMA_VERSIONS];
@@ -60549,19 +60764,19 @@ async function readRuntimeSupportedSchemaVersions(cwd) {
60549
60764
  }
60550
60765
  async function readRuntimeSupportsFunctionActions(cwd) {
60551
60766
  const value = await readOptionalJson(
60552
- import_path23.default.join(cwd, RUNTIME_CAPABILITIES_PATH)
60767
+ import_path24.default.join(cwd, RUNTIME_CAPABILITIES_PATH)
60553
60768
  ).catch(() => void 0);
60554
60769
  return isJsonObject(value) && value.schemaVersion === 1 && isJsonObject(value.a2uiCard) && value.a2uiCard.frontendFunctionActions === true;
60555
60770
  }
60556
60771
  async function readRuntimeSupportsDataPipeline(cwd) {
60557
60772
  const value = await readOptionalJson(
60558
- import_path23.default.join(cwd, RUNTIME_CAPABILITIES_PATH)
60773
+ import_path24.default.join(cwd, RUNTIME_CAPABILITIES_PATH)
60559
60774
  ).catch(() => void 0);
60560
60775
  return isJsonObject(value) && value.schemaVersion === 1 && isJsonObject(value.a2uiCard) && value.a2uiCard.serverDataPipeline === true;
60561
60776
  }
60562
60777
  async function readRuntimeSupportsModelFilledPipelineArguments(cwd) {
60563
60778
  const value = await readOptionalJson(
60564
- import_path23.default.join(cwd, RUNTIME_CAPABILITIES_PATH)
60779
+ import_path24.default.join(cwd, RUNTIME_CAPABILITIES_PATH)
60565
60780
  ).catch(() => void 0);
60566
60781
  return isJsonObject(value) && value.schemaVersion === 1 && isJsonObject(value.a2uiCard) && value.a2uiCard.serverDataPipeline === true && value.a2uiCard.modelFilledPipelineArguments === true;
60567
60782
  }
@@ -60579,7 +60794,7 @@ async function readOptionalJsonObject(file) {
60579
60794
  }
60580
60795
  async function readModifiedAt(file) {
60581
60796
  try {
60582
- return (await (0, import_promises16.stat)(file)).mtime.toISOString();
60797
+ return (await (0, import_promises19.stat)(file)).mtime.toISOString();
60583
60798
  } catch {
60584
60799
  return "";
60585
60800
  }
@@ -60619,7 +60834,7 @@ function assertDraftId(draftId) {
60619
60834
  }
60620
60835
  }
60621
60836
  function draftDirectory(cwd, draftId) {
60622
- return import_path23.default.join(cwd, DRAFT_ROOT, draftId);
60837
+ return import_path24.default.join(cwd, DRAFT_ROOT, draftId);
60623
60838
  }
60624
60839
  function assertChecksum(value, label) {
60625
60840
  if (!SHA256_PATTERN.test(value)) {
@@ -60700,13 +60915,13 @@ async function atomicWrite(file, content) {
60700
60915
  const temporary = `${file}.${process.pid}.${(0, import_crypto9.randomUUID)()}.tmp`;
60701
60916
  let handle;
60702
60917
  try {
60703
- handle = await (0, import_promises16.open)(temporary, "wx", 384);
60918
+ handle = await (0, import_promises19.open)(temporary, "wx", 384);
60704
60919
  await handle.writeFile(content);
60705
60920
  await handle.sync();
60706
60921
  await handle.close();
60707
60922
  handle = void 0;
60708
- await (0, import_promises16.rename)(temporary, file);
60709
- const directoryHandle = await (0, import_promises16.open)(import_path23.default.dirname(file), "r");
60923
+ await (0, import_promises19.rename)(temporary, file);
60924
+ const directoryHandle = await (0, import_promises19.open)(import_path24.default.dirname(file), "r");
60710
60925
  try {
60711
60926
  await directoryHandle.sync();
60712
60927
  } finally {
@@ -60714,10 +60929,10 @@ async function atomicWrite(file, content) {
60714
60929
  }
60715
60930
  } catch (cause) {
60716
60931
  await handle?.close().catch(() => void 0);
60717
- await (0, import_promises16.unlink)(temporary).catch(() => void 0);
60932
+ await (0, import_promises19.unlink)(temporary).catch(() => void 0);
60718
60933
  throw new LinkqueCliError(
60719
60934
  "CARD_FINALIZE_WRITE_FAILED",
60720
- `\u539F\u5B50\u5199\u5165\u5931\u8D25: ${import_path23.default.basename(file)}`,
60935
+ `\u539F\u5B50\u5199\u5165\u5931\u8D25: ${import_path24.default.basename(file)}`,
60721
60936
  { cause: cause instanceof Error ? cause : void 0 }
60722
60937
  );
60723
60938
  }
@@ -60743,15 +60958,15 @@ function parseRollbackToken(token) {
60743
60958
 
60744
60959
  // src/commands/dev.ts
60745
60960
  var import_child_process4 = require("child_process");
60746
- var import_promises18 = require("fs/promises");
60961
+ var import_promises21 = require("fs/promises");
60747
60962
  var import_net2 = require("net");
60748
- var import_path25 = __toESM(require("path"));
60963
+ var import_path26 = __toESM(require("path"));
60749
60964
 
60750
60965
  // src/commands/inspector.ts
60751
60966
  var import_module = require("module");
60752
- var import_promises17 = require("fs/promises");
60967
+ var import_promises20 = require("fs/promises");
60753
60968
  var import_os3 = require("os");
60754
- var import_path24 = __toESM(require("path"));
60969
+ var import_path25 = __toESM(require("path"));
60755
60970
  var import_url = require("url");
60756
60971
  var INSPECTOR_PACKAGES = [
60757
60972
  "@alipay/agent-inspector-workspace",
@@ -60774,7 +60989,7 @@ var importInspectorModule = async (resolvedPath) => {
60774
60989
  };
60775
60990
  var loadInspectorWorkspaceEngine = async (cwd) => {
60776
60991
  try {
60777
- const workspaceRequire = (0, import_module.createRequire)(import_path24.default.join(cwd, "package.json"));
60992
+ const workspaceRequire = (0, import_module.createRequire)(import_path25.default.join(cwd, "package.json"));
60778
60993
  const resolved = /* @__PURE__ */ new Map();
60779
60994
  for (const packageName of INSPECTOR_PACKAGES) {
60780
60995
  resolved.set(packageName, workspaceRequire.resolve(packageName));
@@ -60791,16 +61006,16 @@ var loadInspectorWorkspaceEngine = async (cwd) => {
60791
61006
  );
60792
61007
  }
60793
61008
  };
60794
- var managedRequestDirectory = () => import_path24.default.join((0, import_os3.homedir)(), ".linkque/inspector-requests");
61009
+ var managedRequestDirectory = () => import_path25.default.join((0, import_os3.homedir)(), ".linkque/inspector-requests");
60795
61010
  var assertManagedRequestFile = async (requestFile) => {
60796
- if (!import_path24.default.isAbsolute(requestFile) || !REQUEST_FILE_PATTERN.test(import_path24.default.basename(requestFile)) || import_path24.default.dirname(requestFile) !== managedRequestDirectory()) {
61011
+ if (!import_path25.default.isAbsolute(requestFile) || !REQUEST_FILE_PATTERN.test(import_path25.default.basename(requestFile)) || import_path25.default.dirname(requestFile) !== managedRequestDirectory()) {
60797
61012
  throw new LinkqueCliError(
60798
61013
  "INSPECTOR_PATH_FORBIDDEN",
60799
61014
  "Inspector \u8BF7\u6C42\u6587\u4EF6\u4E0D\u5728\u53D7\u7BA1\u76EE\u5F55\u5185"
60800
61015
  );
60801
61016
  }
60802
61017
  try {
60803
- const fileStat = await (0, import_promises17.lstat)(requestFile);
61018
+ const fileStat = await (0, import_promises20.lstat)(requestFile);
60804
61019
  if (fileStat.isSymbolicLink() || !fileStat.isFile()) {
60805
61020
  throw new LinkqueCliError(
60806
61021
  "INSPECTOR_PATH_FORBIDDEN",
@@ -60814,11 +61029,11 @@ var assertManagedRequestFile = async (requestFile) => {
60814
61029
  );
60815
61030
  }
60816
61031
  const [directoryRealPath, fileRealPath] = await Promise.all([
60817
- (0, import_promises17.realpath)(managedRequestDirectory()),
60818
- (0, import_promises17.realpath)(requestFile)
61032
+ (0, import_promises20.realpath)(managedRequestDirectory()),
61033
+ (0, import_promises20.realpath)(requestFile)
60819
61034
  ]);
60820
- const relative = import_path24.default.relative(directoryRealPath, fileRealPath);
60821
- if (relative === "" || relative.startsWith(`..${import_path24.default.sep}`) || import_path24.default.isAbsolute(relative)) {
61035
+ const relative = import_path25.default.relative(directoryRealPath, fileRealPath);
61036
+ if (relative === "" || relative.startsWith(`..${import_path25.default.sep}`) || import_path25.default.isAbsolute(relative)) {
60822
61037
  throw new LinkqueCliError(
60823
61038
  "INSPECTOR_PATH_FORBIDDEN",
60824
61039
  "Inspector \u8BF7\u6C42\u6587\u4EF6\u89E3\u6790\u540E\u8D8A\u51FA\u53D7\u7BA1\u76EE\u5F55"
@@ -60843,7 +61058,7 @@ var assertManagedRequestFile = async (requestFile) => {
60843
61058
  var readInspectorRequest = async (requestFile) => {
60844
61059
  await assertManagedRequestFile(requestFile);
60845
61060
  try {
60846
- const content = await (0, import_promises17.readFile)(requestFile, "utf8");
61061
+ const content = await (0, import_promises20.readFile)(requestFile, "utf8");
60847
61062
  if (Buffer.byteLength(content, "utf8") > REQUEST_MAX_BYTES) {
60848
61063
  throw new LinkqueCliError(
60849
61064
  "INSPECTOR_REQUEST_INVALID",
@@ -60917,7 +61132,7 @@ var normalizeRevision = (value) => {
60917
61132
  };
60918
61133
  var withInspectorLock = (cwd, operation) => withWorkspaceLock(
60919
61134
  {
60920
- path: import_path24.default.join(cwd, INSPECTOR_LOCK),
61135
+ path: import_path25.default.join(cwd, INSPECTOR_LOCK),
60921
61136
  name: "inspector",
60922
61137
  acquireErrorCode: "INSPECTOR_LOCK_TIMEOUT",
60923
61138
  releaseErrorCode: "INSPECTOR_INTERNAL_ERROR",
@@ -61046,7 +61261,7 @@ var isPortListening2 = (port) => new Promise((resolve2) => {
61046
61261
  });
61047
61262
  async function removeMatchingState2(statePath, pid) {
61048
61263
  const owned = await readOwnedDevState(statePath);
61049
- if (owned?.pid === pid) await (0, import_promises18.rm)(statePath, { force: true });
61264
+ if (owned?.pid === pid) await (0, import_promises21.rm)(statePath, { force: true });
61050
61265
  }
61051
61266
  async function terminateOwner2(statePath, pid) {
61052
61267
  if (!isProcessAlive(pid)) {
@@ -61079,14 +61294,14 @@ async function terminateOwner2(statePath, pid) {
61079
61294
  await removeMatchingState2(statePath, pid);
61080
61295
  }
61081
61296
  var inspectRecordedDevServer = async (cwd) => {
61082
- const statePath = import_path25.default.join(cwd, RUNTIME_DIR3, DEV_STATE);
61297
+ const statePath = import_path26.default.join(cwd, RUNTIME_DIR3, DEV_STATE);
61083
61298
  const content = await readUtf8IfExists(statePath);
61084
61299
  if (content === null) {
61085
61300
  return { state: null, status: stopped2("STOPPED") };
61086
61301
  }
61087
61302
  const owned = parseOwnedDevState(content);
61088
61303
  if (owned === null) {
61089
- await (0, import_promises18.rm)(statePath, { force: true });
61304
+ await (0, import_promises21.rm)(statePath, { force: true });
61090
61305
  return { state: null, status: stopped2("STALE") };
61091
61306
  }
61092
61307
  const state = owned;
@@ -61152,17 +61367,17 @@ var inspectReadyWorkspace = async (cwd) => {
61152
61367
  }
61153
61368
  };
61154
61369
  var spawnDevOwner = (cwd, port, proxyPort, cardPreviewPort, basePath, inspectorEnabled) => {
61155
- const workerPath = import_path25.default.resolve(__dirname, "dev/worker.js");
61370
+ const workerPath = import_path26.default.resolve(__dirname, "dev/worker.js");
61156
61371
  const input = Buffer.from(
61157
61372
  JSON.stringify({
61158
61373
  basePath,
61159
61374
  cardPreviewPort,
61160
61375
  cwd,
61161
61376
  inspectorEnabled,
61162
- logPath: import_path25.default.join(cwd, DEV_LOG),
61377
+ logPath: import_path26.default.join(cwd, DEV_LOG),
61163
61378
  port,
61164
61379
  proxyPort,
61165
- statePath: import_path25.default.join(cwd, RUNTIME_DIR3, DEV_STATE)
61380
+ statePath: import_path26.default.join(cwd, RUNTIME_DIR3, DEV_STATE)
61166
61381
  })
61167
61382
  ).toString("base64url");
61168
61383
  const owner = (0, import_child_process4.spawn)(process.execPath, [workerPath, input], {
@@ -61277,9 +61492,9 @@ var startDevServer = async (cwd, port, proxyPort, cardPreviewPort, basePath, ins
61277
61492
  "dev, proxy and card preview ports must be different"
61278
61493
  );
61279
61494
  }
61280
- const runtimeDir = import_path25.default.join(cwd, RUNTIME_DIR3);
61281
- const lockPath = import_path25.default.join(runtimeDir, DEV_LOCK);
61282
- const statePath = import_path25.default.join(runtimeDir, DEV_STATE);
61495
+ const runtimeDir = import_path26.default.join(cwd, RUNTIME_DIR3);
61496
+ const lockPath = import_path26.default.join(runtimeDir, DEV_LOCK);
61497
+ const statePath = import_path26.default.join(runtimeDir, DEV_STATE);
61283
61498
  return withWorkspaceLock(
61284
61499
  {
61285
61500
  path: lockPath,
@@ -61301,8 +61516,8 @@ var startDevServer = async (cwd, port, proxyPort, cardPreviewPort, basePath, ins
61301
61516
  );
61302
61517
  };
61303
61518
  var stopDevServer = async (cwd) => {
61304
- const lockPath = import_path25.default.join(cwd, RUNTIME_DIR3, DEV_LOCK);
61305
- const statePath = import_path25.default.join(cwd, RUNTIME_DIR3, DEV_STATE);
61519
+ const lockPath = import_path26.default.join(cwd, RUNTIME_DIR3, DEV_LOCK);
61520
+ const statePath = import_path26.default.join(cwd, RUNTIME_DIR3, DEV_STATE);
61306
61521
  return withWorkspaceLock(
61307
61522
  {
61308
61523
  path: lockPath,
@@ -61315,7 +61530,7 @@ var stopDevServer = async (cwd) => {
61315
61530
  async () => {
61316
61531
  const owned = await readOwnedDevState(statePath);
61317
61532
  if (owned !== null) await terminateOwner2(statePath, owned.pid);
61318
- await (0, import_promises18.rm)(statePath, { force: true });
61533
+ await (0, import_promises21.rm)(statePath, { force: true });
61319
61534
  return { stopped: true };
61320
61535
  }
61321
61536
  );
@@ -61323,8 +61538,8 @@ var stopDevServer = async (cwd) => {
61323
61538
 
61324
61539
  // src/commands/platformSdk/apply.ts
61325
61540
  var import_crypto10 = require("crypto");
61326
- var import_promises19 = require("fs/promises");
61327
- var import_path26 = __toESM(require("path"));
61541
+ var import_promises22 = require("fs/promises");
61542
+ var import_path27 = __toESM(require("path"));
61328
61543
  var PLATFORM_SDK_DIR = ".platform-sdk";
61329
61544
  var PLATFORM_SDK_VERSION_FILE = `${PLATFORM_SDK_DIR}/version.json`;
61330
61545
  var PLATFORM_SDK_STATE = ".linkque/runtime/platform-sdk-state.json";
@@ -61336,10 +61551,10 @@ var failManifest = (message) => {
61336
61551
  var isRecord2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
61337
61552
  var isSha256 = (value) => typeof value === "string" && /^sha256:[a-f0-9]{64}$/u.test(value);
61338
61553
  var isSafePlatformPath = (value) => {
61339
- if (value.includes("\\") || value.includes("\0") || import_path26.default.posix.isAbsolute(value)) {
61554
+ if (value.includes("\\") || value.includes("\0") || import_path27.default.posix.isAbsolute(value)) {
61340
61555
  return false;
61341
61556
  }
61342
- const normalized = import_path26.default.posix.normalize(value);
61557
+ const normalized = import_path27.default.posix.normalize(value);
61343
61558
  return normalized === value && normalized.startsWith(`${PLATFORM_SDK_DIR}/`) && !normalized.split("/").includes("..");
61344
61559
  };
61345
61560
  var parseManifest = (content) => {
@@ -61382,14 +61597,14 @@ var extractArchive = async (cwd, archive, manifest) => {
61382
61597
  `platform SDK archive contains an unsafe path: ${entry.filename}`
61383
61598
  );
61384
61599
  }
61385
- const destination = import_path26.default.join(cwd, ...entryPath.split("/"));
61600
+ const destination = import_path27.default.join(cwd, ...entryPath.split("/"));
61386
61601
  if (entry.directory) {
61387
- await (0, import_promises19.mkdir)(destination, { recursive: true });
61602
+ await (0, import_promises22.mkdir)(destination, { recursive: true });
61388
61603
  continue;
61389
61604
  }
61390
61605
  const bytes = await entry.getData(new Uint8ArrayWriter());
61391
- await (0, import_promises19.mkdir)(import_path26.default.dirname(destination), { recursive: true });
61392
- await (0, import_promises19.writeFile)(destination, bytes, { flag: "wx" });
61606
+ await (0, import_promises22.mkdir)(import_path27.default.dirname(destination), { recursive: true });
61607
+ await (0, import_promises22.writeFile)(destination, bytes, { flag: "wx" });
61393
61608
  extractedFiles.set(entryPath, sha256(bytes));
61394
61609
  }
61395
61610
  } finally {
@@ -61408,7 +61623,7 @@ var validateVersionMarker = async (cwd, manifest) => {
61408
61623
  let value;
61409
61624
  try {
61410
61625
  value = JSON.parse(
61411
- await (0, import_promises19.readFile)(import_path26.default.join(cwd, PLATFORM_SDK_VERSION_FILE), "utf8")
61626
+ await (0, import_promises22.readFile)(import_path27.default.join(cwd, PLATFORM_SDK_VERSION_FILE), "utf8")
61412
61627
  );
61413
61628
  } catch (error2) {
61414
61629
  throw new LinkqueCliError(
@@ -61425,10 +61640,10 @@ var validateVersionMarker = async (cwd, manifest) => {
61425
61640
  }
61426
61641
  };
61427
61642
  var rewritePackageJson = async (cwd, manifest) => {
61428
- const packageJsonPath = import_path26.default.join(cwd, "package.json");
61643
+ const packageJsonPath = import_path27.default.join(cwd, "package.json");
61429
61644
  let packageJson;
61430
61645
  try {
61431
- packageJson = JSON.parse(await (0, import_promises19.readFile)(packageJsonPath, "utf8"));
61646
+ packageJson = JSON.parse(await (0, import_promises22.readFile)(packageJsonPath, "utf8"));
61432
61647
  } catch (error2) {
61433
61648
  throw new LinkqueCliError(
61434
61649
  "PLATFORM_SDK_APPLY_FAILED",
@@ -61468,8 +61683,8 @@ var rewritePackageJson = async (cwd, manifest) => {
61468
61683
  };
61469
61684
  var applyWhileLocked = async (cwd, manifestPath, archivePath, options) => {
61470
61685
  const [manifestContent, archive] = await Promise.all([
61471
- (0, import_promises19.readFile)(import_path26.default.resolve(cwd, manifestPath), "utf8"),
61472
- (0, import_promises19.readFile)(import_path26.default.resolve(cwd, archivePath))
61686
+ (0, import_promises22.readFile)(import_path27.default.resolve(cwd, manifestPath), "utf8"),
61687
+ (0, import_promises22.readFile)(import_path27.default.resolve(cwd, archivePath))
61473
61688
  ]).catch((error2) => {
61474
61689
  throw new LinkqueCliError(
61475
61690
  "PLATFORM_SDK_APPLY_FAILED",
@@ -61484,7 +61699,7 @@ var applyWhileLocked = async (cwd, manifestPath, archivePath, options) => {
61484
61699
  "platform SDK archive identity does not match the manifest"
61485
61700
  );
61486
61701
  }
61487
- await (0, import_promises19.rm)(import_path26.default.join(cwd, PLATFORM_SDK_DIR), { force: true, recursive: true });
61702
+ await (0, import_promises22.rm)(import_path27.default.join(cwd, PLATFORM_SDK_DIR), { force: true, recursive: true });
61488
61703
  try {
61489
61704
  await extractArchive(cwd, archive, manifest);
61490
61705
  await validateVersionMarker(cwd, manifest);
@@ -61496,12 +61711,12 @@ var applyWhileLocked = async (cwd, manifestPath, archivePath, options) => {
61496
61711
  let templateVersion;
61497
61712
  try {
61498
61713
  const artifact = JSON.parse(
61499
- await (0, import_promises19.readFile)(import_path26.default.join(cwd, "template-artifact.json"), "utf8")
61714
+ await (0, import_promises22.readFile)(import_path27.default.join(cwd, "template-artifact.json"), "utf8")
61500
61715
  );
61501
61716
  templateVersion = typeof artifact.templateVersion === "string" ? artifact.templateVersion : void 0;
61502
61717
  } catch {
61503
61718
  }
61504
- await writeJsonAtomically(import_path26.default.join(cwd, PLATFORM_SDK_STATE), {
61719
+ await writeJsonAtomically(import_path27.default.join(cwd, PLATFORM_SDK_STATE), {
61505
61720
  schemaVersion: 1,
61506
61721
  bundleVersion: manifest.bundleVersion,
61507
61722
  platformSdkRef: manifest.archive.ossKey,
@@ -61525,7 +61740,7 @@ var applyWhileLocked = async (cwd, manifestPath, archivePath, options) => {
61525
61740
  };
61526
61741
  var applyPlatformSdk = async (cwd, manifestPath, archivePath, options = {}) => withWorkspaceLock(
61527
61742
  {
61528
- path: import_path26.default.join(cwd, PLATFORM_SDK_LOCK),
61743
+ path: import_path27.default.join(cwd, PLATFORM_SDK_LOCK),
61529
61744
  name: "platform SDK",
61530
61745
  acquireErrorCode: "PLATFORM_SDK_LOCK_TIMEOUT",
61531
61746
  releaseErrorCode: "PLATFORM_SDK_LOCK_RELEASE_FAILED",
@@ -61536,8 +61751,8 @@ var applyPlatformSdk = async (cwd, manifestPath, archivePath, options = {}) => w
61536
61751
  );
61537
61752
 
61538
61753
  // src/commands/unzip.ts
61539
- var import_promises20 = require("fs/promises");
61540
- var import_path27 = __toESM(require("path"));
61754
+ var import_promises23 = require("fs/promises");
61755
+ var import_path28 = __toESM(require("path"));
61541
61756
  var MAX_ZIP_BYTES = 70 * 1024 * 1024;
61542
61757
  var MAX_FILE_COUNT = 5e3;
61543
61758
  var MAX_TOTAL_BYTES = 50 * 1024 * 1024;
@@ -61563,12 +61778,12 @@ var SourceArchiveExtractor = class {
61563
61778
  constructor(cwd, input, output) {
61564
61779
  if (!input) this.invalid("unzip input path must not be empty");
61565
61780
  if (!output) this.invalid("unzip output path must not be empty");
61566
- this.inputPath = import_path27.default.resolve(cwd, input);
61567
- this.outputPath = import_path27.default.resolve(cwd, output);
61781
+ this.inputPath = import_path28.default.resolve(cwd, input);
61782
+ this.outputPath = import_path28.default.resolve(cwd, output);
61568
61783
  }
61569
61784
  async extract() {
61570
61785
  await this.assertInputs();
61571
- const handle = await (0, import_promises20.open)(this.inputPath, "r").catch((error2) => {
61786
+ const handle = await (0, import_promises23.open)(this.inputPath, "r").catch((error2) => {
61572
61787
  throw new LinkqueCliError(
61573
61788
  "UNZIP_INPUT_INVALID",
61574
61789
  "unzip input archive could not be opened",
@@ -61604,7 +61819,7 @@ var SourceArchiveExtractor = class {
61604
61819
  }
61605
61820
  let inputStat;
61606
61821
  try {
61607
- inputStat = await (0, import_promises20.stat)(this.inputPath);
61822
+ inputStat = await (0, import_promises23.stat)(this.inputPath);
61608
61823
  } catch (error2) {
61609
61824
  throw new LinkqueCliError(
61610
61825
  "UNZIP_INPUT_INVALID",
@@ -61618,7 +61833,7 @@ var SourceArchiveExtractor = class {
61618
61833
  }
61619
61834
  let outputStat;
61620
61835
  try {
61621
- outputStat = await (0, import_promises20.lstat)(this.outputPath);
61836
+ outputStat = await (0, import_promises23.lstat)(this.outputPath);
61622
61837
  } catch (error2) {
61623
61838
  throw new LinkqueCliError(
61624
61839
  "UNZIP_INPUT_INVALID",
@@ -61629,7 +61844,7 @@ var SourceArchiveExtractor = class {
61629
61844
  if (outputStat.isSymbolicLink() || !outputStat.isDirectory()) {
61630
61845
  this.invalid("unzip output must be an existing directory");
61631
61846
  }
61632
- if ((await (0, import_promises20.readdir)(this.outputPath)).length > 0) {
61847
+ if ((await (0, import_promises23.readdir)(this.outputPath)).length > 0) {
61633
61848
  this.invalid("unzip output directory must be empty");
61634
61849
  }
61635
61850
  }
@@ -61660,16 +61875,16 @@ var SourceArchiveExtractor = class {
61660
61875
  }
61661
61876
  normalizeEntryPath(filename) {
61662
61877
  const normalized = filename.replace(/\/$/u, "");
61663
- if (!normalized || filename.includes("\0") || filename.includes("\\") || import_path27.default.posix.isAbsolute(normalized) || /^[a-zA-Z]:\//u.test(normalized) || normalized.split("/").some((part) => part === "" || part === "." || part === "..")) {
61878
+ if (!normalized || filename.includes("\0") || filename.includes("\\") || import_path28.default.posix.isAbsolute(normalized) || /^[a-zA-Z]:\//u.test(normalized) || normalized.split("/").some((part) => part === "" || part === "." || part === "..")) {
61664
61879
  this.invalid(`unzip archive contains an unsafe path: ${filename}`);
61665
61880
  }
61666
61881
  return normalized;
61667
61882
  }
61668
61883
  async extractFile(file) {
61669
61884
  const destination = this.resolveDestination(file.filename);
61670
- await (0, import_promises20.mkdir)(import_path27.default.dirname(destination), { recursive: true });
61885
+ await (0, import_promises23.mkdir)(import_path28.default.dirname(destination), { recursive: true });
61671
61886
  this.sourceChecksum.appendFileHeader(file.filename, file.size);
61672
- const handle = await (0, import_promises20.open)(destination, "wx");
61887
+ const handle = await (0, import_promises23.open)(destination, "wx");
61673
61888
  let written = 0;
61674
61889
  try {
61675
61890
  await file.entry.getData(
@@ -61701,9 +61916,9 @@ var SourceArchiveExtractor = class {
61701
61916
  }
61702
61917
  }
61703
61918
  resolveDestination(filename) {
61704
- const destination = import_path27.default.resolve(this.outputPath, ...filename.split("/"));
61705
- const relative = import_path27.default.relative(this.outputPath, destination);
61706
- if (relative === "" || relative.startsWith("..") || import_path27.default.isAbsolute(relative)) {
61919
+ const destination = import_path28.default.resolve(this.outputPath, ...filename.split("/"));
61920
+ const relative = import_path28.default.relative(this.outputPath, destination);
61921
+ if (relative === "" || relative.startsWith("..") || import_path28.default.isAbsolute(relative)) {
61707
61922
  this.invalid(`unzip archive escapes output directory: ${filename}`);
61708
61923
  }
61709
61924
  return destination;
@@ -62036,7 +62251,7 @@ function decodeOtlpRecords(line, source) {
62036
62251
  }
62037
62252
 
62038
62253
  // ../linkque-agent-runtime-trace/dist/esm/summarize.js
62039
- var import_node_crypto3 = require("node:crypto");
62254
+ var import_node_crypto4 = require("node:crypto");
62040
62255
  var dedupKey = (advanceId, suffix) => `${advanceId ?? ""}
62041
62256
  ${suffix ?? ""}`;
62042
62257
  var extractQueryInput = (facts) => {
@@ -62210,7 +62425,7 @@ ${body.section}`;
62210
62425
  section: body.section,
62211
62426
  contentRef,
62212
62427
  ...body.reason === "content_limit" ? { reason: "content_limit" } : {},
62213
- valueDigest: (0, import_node_crypto3.createHash)("sha256").update(JSON.stringify(body.value) ?? "").digest("hex"),
62428
+ valueDigest: (0, import_node_crypto4.createHash)("sha256").update(JSON.stringify(body.value) ?? "").digest("hex"),
62214
62429
  ...body.value && typeof body.value === "object" && (body.section.endsWith(".output") || body.section === "knowledge.input") ? {
62215
62430
  result: Object.fromEntries(Object.entries(body.value).filter(([key, value]) => [
62216
62431
  "status",
@@ -62406,7 +62621,7 @@ function readTraceContent(input) {
62406
62621
  const pageBytes = Math.min(maxBytes, remaining);
62407
62622
  const isFullContent = offset === 0 && totalBytes <= maxBytes;
62408
62623
  const titles = body.fieldTitles;
62409
- const fieldTitles = titles && typeof titles === "object" && !Array.isArray(titles) ? Object.fromEntries(Object.entries(titles).filter(([path26, title]) => path26.startsWith("/") && typeof title === "string")) : void 0;
62624
+ const fieldTitles = titles && typeof titles === "object" && !Array.isArray(titles) ? Object.fromEntries(Object.entries(titles).filter(([path28, title]) => path28.startsWith("/") && typeof title === "string")) : void 0;
62410
62625
  const evidence = {
62411
62626
  ...body.originalBytes !== void 0 ? { originalBytes: body.originalBytes } : {},
62412
62627
  ...body.storedBytes !== void 0 ? { storedBytes: body.storedBytes } : {},
@@ -62445,8 +62660,8 @@ function readTraceContent(input) {
62445
62660
 
62446
62661
  // src/utils/otlpScanner.ts
62447
62662
  var import_node_path13 = __toESM(require("node:path"));
62448
- var import_node_crypto4 = require("node:crypto");
62449
- var import_promises21 = require("node:fs/promises");
62663
+ var import_node_crypto5 = require("node:crypto");
62664
+ var import_promises24 = require("node:fs/promises");
62450
62665
 
62451
62666
  // src/commands/runs/types.ts
62452
62667
  var OTLP_LOG_FILES = {
@@ -62502,7 +62717,7 @@ async function scanRetainedLogs(cwd, pinned, options) {
62502
62717
  const dir = import_node_path13.default.join(cwd, LOGS_ROOT);
62503
62718
  let files;
62504
62719
  try {
62505
- files = await (0, import_promises21.readdir)(dir);
62720
+ files = await (0, import_promises24.readdir)(dir);
62506
62721
  } catch (error2) {
62507
62722
  if (isNodeError(error2, "ENOENT"))
62508
62723
  return { facts: [], warnings: ["source_unavailable"], readWindow: [] };
@@ -62525,14 +62740,14 @@ async function scanRetainedLogs(cwd, pinned, options) {
62525
62740
  try {
62526
62741
  const source = retainedFiles.get(file);
62527
62742
  const filePath = import_node_path13.default.join(dir, file);
62528
- const before = await (0, import_promises21.stat)(filePath);
62743
+ const before = await (0, import_promises24.stat)(filePath);
62529
62744
  if (options && scannedBytes + before.size > options.maxBytes)
62530
62745
  throw new RangeError("\u539F\u59CB\u65E5\u5FD7\u8D85\u8FC7\u5F52\u6863\u8BFB\u53D6\u4E0A\u9650");
62531
- const content = await (0, import_promises21.readFile)(filePath);
62746
+ const content = await (0, import_promises24.readFile)(filePath);
62532
62747
  scannedBytes += content.length;
62533
62748
  if (options && scannedBytes > options.maxBytes)
62534
62749
  throw new RangeError("\u539F\u59CB\u65E5\u5FD7\u8D85\u8FC7\u5F52\u6863\u8BFB\u53D6\u4E0A\u9650");
62535
- const after = await (0, import_promises21.stat)(filePath);
62750
+ const after = await (0, import_promises24.stat)(filePath);
62536
62751
  if (before.ino !== after.ino || after.size < before.size) {
62537
62752
  warnings.push("log_rotated_during_read");
62538
62753
  continue;
@@ -62541,7 +62756,7 @@ async function scanRetainedLogs(cwd, pinned, options) {
62541
62756
  let window;
62542
62757
  if (pinned) {
62543
62758
  window = [...remaining].find(
62544
- (entry) => entry.source === source && content.length >= entry.bytes && (0, import_node_crypto4.createHash)("sha256").update(content.subarray(0, entry.bytes)).digest("hex") === entry.digest
62759
+ (entry) => entry.source === source && content.length >= entry.bytes && (0, import_node_crypto5.createHash)("sha256").update(content.subarray(0, entry.bytes)).digest("hex") === entry.digest
62545
62760
  );
62546
62761
  if (!window) continue;
62547
62762
  remaining.delete(window);
@@ -62552,7 +62767,7 @@ async function scanRetainedLogs(cwd, pinned, options) {
62552
62767
  window = {
62553
62768
  source,
62554
62769
  bytes: complete.length,
62555
- digest: (0, import_node_crypto4.createHash)("sha256").update(complete).digest("hex")
62770
+ digest: (0, import_node_crypto5.createHash)("sha256").update(complete).digest("hex")
62556
62771
  };
62557
62772
  }
62558
62773
  readWindow.push(window);
@@ -62758,9 +62973,9 @@ var scanContent = async (input) => {
62758
62973
  var import_node_path14 = __toESM(require("node:path"));
62759
62974
  var import_node_fs9 = require("node:fs");
62760
62975
  var import_node_stream2 = require("node:stream");
62761
- var import_promises22 = require("node:stream/promises");
62976
+ var import_promises25 = require("node:stream/promises");
62762
62977
  var import_node_zlib2 = require("node:zlib");
62763
- var import_promises23 = require("node:fs/promises");
62978
+ var import_promises26 = require("node:fs/promises");
62764
62979
  var TURN_ARCHIVE_MAX_BYTES = 16 * 1024 * 1024;
62765
62980
  var TURN_SOURCE_MAX_BYTES = 64 * 1024 * 1024;
62766
62981
  var TURN_UNCOMPRESSED_ARCHIVE_MAX_BYTES = 64 * 1024 * 1024;
@@ -62787,8 +63002,8 @@ async function exportTurn(cwd, identity) {
62787
63002
  "\u76EE\u6807\u8F6E\u6B21\u65E5\u5FD7\u4E0D\u53EF\u7528"
62788
63003
  );
62789
63004
  const root = import_node_path14.default.join(cwd, ".linkque", "tmp");
62790
- await (0, import_promises23.mkdir)(root, { recursive: true });
62791
- const directory = await (0, import_promises23.mkdtemp)(import_node_path14.default.join(root, "turn-share-"));
63005
+ await (0, import_promises26.mkdir)(root, { recursive: true });
63006
+ const directory = await (0, import_promises26.mkdtemp)(import_node_path14.default.join(root, "turn-share-"));
62792
63007
  const archivePath = import_node_path14.default.join(directory, "logs.tar.gz");
62793
63008
  let result;
62794
63009
  try {
@@ -62809,7 +63024,7 @@ async function exportTurn(cwd, identity) {
62809
63024
  if (payloadBytes > TURN_UNCOMPRESSED_ARCHIVE_MAX_BYTES)
62810
63025
  throw new RangeError("\u672A\u538B\u7F29\u5F52\u6863\u5185\u5BB9\u8D85\u8FC7\u4E0A\u9650");
62811
63026
  for (const [name, value] of Object.entries(files))
62812
- await (0, import_promises23.writeFile)(import_node_path14.default.join(directory, name), value, { flag: "wx" });
63027
+ await (0, import_promises26.writeFile)(import_node_path14.default.join(directory, name), value, { flag: "wx" });
62813
63028
  let uncompressedBytes = 0;
62814
63029
  let compressedBytes = 0;
62815
63030
  const rawBudget = new import_node_stream2.Transform({
@@ -62830,7 +63045,7 @@ async function exportTurn(cwd, identity) {
62830
63045
  );
62831
63046
  }
62832
63047
  });
62833
- await (0, import_promises22.pipeline)(
63048
+ await (0, import_promises25.pipeline)(
62834
63049
  Qn(
62835
63050
  { cwd: directory, portable: true },
62836
63051
  Object.keys(files)
@@ -62842,7 +63057,7 @@ async function exportTurn(cwd, identity) {
62842
63057
  );
62843
63058
  result = { archivePath, compressedBytes, uncompressedBytes };
62844
63059
  } catch (cause) {
62845
- await (0, import_promises23.rm)(directory, { recursive: true, force: true }).catch(
63060
+ await (0, import_promises26.rm)(directory, { recursive: true, force: true }).catch(
62846
63061
  () => void 0
62847
63062
  );
62848
63063
  throw new LinkqueCliError(
@@ -62852,7 +63067,7 @@ async function exportTurn(cwd, identity) {
62852
63067
  );
62853
63068
  }
62854
63069
  for (const name of ["manifest.json", "logs.jsonl", "traces.jsonl"]) {
62855
- await (0, import_promises23.rm)(import_node_path14.default.join(directory, name), { force: true }).catch(
63070
+ await (0, import_promises26.rm)(import_node_path14.default.join(directory, name), { force: true }).catch(
62856
63071
  () => void 0
62857
63072
  );
62858
63073
  }
@@ -63243,6 +63458,16 @@ var cardList = {
63243
63458
  `,
63244
63459
  run: (cwd) => listCardDrafts(cwd)
63245
63460
  };
63461
+ var cardMigrate = {
63462
+ name: "card.migrate",
63463
+ description: "\u5C06 V4 \u5361\u7247\u8FC1\u79FB\u4E3A\u72EC\u7ACB\u7ED3\u6784\u548C\u7ED1\u5B9A\u6587\u4EF6",
63464
+ options: [],
63465
+ summarize: () => "V4 card storage migrated.\n",
63466
+ run: async (cwd) => {
63467
+ const source = await migrateAgentCards(import_path29.default.join(cwd, "agent_config.json"));
63468
+ return { cardCount: Object.keys(source.files).length / 2 };
63469
+ }
63470
+ };
63246
63471
  var cardRead = {
63247
63472
  name: "card.read",
63248
63473
  description: "read one validated A2UI card draft bundle",
@@ -63726,6 +63951,7 @@ var COMMANDS = [
63726
63951
  inspectorApply,
63727
63952
  mcpDescribe,
63728
63953
  cardList,
63954
+ cardMigrate,
63729
63955
  cardRead,
63730
63956
  cardPrepareBindingContext,
63731
63957
  cardValidateBindings,