linkque-cli-v2 1.2.5 → 1.2.6

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.
@@ -3211,6 +3211,7 @@ var require_utils = __commonJS({
3211
3211
  "use strict";
3212
3212
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
3213
3213
  var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
3214
+ var isPort = RegExp.prototype.test.bind(/^\d*$/u);
3214
3215
  var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
3215
3216
  var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
3216
3217
  var isPathCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u);
@@ -3676,8 +3677,12 @@ var require_utils = __commonJS({
3676
3677
  uriTokens.push(host);
3677
3678
  }
3678
3679
  if (typeof component.port === "number" || typeof component.port === "string") {
3680
+ const port = String(component.port);
3681
+ if (!isPort(port)) {
3682
+ throw new TypeError("URI port is malformed.");
3683
+ }
3679
3684
  uriTokens.push(":");
3680
- uriTokens.push(String(component.port));
3685
+ uriTokens.push(port);
3681
3686
  }
3682
3687
  return uriTokens.length ? uriTokens.join("") : void 0;
3683
3688
  }
@@ -4120,12 +4125,15 @@ var require_fast_uri = __commonJS({
4120
4125
  }
4121
4126
  return false;
4122
4127
  }
4128
+ function isIPLiteral(host) {
4129
+ return host[0] === "[" && host[host.length - 1] === "]";
4130
+ }
4123
4131
  function hasMalformedComponentPercentEncoding(matches) {
4124
4132
  const host = matches[4];
4125
- return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !(host[0] === "[" && host[host.length - 1] === "]") && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
4133
+ return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !isIPLiteral(host) && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
4126
4134
  }
4127
4135
  function canonicalizeHost(parsed, options, schemeHandler, isIP) {
4128
- if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && parsed.host[0] !== "[" && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
4136
+ if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
4129
4137
  try {
4130
4138
  parsed.host = new URL("http://" + parsed.host).hostname;
4131
4139
  } catch (e) {
@@ -4212,10 +4220,11 @@ var require_fast_uri = __commonJS({
4212
4220
  if (parsed.host) {
4213
4221
  const ipv4result = isIPv4(parsed.host);
4214
4222
  if (ipv4result === false) {
4215
- const bracketedIPLiteral = parsed.host[0] === "[" && parsed.host[parsed.host.length - 1] === "]";
4223
+ const bracketedIPLiteral = isIPLiteral(parsed.host);
4224
+ const hasIPLiteralBracket = parsed.host.indexOf("[") !== -1 || parsed.host.indexOf("]") !== -1;
4216
4225
  const ipv6result = normalizeIPv6(parsed.host);
4217
4226
  isIP = ipv6result.isIPV6 || ipv6result.isIPVFuture === true;
4218
- malformedIPLiteral = bracketedIPLiteral && ipv6result.error === true;
4227
+ malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true);
4219
4228
  parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
4220
4229
  if (malformedIPLiteral) {
4221
4230
  parsed.error = parsed.error || "URI host is malformed.";
@@ -4238,7 +4247,9 @@ var require_fast_uri = __commonJS({
4238
4247
  parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
4239
4248
  }
4240
4249
  const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
4241
- malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
4250
+ if (!malformedIPLiteral) {
4251
+ malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
4252
+ }
4242
4253
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
4243
4254
  if (uri.indexOf("%") !== -1) {
4244
4255
  if (parsed.host !== void 0 && !malformedIPLiteral) {
@@ -9950,6 +9961,7 @@ var colors = [
9950
9961
  "default",
9951
9962
  "muted",
9952
9963
  "primary",
9964
+ "accent",
9953
9965
  "success",
9954
9966
  "warning",
9955
9967
  "error",
@@ -10001,18 +10013,8 @@ var iconNames = [
10001
10013
  "warning",
10002
10014
  "arrow-right-long"
10003
10015
  ];
10004
- var layoutItem = {
10005
- grow: {
10006
- kind: "number",
10007
- values: [0, 1, 2, 3, 4],
10008
- parentComponents: ["Row", "Column"]
10009
- }
10010
- };
10011
- var width = { width: { kind: "string", values: ["fit", "fill"] } };
10012
- var radius = {
10013
- radius: { kind: "string", values: ["none", "xs", "sm", "md", "full"] }
10014
- };
10015
- var decoration = {
10016
+ var box = {
10017
+ margin: { kind: "string", values: spacing },
10016
10018
  padding: { kind: "string", values: spacing },
10017
10019
  background: {
10018
10020
  kind: "string",
@@ -10030,17 +10032,29 @@ var decoration = {
10030
10032
  kind: "string",
10031
10033
  values: ["none", "subtle", "card-border", "primary"]
10032
10034
  },
10033
- ...radius
10035
+ radius: { kind: "string", values: ["none", "xs", "sm", "md", "full"] },
10036
+ width: { kind: "string", values: ["fit", "fill"] },
10037
+ grow: { kind: "number", values: [0, 1, 2, 3, 4] },
10038
+ shrink: { kind: "boolean" }
10034
10039
  };
10035
10040
  var typography = {
10036
10041
  color: { kind: "string", values: colors },
10037
- fontSize: { kind: "string", values: ["xs", "sm", "md", "lg", "xl", "xxl"] },
10042
+ fontSize: {
10043
+ kind: "string",
10044
+ values: [
10045
+ "small",
10046
+ "medium",
10047
+ "large",
10048
+ "striking",
10049
+ "display",
10050
+ "badge",
10051
+ "merchant"
10052
+ ]
10053
+ },
10038
10054
  fontWeight: { kind: "string", values: ["normal", "semibold", "bold"] }
10039
10055
  };
10040
10056
  var container = {
10041
- ...layoutItem,
10042
- ...width,
10043
- padding: { kind: "string", values: spacing },
10057
+ ...box,
10044
10058
  children: { kind: "children", required: true },
10045
10059
  gap: { kind: "string", values: spacing },
10046
10060
  align: {
@@ -10060,7 +10074,6 @@ var container = {
10060
10074
  },
10061
10075
  "x2-overflow": { kind: "format" }
10062
10076
  };
10063
- var { justify: _listJustify, ...listContainer } = container;
10064
10077
  var A2UI_V4_COMPONENT_CATALOG = Object.freeze({
10065
10078
  catalogId: LINKQUE_A2UI_V4_CATALOG_ID,
10066
10079
  protocolVersion: "0.9",
@@ -10068,10 +10081,7 @@ var A2UI_V4_COMPONENT_CATALOG = Object.freeze({
10068
10081
  Card: {
10069
10082
  interaction: "action",
10070
10083
  properties: {
10071
- ...layoutItem,
10072
- ...width,
10073
- ...decoration,
10074
- child: { kind: "child", required: true },
10084
+ ...container,
10075
10085
  action: { kind: "action" },
10076
10086
  disabled: { kind: "boolean" }
10077
10087
  }
@@ -10087,7 +10097,7 @@ var A2UI_V4_COMPONENT_CATALOG = Object.freeze({
10087
10097
  List: {
10088
10098
  interaction: "none",
10089
10099
  properties: {
10090
- ...listContainer,
10100
+ ...container,
10091
10101
  variant: {
10092
10102
  kind: "string",
10093
10103
  required: true,
@@ -10098,9 +10108,8 @@ var A2UI_V4_COMPONENT_CATALOG = Object.freeze({
10098
10108
  Text: {
10099
10109
  interaction: "none",
10100
10110
  properties: {
10101
- ...layoutItem,
10111
+ ...box,
10102
10112
  ...typography,
10103
- shrink: { kind: "boolean" },
10104
10113
  text: { kind: "binding", required: true },
10105
10114
  maxLines: { kind: "number", values: [0, 1, 2, 3, 4, 5, 6] },
10106
10115
  decoration: { kind: "string", values: ["line-through"] },
@@ -10110,31 +10119,19 @@ var A2UI_V4_COMPONENT_CATALOG = Object.freeze({
10110
10119
  Tag: {
10111
10120
  interaction: "none",
10112
10121
  properties: {
10113
- ...layoutItem,
10122
+ ...box,
10123
+ ...typography,
10114
10124
  text: { kind: "binding", required: true },
10115
10125
  icon: { kind: "string", values: iconNames },
10116
- tone: {
10117
- kind: "string",
10118
- values: [
10119
- "default",
10120
- "muted",
10121
- "primary",
10122
- "success",
10123
- "warning",
10124
- "error"
10125
- ]
10126
- },
10127
- variant: { kind: "string", values: ["soft", "outline", "plain"] },
10128
- size: { kind: "string", values: ["sm", "md"] },
10129
- shrink: { kind: "boolean" },
10130
- maxLines: { kind: "number", values: [0, 1, 2, 3, 4, 5, 6] }
10126
+ gap: { kind: "string", values: spacing },
10127
+ maxLines: { kind: "number", values: [0, 1, 2, 3, 4, 5, 6] },
10128
+ format: { kind: "format" }
10131
10129
  }
10132
10130
  },
10133
10131
  Button: {
10134
10132
  interaction: "action",
10135
10133
  properties: {
10136
- ...layoutItem,
10137
- ...width,
10134
+ ...box,
10138
10135
  label: { kind: "binding", required: true },
10139
10136
  action: { kind: "action", required: true },
10140
10137
  checks: { kind: "format" },
@@ -10152,29 +10149,34 @@ var A2UI_V4_COMPONENT_CATALOG = Object.freeze({
10152
10149
  Image: {
10153
10150
  interaction: "none",
10154
10151
  properties: {
10155
- ...layoutItem,
10156
- ...radius,
10152
+ ...box,
10157
10153
  src: { kind: "binding", required: true },
10158
10154
  alt: { kind: "binding" },
10159
10155
  fit: {
10160
10156
  kind: "string",
10161
10157
  values: ["contain", "cover", "fill", "none", "scale-down"]
10162
10158
  },
10163
- aspectRatio: {
10164
- kind: "string",
10165
- values: ["square", "portrait", "landscape", "wide", "banner"]
10166
- },
10167
- height: { kind: "string", values: ["auto", "fill"] },
10168
- size: {
10159
+ variant: {
10169
10160
  kind: "string",
10170
- values: ["xs", "sm", "md", "lg", "xl", "full"]
10161
+ values: [
10162
+ "icon",
10163
+ "avatar",
10164
+ "merchantLogo",
10165
+ "smallFeature",
10166
+ "mediumFeature",
10167
+ "portraitFeature",
10168
+ "productThumbnail",
10169
+ "voucherThumbnail",
10170
+ "largeFeature",
10171
+ "header"
10172
+ ]
10171
10173
  }
10172
10174
  }
10173
10175
  },
10174
10176
  Icon: {
10175
10177
  interaction: "none",
10176
10178
  properties: {
10177
- ...layoutItem,
10179
+ ...box,
10178
10180
  name: { kind: "string", required: true, values: iconNames },
10179
10181
  label: { kind: "string" },
10180
10182
  color: { kind: "string", values: colors },
@@ -10187,15 +10189,15 @@ var A2UI_V4_COMPONENT_CATALOG = Object.freeze({
10187
10189
  Divider: {
10188
10190
  interaction: "none",
10189
10191
  properties: {
10190
- ...layoutItem,
10192
+ ...box,
10191
10193
  axis: { kind: "string", values: ["horizontal", "vertical"] }
10192
10194
  }
10193
10195
  },
10194
10196
  TextField: {
10195
10197
  interaction: "input",
10196
10198
  properties: {
10197
- ...layoutItem,
10198
- ...width,
10199
+ ...box,
10200
+ ...typography,
10199
10201
  label: { kind: "string", required: true },
10200
10202
  value: { kind: "binding", required: true },
10201
10203
  checks: { kind: "format" },
@@ -10219,8 +10221,7 @@ var A2UI_V4_COMPONENT_CATALOG = Object.freeze({
10219
10221
  ChoicePicker: {
10220
10222
  interaction: "input",
10221
10223
  properties: {
10222
- ...layoutItem,
10223
- ...width,
10224
+ ...box,
10224
10225
  label: { kind: "string", required: true },
10225
10226
  value: { kind: "binding", required: true },
10226
10227
  options: { kind: "options", required: true },
@@ -10235,8 +10236,7 @@ var A2UI_V4_COMPONENT_CATALOG = Object.freeze({
10235
10236
  Stepper: {
10236
10237
  interaction: "input",
10237
10238
  properties: {
10238
- ...layoutItem,
10239
- ...width,
10239
+ ...box,
10240
10240
  label: { kind: "string", required: true },
10241
10241
  value: { kind: "binding", required: true },
10242
10242
  min: { kind: "number" },
@@ -10352,6 +10352,8 @@ function validateComponents(payload, path2, surfaces, issues) {
10352
10352
  if (value !== void 0)
10353
10353
  validateProperty(value, property, `${componentPath}.${name}`, issues, name);
10354
10354
  }
10355
+ if (component.component === "Tag" && component.icon === void 0 && component.gap !== void 0)
10356
+ issues.push(issue2(`${componentPath}.gap`, "TAG_GAP_REQUIRES_ICON", "Tag.gap requires Tag.icon"));
10355
10357
  if (component["x2-overflow"] !== void 0)
10356
10358
  validateOverflow(component, componentPath, issues);
10357
10359
  if (component.component === "TextField")
@@ -10365,7 +10367,7 @@ function validateComponents(payload, path2, surfaces, issues) {
10365
10367
  validateStepper(component, componentPath, issues);
10366
10368
  if (component.checks !== void 0)
10367
10369
  validateChecks(component.checks, `${componentPath}.checks`, issues);
10368
- if (component.format !== void 0 && component.component === "Text")
10370
+ if (component.format !== void 0 && (component.component === "Text" || component.component === "Tag"))
10369
10371
  validateNumberFormat(component.format, `${componentPath}.format`, issues);
10370
10372
  if (component.action !== void 0)
10371
10373
  validateAction(component.action, `${componentPath}.action`, issues, 0);
@@ -10379,11 +10381,6 @@ function validateProperty(value, schema, path2, issues, propertyName) {
10379
10381
  issues.push(issue2(path2, "INVALID_DISPLAY_VALUE", `display value must be ${stringOnly ? "a string" : "a string or finite number"}, or a compatible display binding`));
10380
10382
  return;
10381
10383
  }
10382
- if (schema.kind === "child") {
10383
- if (!isSafeIdentifier(value))
10384
- issues.push(issue2(path2, "INVALID_CHILD", "child must be a safe component id"));
10385
- return;
10386
- }
10387
10384
  if (schema.kind === "children") {
10388
10385
  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);
10389
10386
  if (!valid)
@@ -10624,27 +10621,20 @@ function validateReferences(surfaces, path2, issues) {
10624
10621
  issues.push(issue2(`${path2}.surfaces.${surfaceId}`, "MISSING_ROOT_COMPONENT", "surface must define root"));
10625
10622
  const edges = /* @__PURE__ */ new Map();
10626
10623
  for (const [id, component] of components) {
10627
- const refs = getComponentReferences(component);
10624
+ const children = component.children;
10625
+ const refs = Array.isArray(children) ? children.filter((entry) => typeof entry === "string") : isPlainRecord(children) && typeof children.componentId === "string" ? [children.componentId] : [];
10628
10626
  edges.set(id, refs);
10629
10627
  refs.forEach((ref) => {
10630
10628
  if (!components.has(ref))
10631
- issues.push(issue2(`${path2}.surfaces.${surfaceId}.components.${id}.${component.child !== void 0 ? "child" : "children"}`, "MISSING_COMPONENT_REFERENCE", `component ${ref} does not exist`));
10629
+ issues.push(issue2(`${path2}.surfaces.${surfaceId}.components.${id}.children`, "MISSING_COMPONENT_REFERENCE", `component ${ref} does not exist`));
10632
10630
  });
10633
10631
  if ((component.component === "Button" || component.component === "Card" && component.action !== void 0) && refs.some((ref) => hasInteractiveDescendant(ref, components, /* @__PURE__ */ new Set())))
10634
- issues.push(issue2(`${path2}.surfaces.${surfaceId}.components.${id}.${component.child !== void 0 ? "child" : "children"}`, "NESTED_INTERACTION", "action components cannot contain interactive descendants"));
10632
+ issues.push(issue2(`${path2}.surfaces.${surfaceId}.components.${id}.children`, "NESTED_INTERACTION", "action components cannot contain interactive descendants"));
10635
10633
  collectSurfaceOpenReferences(component.action).forEach((targetSurfaceId) => {
10636
10634
  if (!surfaces.has(targetSurfaceId))
10637
10635
  issues.push(issue2(`${path2}.surfaces.${surfaceId}.components.${id}.action`, "MISSING_SURFACE_REFERENCE", `surface ${targetSurfaceId} does not exist`));
10638
10636
  });
10639
10637
  }
10640
- components.forEach((component, id) => {
10641
- if (component.grow === void 0)
10642
- return;
10643
- const parents = [...components.values()].filter((parent) => getComponentReferences(parent).includes(id));
10644
- if (id === "root" || parents.length === 0 || parents.some((parent) => parent.component !== "Row" && parent.component !== "Column")) {
10645
- issues.push(issue2(`${path2}.surfaces.${surfaceId}.components.${id}.grow`, "INVALID_LAYOUT_PARENT", "grow requires a direct Row or Column parent in every occurrence"));
10646
- }
10647
- });
10648
10638
  const visiting = /* @__PURE__ */ new Set();
10649
10639
  const visited = /* @__PURE__ */ new Set();
10650
10640
  const walk = (id) => {
@@ -10675,14 +10665,6 @@ function collectSurfaceOpenReferences(value, result = /* @__PURE__ */ new Set())
10675
10665
  }
10676
10666
  return result;
10677
10667
  }
10678
- function getComponentReferences(component) {
10679
- if (typeof component.child === "string")
10680
- return [component.child];
10681
- const children = component.children;
10682
- if (Array.isArray(children))
10683
- return children.filter((entry) => typeof entry === "string");
10684
- return isPlainRecord(children) && typeof children.componentId === "string" ? [children.componentId] : [];
10685
- }
10686
10668
  function hasInteractiveDescendant(id, components, visited) {
10687
10669
  if (visited.has(id))
10688
10670
  return false;
@@ -10692,7 +10674,8 @@ function hasInteractiveDescendant(id, components, visited) {
10692
10674
  return false;
10693
10675
  if (component.component === "Button" || component.action !== void 0 || ["TextField", "ChoicePicker", "Stepper"].includes(String(component.component)))
10694
10676
  return true;
10695
- const refs = getComponentReferences(component);
10677
+ const children = component.children;
10678
+ const refs = Array.isArray(children) ? children : isPlainRecord(children) ? [children.componentId] : [];
10696
10679
  return refs.some((ref) => typeof ref === "string" && hasInteractiveDescendant(ref, components, visited));
10697
10680
  }
10698
10681
 
@@ -11686,7 +11669,6 @@ function aggregateMcpServers(resources, protocolAgentId) {
11686
11669
  // ../linkque-agent-runtime/dist/esm/core/types.js
11687
11670
  var EDebugLogScope;
11688
11671
  (function(EDebugLogScope2) {
11689
- EDebugLogScope2["A2UI_ACTION"] = "A2UI_ACTION";
11690
11672
  EDebugLogScope2["CONFIG"] = "CONFIG";
11691
11673
  EDebugLogScope2["LLM"] = "LLM";
11692
11674
  EDebugLogScope2["PI_EVENT"] = "PI_EVENT";
@@ -11754,11 +11736,7 @@ var McpProxyTool = class {
11754
11736
  return;
11755
11737
  try {
11756
11738
  await entry.server.close?.();
11757
- } catch (error) {
11758
- try {
11759
- this.debugLog(`[mcp] server ${entry.server.serverName} close failed: ${error instanceof Error ? error.message : "unknown error"}`, EDebugLogScope.MCP);
11760
- } catch {
11761
- }
11739
+ } catch {
11762
11740
  }
11763
11741
  }));
11764
11742
  }
@@ -12136,89 +12114,14 @@ var MCP_PROXY_INPUT_SCHEMA = {
12136
12114
  }
12137
12115
  };
12138
12116
 
12139
- // ../linkque-agent-runtime/dist/esm/core/cardActionDiagnostics.js
12140
- var CardActionDiagnostics = class {
12141
- sink;
12142
- layer;
12143
- stage = "validate";
12144
- context;
12145
- debugLog;
12146
- startedAt = performance.now();
12147
- constructor(sink, context, layer = "runtime") {
12148
- this.sink = sink;
12149
- this.layer = layer;
12150
- this.context = { ...context };
12151
- if (sink) {
12152
- this.debugLog = (line, scope) => {
12153
- this.write("diagnostic", { message: line }, scope);
12154
- };
12155
- }
12156
- }
12157
- write(event, fields = {}, scope = EDebugLogScope.A2UI_ACTION) {
12158
- if (!this.sink)
12159
- return;
12160
- try {
12161
- const record2 = { ...this.context, ...fields };
12162
- if (record2.message)
12163
- record2.message = sanitizeDiagnosticText(record2.message);
12164
- if (record2.errorName)
12165
- record2.errorName = sanitizeDiagnosticText(record2.errorName);
12166
- this.sink(JSON.stringify({
12167
- operation: "a2uiAction.execute",
12168
- layer: this.layer,
12169
- event,
12170
- stage: this.stage,
12171
- ...record2,
12172
- costMs: Math.max(0, Math.round(performance.now() - this.startedAt))
12173
- }), scope);
12174
- } catch {
12175
- }
12176
- }
12177
- error(event, error) {
12178
- if (!this.sink)
12179
- return;
12180
- try {
12181
- this.write(event, {
12182
- errorName: error instanceof Error ? error.name : typeof error,
12183
- message: error instanceof Error ? error.message : typeof error === "string" ? error : "\u975E\u6807\u51C6\u5F02\u5E38"
12184
- });
12185
- } catch {
12186
- }
12187
- }
12188
- };
12189
- function sanitizeDiagnosticText(value) {
12190
- return value.replace(/\b(?:body|arguments|payload|headers)\s*[:=][\s\S]*/giu, "<payload>").replace(/\{[\s\S]*/gu, "<payload>").replace(/https?:\/\/[^\s]+/giu, "<url>").replace(/\b(?:authorization|cookie|set-cookie)\s*[:=][^\r\n]*/giu, "<redacted>").replace(/\bbearer\s+[^\s,;]+/giu, "Bearer <redacted>").replace(/\b((?:api[_-]?key|access[_-]?key|token|secret|password|ak|sk|tradeNO|userId|orderId)\s*[:=]\s*)(?:"[^"]*"|'[^']*'|[^\s,;]+)/giu, "$1<redacted>").replace(/\s+/gu, " ").slice(0, 300);
12191
- }
12192
-
12193
12117
  // ../linkque-agent-runtime/dist/esm/core/cardActionExecutor.js
12194
12118
  async function executeCardAction(input) {
12195
- const diagnostics = new CardActionDiagnostics(input.debugLog, {
12196
- agentId: input.protocol.agentId,
12197
- threadId: input.runtimeContext.threadId
12198
- });
12199
- diagnostics.write("started");
12200
- try {
12201
- const response = await executeCardActionInternal(input, diagnostics);
12202
- diagnostics.write(response.ok ? "completed" : "failed", response.ok ? {} : { code: response.error.code, retryable: response.error.retryable });
12203
- return response;
12204
- } catch (error) {
12205
- diagnostics.error("failed", error);
12206
- throw error;
12207
- }
12208
- }
12209
- async function executeCardActionInternal(input, diagnostics) {
12210
12119
  let request;
12211
12120
  try {
12212
12121
  request = parseA2UIActionExecuteRequest(input.request);
12213
12122
  } catch (error) {
12214
12123
  return failure("INVALID_INPUT", errorMessage(error, "\u652F\u4ED8\u52A8\u4F5C\u8BF7\u6C42\u65E0\u6548"), false);
12215
12124
  }
12216
- Object.assign(diagnostics.context, {
12217
- invocationId: request.invocationId,
12218
- actionId: request.actionId,
12219
- cardRef: request.source.cardRef,
12220
- cardRevision: request.source.cardRevision
12221
- });
12222
12125
  if (request.agentId !== input.protocol.agentId) {
12223
12126
  return failure("AGENT_MISMATCH", "\u652F\u4ED8\u52A8\u4F5C\u4E0E\u5F53\u524D Agent \u4E0D\u5339\u914D", false);
12224
12127
  }
@@ -12228,38 +12131,24 @@ async function executeCardActionInternal(input, diagnostics) {
12228
12131
  if (!input.runtimeContext.userId.trim()) {
12229
12132
  return failure("AUTH_REQUIRED", "\u652F\u4ED8\u52A8\u4F5C\u7F3A\u5C11\u53EF\u4FE1\u7528\u6237\u8EAB\u4EFD", false);
12230
12133
  }
12231
- diagnostics.write("validated");
12232
- diagnostics.stage = "binding";
12233
12134
  const resolved = resolvePaymentBinding(input.protocol, request.source, request.actionId);
12234
12135
  if (!resolved.ok)
12235
12136
  return resolved.response;
12236
- Object.assign(diagnostics.context, {
12237
- mcpResourceId: resolved.binding.createTrade.mcpResourceId,
12238
- toolName: resolved.binding.createTrade.toolName
12239
- });
12240
- diagnostics.write("binding_resolved");
12241
- diagnostics.stage = "tool_resolve";
12242
- const registry = createRegistry(input.protocol, input.mcpServerProvider, diagnostics.debugLog);
12137
+ const registry = createRegistry(input.protocol, input.mcpServerProvider);
12243
12138
  try {
12244
12139
  const tool = await registry.resolve(resolved.binding.createTrade.mcpResourceId, resolved.binding.createTrade.toolName, input.signal);
12245
12140
  if (!tool) {
12246
12141
  return failure("TOOL_NOT_ALLOWED", "\u521B\u5EFA\u4EA4\u6613 MCP Tool \u4E0D\u5B58\u5728\u6216\u672A\u6388\u6743", false);
12247
12142
  }
12248
- diagnostics.stage = "tool_input";
12249
12143
  const args = createToolInput(resolved.binding.createTrade.inputBindings, request.actionContext, input.runtimeContext);
12250
12144
  if (!args)
12251
12145
  return failure("INVALID_INPUT", "\u65E0\u6CD5\u751F\u6210\u521B\u5EFA\u4EA4\u6613 MCP \u5165\u53C2", false);
12252
12146
  let result;
12253
- diagnostics.stage = "tool_execute";
12254
- diagnostics.write("tool_started");
12255
12147
  try {
12256
12148
  result = await tool.execute(args, input.signal);
12257
- diagnostics.write("tool_completed");
12258
- } catch (error) {
12259
- diagnostics.error("tool_failed", error);
12149
+ } catch {
12260
12150
  return failure("EXECUTION_FAILED", "\u521B\u5EFA\u4EA4\u6613\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5", true);
12261
12151
  }
12262
- diagnostics.stage = "tool_output";
12263
12152
  const structured = readStructuredContent(result);
12264
12153
  const tradeNO = readJsonPointer(structured, resolved.binding.createTrade.tradeNoPath);
12265
12154
  if (typeof tradeNO !== "string" || !tradeNO.trim() || tradeNO.length > 64) {
@@ -12271,10 +12160,7 @@ async function executeCardActionInternal(input, diagnostics) {
12271
12160
  result: { kind: "payment", tradeNO }
12272
12161
  };
12273
12162
  } finally {
12274
- const stage = diagnostics.stage;
12275
- diagnostics.stage = "cleanup";
12276
12163
  await registry.closeAll();
12277
- diagnostics.stage = stage;
12278
12164
  }
12279
12165
  }
12280
12166
  async function verifyPaymentResult(input) {
@@ -12337,9 +12223,9 @@ function resolvePaymentBinding(protocol, source, actionId) {
12337
12223
  }
12338
12224
  return { ok: true, binding };
12339
12225
  }
12340
- function createRegistry(protocol, provider, debugLog) {
12226
+ function createRegistry(protocol, provider) {
12341
12227
  const resources = protocol.agent.resources.filter((resource) => resource.resourceType === EResourceType.MCP || resource.resourceType === EResourceType.MCP_TOOL);
12342
- return new McpProxyTool(provider, aggregateMcpServers(resources, protocol.agentId), { debugLog });
12228
+ return new McpProxyTool(provider, aggregateMcpServers(resources, protocol.agentId));
12343
12229
  }
12344
12230
  function createToolInput(bindings, actionContext, runtimeContext, tradeNO, callback) {
12345
12231
  const result = {};
@@ -14908,6 +14794,9 @@ function getConversationRunRequestIssues(value) {
14908
14794
  issues.push("attachments must be an array");
14909
14795
  } else {
14910
14796
  value.attachments.forEach((attachment, index) => validateAttachment(attachment, index, issues));
14797
+ if (value.attachments.length > 0 && (!Array.isArray(value.messages) || !value.messages.some((message) => isRecord4(message) && message.role === "user"))) {
14798
+ issues.push("non-empty attachments require at least one user message");
14799
+ }
14911
14800
  }
14912
14801
  if (!isRecord4(value.metadata))
14913
14802
  issues.push("metadata must be an object");
@@ -15048,6 +14937,9 @@ function validateAttachment(value, index, issues) {
15048
14937
  if (value.size !== void 0 && (!Number.isSafeInteger(value.size) || Number(value.size) < 0)) {
15049
14938
  issues.push(`attachments[${index}].size must be a non-negative safe integer when provided`);
15050
14939
  }
14940
+ if (value.availability !== void 0 && value.availability !== "resolvable" && value.availability !== "current_turn_only") {
14941
+ issues.push(`attachments[${index}].availability must be resolvable or current_turn_only when provided`);
14942
+ }
15051
14943
  if (value.metadata !== void 0 && !isRecord4(value.metadata)) {
15052
14944
  issues.push(`attachments[${index}].metadata must be an object when provided`);
15053
14945
  }
@@ -21564,7 +21456,6 @@ export {
21564
21456
  aggregateMcpServers,
21565
21457
  McpProxyTool,
21566
21458
  executeHomeData,
21567
- CardActionDiagnostics,
21568
21459
  executeCardAction,
21569
21460
  verifyPaymentResult,
21570
21461
  FOLLOW_UP_CONTEXT_MAX_HISTORY_RUNS,
@@ -18,7 +18,7 @@ import {
18
18
  import {
19
19
  RUNTIME_CONFIG_DEFAULTS,
20
20
  RuntimeConfigProvider
21
- } from "./chunk-YYBDYBTX.js";
21
+ } from "./chunk-DCQYAWC6.js";
22
22
  import {
23
23
  __commonJS,
24
24
  __require,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  EModelProvider
3
- } from "./chunk-YYBDYBTX.js";
3
+ } from "./chunk-DCQYAWC6.js";
4
4
 
5
5
  // ../linkque-agent-appwrite-integrate/dist/esm/runtime/protocol.js
6
6
  var baked;