linkque-cli-v2 1.6.25 → 1.6.27

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
@@ -34494,11 +34494,14 @@ function assertCardPath(value) {
34494
34494
  throw new Error("\u65E0\u6548\u7684\u5361\u7247\u6587\u4EF6\u5F15\u7528");
34495
34495
  }
34496
34496
  }
34497
+ function isWorkspaceFileCard({ resourceType, config: config3 }) {
34498
+ return resourceType === "CARD" && ("bindingRef" in config3 || !("definitionRef" in config3) && (config3.schemaVersion === "4" || config3.format === "alipay-a2ui"));
34499
+ }
34497
34500
  function splitAgentCards(input) {
34498
34501
  const config3 = structuredClone(input);
34499
34502
  const files = {};
34500
34503
  for (const resource of config3.agent.resources ?? []) {
34501
- if (resource.resourceType !== "CARD")
34504
+ if (!isWorkspaceFileCard(resource))
34502
34505
  continue;
34503
34506
  const { config: inline } = resource;
34504
34507
  const directory = `cards/${encodeURIComponent(resource.resourceId)}/${contentChecksum(inline)}`;
@@ -34532,7 +34535,7 @@ function splitAgentCards(input) {
34532
34535
  async function hydrateAgentCards(input, readJson) {
34533
34536
  const config3 = structuredClone(input);
34534
34537
  for (const resource of config3.agent.resources ?? []) {
34535
- if (resource.resourceType !== "CARD")
34538
+ if (!isWorkspaceFileCard(resource))
34536
34539
  continue;
34537
34540
  if (!("bindingRef" in resource.config)) {
34538
34541
  if (resource.config.format === "alipay-a2ui")
@@ -38339,7 +38342,7 @@ function validateSchemaNode(value, path28, issues, options) {
38339
38342
  if (options.requireCompleteStructures) {
38340
38343
  issues.push(issue2(`${path28}.items`, "INCOMPLETE_ARRAY_SCHEMA", "array schemas must declare items"));
38341
38344
  }
38342
- } else {
38345
+ } else if (!options.allowEmptyArrayItemSchema || Object.keys(value.items).length > 0) {
38343
38346
  validateSchemaNode(value.items, `${path28}.items`, issues, options);
38344
38347
  }
38345
38348
  }
@@ -39819,11 +39822,11 @@ function validateClientAction(body, path28, issues) {
39819
39822
  issues.push(issue2(`${path28}.context`, "INVALID_CLIENT_ACTION_CONTEXT", "ui.surface.open requires context.surfaceId"));
39820
39823
  return;
39821
39824
  }
39822
- if (body.name === "ui.page.open" || body.name === "ui.miniprogram.embed") {
39823
- if (!isPlainRecord(body.context) || Object.keys(body.context).length !== 1 || typeof body.context.url !== "string" && !isStrictBinding(body.context.url))
39825
+ if (body.name === "ui.page.open" || body.name === "ui.miniprogram.embed" || body.name === "ui.miniprogram.open") {
39826
+ if (!isPlainRecord(body.context) || Object.keys(body.context).some((key) => key !== "url" && !((body.name === "ui.miniprogram.embed" || body.name === "ui.miniprogram.open") && key === "returnQuery")) || body.context.returnQuery !== void 0 && typeof body.context.returnQuery !== "boolean" || typeof body.context.url !== "string" && !isStrictBinding(body.context.url))
39824
39827
  issues.push(issue2(`${path28}.context`, "INVALID_CLIENT_ACTION_CONTEXT", `${body.name} requires one literal or bound URL`));
39825
39828
  else if (typeof body.context.url === "string" && !isSafePageUrl(body.context.url, body.name))
39826
- 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"));
39829
+ issues.push(issue2(`${path28}.context.url`, "INVALID_PAGE_URL", body.name === "ui.miniprogram.embed" || body.name === "ui.miniprogram.open" ? `${body.name} URL must include appId parameter` : "ui.page.open URL must use https or the approved Alipay scheme"));
39827
39830
  return;
39828
39831
  }
39829
39832
  issues.push(issue2(`${path28}.name`, "UNSUPPORTED_CLIENT_ACTION", `unsupported client action ${String(body.name)}`));
@@ -39933,7 +39936,7 @@ function rejectUnknownKeys(value, allowed, path28, issues) {
39933
39936
  function isSafePageUrl(value, actionName) {
39934
39937
  if (value.length > 2e3)
39935
39938
  return false;
39936
- if (actionName === "ui.miniprogram.embed") {
39939
+ if (actionName === "ui.miniprogram.embed" || actionName === "ui.miniprogram.open") {
39937
39940
  try {
39938
39941
  return Boolean(new URL(value).searchParams.get("appId"));
39939
39942
  } catch {
@@ -40289,7 +40292,7 @@ function getA2UICardResourceConfigV4PipelineIssues(value, standard = false) {
40289
40292
  requiredString(value.whenToUse, "config.whenToUse", issues);
40290
40293
  optionalString(value.whenNotToUse, "config.whenNotToUse", issues);
40291
40294
  validateLooseJsonSchema(value.presentationInputSchema, "config.presentationInputSchema", issues);
40292
- const fields2 = validateFields(value.fields, "config.fields", issues);
40295
+ const fields2 = validateFields(value.fields, "config.fields", issues, standard);
40293
40296
  const pipelineSources = validatePipelineDataSources(value.dataSources, "config.dataSources", issues);
40294
40297
  if (value.argumentMode === "model" && pipelineSources) {
40295
40298
  validateModelPipelineArguments(value, pipelineSources, "config", issues);
@@ -40335,7 +40338,7 @@ function getA2UICardResourceConfigV3Issues(value, standard = false) {
40335
40338
  requiredString(value.description, "config.description", issues);
40336
40339
  requiredString(value.whenToUse, "config.whenToUse", issues);
40337
40340
  optionalString(value.whenNotToUse, "config.whenNotToUse", issues);
40338
- const fields2 = validateFields(value.fields, "config.fields", issues);
40341
+ const fields2 = validateFields(value.fields, "config.fields", issues, standard);
40339
40342
  if (value.schemaVersion === "4") {
40340
40343
  validateBindingOutputSchemas(value.bindingOutputSchemas, fields2, "config.bindingOutputSchemas", issues);
40341
40344
  }
@@ -40780,7 +40783,7 @@ function hasOverlappingJsonPointer(fixedInput, inputPath) {
40780
40783
  }
40781
40784
  return fixedPaths.some((fixedPath) => fixedPath === inputPath || fixedPath.startsWith(`${inputPath}/`) || inputPath.startsWith(`${fixedPath}/`));
40782
40785
  }
40783
- function validateFields(value, path28, issues) {
40786
+ function validateFields(value, path28, issues, allowEmptyArrayItemSchema = false) {
40784
40787
  if (!Array.isArray(value)) {
40785
40788
  issues.push(issue2(path28, "INVALID_FIELDS", `${path28} must be an array`));
40786
40789
  return void 0;
@@ -40833,7 +40836,7 @@ function validateFields(value, path28, issues) {
40833
40836
  if (!FIELD_SOURCES.has(candidate.source)) {
40834
40837
  issues.push(issue2(`${itemPath}.source`, "INVALID_FIELD_SOURCE", "field source is invalid"));
40835
40838
  }
40836
- const schemaIssues = getJsonSchemaIssues(candidate.valueSchema, `${itemPath}.valueSchema`, { requireCompleteStructures: true });
40839
+ const schemaIssues = getJsonSchemaIssues(candidate.valueSchema, `${itemPath}.valueSchema`, { requireCompleteStructures: true, allowEmptyArrayItemSchema });
40837
40840
  issues.push(...schemaIssues);
40838
40841
  if (isPlainRecord(candidate.valueSchema) && candidate.valueSchema.type !== candidate.type) {
40839
40842
  issues.push(issue2(`${itemPath}.valueSchema.type`, "FIELD_SCHEMA_TYPE_MISMATCH", `valueSchema.type must equal field type ${String(candidate.type)}`));
@@ -41707,13 +41710,13 @@ function getA2UICardAuthoringDiagnostics(bundle, partial2) {
41707
41710
  const component = findComponent(bundle, group.surfaceId, group.componentId);
41708
41711
  const action = isPlainRecord(component?.action) ? component.action : void 0;
41709
41712
  const client = action && isPlainRecord(action.client) ? action.client : void 0;
41710
- if (client?.name === "ui.page.open" || client?.name === "ui.miniprogram.embed") {
41713
+ if (client?.name === "ui.page.open" || client?.name === "ui.miniprogram.embed" || client?.name === "ui.miniprogram.open") {
41711
41714
  const context = isPlainRecord(client.context) ? client.context : void 0;
41712
41715
  if (typeof context?.url === "string" && !isSafePageUrl2(context.url, typeof client?.name === "string" ? client.name : void 0)) {
41713
41716
  diagnostics.push({
41714
41717
  code: "UNSAFE_PAGE_URL",
41715
41718
  path: `${group.occurrenceId}.action.client.context.url`,
41716
- message: client?.name === "ui.miniprogram.embed" ? "\u5C0F\u7A0B\u5E8F\u534A\u5C4F\u6253\u5F00\u5FC5\u987B\u6709 appId \u53C2\u6570" : "\u9875\u9762\u5730\u5740\u5FC5\u987B\u662F\u5B89\u5168\u7684 http(s) \u5730\u5740\u6216\u7AD9\u5185\u7EDD\u5BF9\u8DEF\u5F84",
41719
+ message: client?.name === "ui.miniprogram.embed" || client?.name === "ui.miniprogram.open" ? "\u6253\u5F00\u5C0F\u7A0B\u5E8F\u5FC5\u987B\u6709 appId \u53C2\u6570" : "\u9875\u9762\u5730\u5740\u5FC5\u987B\u662F\u5B89\u5168\u7684 http(s) \u5730\u5740\u6216\u7AD9\u5185\u7EDD\u5BF9\u8DEF\u5F84",
41717
41720
  severity: "hard-error",
41718
41721
  occurrenceId: group.occurrenceId
41719
41722
  });
@@ -41759,7 +41762,7 @@ function isSafePageUrl2(url2, actionName) {
41759
41762
  return false;
41760
41763
  try {
41761
41764
  const parsedUrl = new URL(candidate);
41762
- if (actionName === "ui.miniprogram.embed") {
41765
+ if (actionName === "ui.miniprogram.embed" || actionName === "ui.miniprogram.open") {
41763
41766
  return Boolean(parsedUrl.searchParams.get("appId"));
41764
41767
  }
41765
41768
  return ["https:", "alipays:"].includes(parsedUrl.protocol);
@@ -41851,16 +41854,16 @@ function actionTargets(component, occurrenceId) {
41851
41854
  ];
41852
41855
  }
41853
41856
  const client = isPlainRecord(action.client) ? action.client : void 0;
41854
- if (client?.name === "ui.page.open" || client?.name === "ui.miniprogram.embed") {
41857
+ if (client?.name === "ui.page.open" || client?.name === "ui.miniprogram.embed" || client?.name === "ui.miniprogram.open") {
41855
41858
  const context = isPlainRecord(client.context) ? client.context : void 0;
41856
41859
  const url2 = context?.url;
41857
41860
  return [
41858
41861
  {
41859
- kind: client.name === "ui.miniprogram.embed" ? "miniprogram-embed" : "page-open",
41862
+ kind: client.name === "ui.miniprogram.open" ? "miniprogram-open" : client.name === "ui.miniprogram.embed" ? "miniprogram-embed" : "page-open",
41860
41863
  targetId: createA2UICardAuthoringTargetId(occurrenceId, "action"),
41861
41864
  occurrenceId,
41862
41865
  propertyPath: "action",
41863
- label: client.name === "ui.miniprogram.embed" ? "\u534A\u5C4F\u6253\u5F00\u5C0F\u7A0B\u5E8F" : "\u6253\u5F00\u9875\u9762",
41866
+ label: client.name === "ui.miniprogram.open" ? "\u5168\u5C4F\u6253\u5F00\u5C0F\u7A0B\u5E8F" : client.name === "ui.miniprogram.embed" ? "\u534A\u5C4F\u6253\u5F00\u5C0F\u7A0B\u5E8F" : "\u6253\u5F00\u9875\u9762",
41864
41867
  ...typeof url2 === "string" ? { url: url2 } : {},
41865
41868
  dynamic: isPlainRecord(url2) && typeof url2.path === "string"
41866
41869
  }
@@ -43200,6 +43203,7 @@ var ETelemetryEventPhase;
43200
43203
  var ETelemetryEventName;
43201
43204
  (function(ETelemetryEventName2) {
43202
43205
  ETelemetryEventName2["TOOL_EXECUTION_FAILED"] = "linkque.tool.execution.failed";
43206
+ ETelemetryEventName2["CARD_MCP_FAILED"] = "linkque.card.mcp.failed";
43203
43207
  ETelemetryEventName2["TELEMETRY_COVERAGE"] = "linkque.telemetry.coverage";
43204
43208
  ETelemetryEventName2["HOOK_MATCHED"] = "linkque.hook.matched";
43205
43209
  ETelemetryEventName2["HOOK_SCHEDULED"] = "linkque.hook.scheduled";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linkque-cli-v2",
3
- "version": "1.6.25",
3
+ "version": "1.6.27",
4
4
  "description": "Public Linkque CLI bundle for sandbox debugging",
5
5
  "bin": {
6
6
  "linkquejs": "linkquejs.js"
@@ -23,7 +23,7 @@ import {
23
23
  RuntimeConfigProvider,
24
24
  getRunEmbeddedQuery,
25
25
  isDebugLoggingEnabled
26
- } from "./chunk-IMRER6VX.js";
26
+ } from "./chunk-PYP7WCXN.js";
27
27
  import {
28
28
  __commonJS,
29
29
  __require,
@@ -42301,6 +42301,9 @@ function isRecord4(value) {
42301
42301
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
42302
42302
  }
42303
42303
 
42304
+ // ../linkque-agent-runtime/dist/esm/impl/mcp/alipay/gatewayAuthorization.js
42305
+ import { randomUUID } from "node:crypto";
42306
+
42304
42307
  // ../linkque-agent-runtime/dist/esm/core/abort.js
42305
42308
  function waitWithSignal(operation, signal) {
42306
42309
  if (typeof operation === "function") {
@@ -42335,7 +42338,39 @@ function waitForPromise(operation, signal) {
42335
42338
  });
42336
42339
  }
42337
42340
 
42341
+ // ../linkque-agent-runtime/dist/esm/impl/a2aDiagnostics.js
42342
+ function diagnosticCode(value) {
42343
+ if (typeof value === "string" && /^[A-Z][A-Z0-9_]{0,79}$/.test(value))
42344
+ return value;
42345
+ return void 0;
42346
+ }
42347
+ function diagnosticResponse(response) {
42348
+ const trace2 = response.headers.get("x-trace-id") ?? response.headers.get("traceparent");
42349
+ return {
42350
+ statusCode: response.status,
42351
+ gatewayTraceId: trace2 && /^[A-Za-z0-9_-]{1,128}$/.test(trace2) ? trace2 : void 0
42352
+ };
42353
+ }
42354
+ function emitA2aDiagnostic(record4, event) {
42355
+ try {
42356
+ record4?.(event);
42357
+ } catch {
42358
+ }
42359
+ }
42360
+
42338
42361
  // ../linkque-agent-runtime/dist/esm/impl/apassAuthorization.js
42362
+ var ApassTokenNotIssuedError = class extends Error {
42363
+ code = "APASS_TOKEN_NOT_ISSUED";
42364
+ constructor() {
42365
+ super("APASS_TOKEN_NOT_ISSUED");
42366
+ }
42367
+ };
42368
+ var ApassConfirmationFailedError = class extends Error {
42369
+ code = "APASS_CONFIRM_FAILED";
42370
+ constructor() {
42371
+ super("\u6388\u6743\u672A\u6210\u529F\uFF0C\u8BF7\u91CD\u65B0\u786E\u8BA4\u6388\u6743");
42372
+ }
42373
+ };
42339
42374
  var ApassAuthorizationRequiredError = class extends Error {
42340
42375
  challenge;
42341
42376
  code = "APASS_AUTHORIZATION_REQUIRED";
@@ -42352,12 +42387,25 @@ function apassChallenge(error) {
42352
42387
  return challenge;
42353
42388
  return void 0;
42354
42389
  }
42355
- async function invokeApassAuthorization(baseUrl, authorization, operation, body, fetchImpl = fetch, signal) {
42390
+ async function invokeApassAuthorization(baseUrl, authorization, operation, body, fetchImpl = fetch, signal, diagnostic) {
42391
+ const startedAt = Date.now();
42392
+ let stage = `apass.${operation}.credentials`;
42393
+ const report = (outcome, fields = {}) => emitA2aDiagnostic(diagnostic, {
42394
+ stage,
42395
+ outcome,
42396
+ elapsedMs: Date.now() - startedAt,
42397
+ ...fields
42398
+ });
42399
+ report("started");
42356
42400
  const credential = /^(Bearer|Scenario)[\t ]+([^\s,]+)$/iu.exec(authorization);
42357
- if (!credential || (credential[1].toLowerCase() === "scenario" ? !/^lqs_[A-Za-z0-9_-]{43}$/u.test(credential[2]) : credential[2].startsWith("lqs_")))
42401
+ if (!credential || (credential[1].toLowerCase() === "scenario" ? !/^lqs_[A-Za-z0-9_-]{43}$/u.test(credential[2]) : credential[2].startsWith("lqs_"))) {
42402
+ report("failed");
42358
42403
  throw new Error("APASS_USER_AUTHORIZATION_REQUIRED");
42359
- if (!body || typeof body !== "object" || Array.isArray(body))
42404
+ }
42405
+ if (!body || typeof body !== "object" || Array.isArray(body)) {
42406
+ report("failed");
42360
42407
  throw new Error("APASS_AUTHORIZATION_FAILED");
42408
+ }
42361
42409
  const requestBody = {
42362
42410
  ...body,
42363
42411
  credentialType: credential[1].toLowerCase() === "scenario" ? "scenarioToken" : "userToken"
@@ -42368,6 +42416,7 @@ async function invokeApassAuthorization(baseUrl, authorization, operation, body,
42368
42416
  ]);
42369
42417
  let reader;
42370
42418
  try {
42419
+ stage = `apass.${operation}.http`;
42371
42420
  const response = await waitWithSignal(() => fetchImpl(new URL(`/api/apass/${operation}`, baseUrl), {
42372
42421
  method: "POST",
42373
42422
  redirect: "error",
@@ -42375,6 +42424,8 @@ async function invokeApassAuthorization(baseUrl, authorization, operation, body,
42375
42424
  headers: { "content-type": "application/json", authorization },
42376
42425
  body: JSON.stringify(requestBody)
42377
42426
  }), combined);
42427
+ report(response.ok ? "succeeded" : "failed", diagnosticResponse(response));
42428
+ stage = `apass.${operation}.response`;
42378
42429
  if (!response.ok || !response.body) {
42379
42430
  void response.body?.cancel().catch(() => void 0);
42380
42431
  throw new Error("APASS_AUTHORIZATION_FAILED");
@@ -42396,10 +42447,27 @@ async function invokeApassAuthorization(baseUrl, authorization, operation, body,
42396
42447
  if (!result || typeof result !== "object" || Array.isArray(result))
42397
42448
  throw new Error("APASS_AUTHORIZATION_FAILED");
42398
42449
  const envelope = result;
42450
+ report(envelope.success === true ? "succeeded" : "failed", {
42451
+ gatewayErrorCode: diagnosticCode(envelope.errorCode)
42452
+ });
42453
+ if (operation === "confirmAuth" && envelope.success === false && envelope.errorCode === "APASS_CONFIRM_FAILED")
42454
+ throw new ApassConfirmationFailedError();
42455
+ if (operation === "confirmToken" && envelope.success === false && [
42456
+ "APASS_AUTH_POLICY_UNAVAILABLE",
42457
+ "APASS_IDENTITY_UNAVAILABLE",
42458
+ "APASS_IDENTITY_MISMATCH",
42459
+ "INVALID_REQUEST"
42460
+ ].includes(String(envelope.errorCode)))
42461
+ throw new ApassTokenNotIssuedError();
42399
42462
  if (envelope.success !== true || !envelope.data || typeof envelope.data !== "object" || Array.isArray(envelope.data))
42400
42463
  throw new Error("APASS_AUTHORIZATION_FAILED");
42464
+ stage = `apass.${operation}.completed`;
42465
+ report("succeeded");
42401
42466
  return envelope.data;
42402
- } catch {
42467
+ } catch (error) {
42468
+ report("failed");
42469
+ if (error instanceof ApassTokenNotIssuedError || error instanceof ApassConfirmationFailedError)
42470
+ throw error;
42403
42471
  signal?.throwIfAborted();
42404
42472
  throw new Error("APASS_AUTHORIZATION_FAILED");
42405
42473
  } finally {
@@ -42411,7 +42479,6 @@ async function invokeApassAuthorization(baseUrl, authorization, operation, body,
42411
42479
  }
42412
42480
 
42413
42481
  // ../linkque-agent-runtime/dist/esm/impl/mcp/alipay/gatewayAuthorization.js
42414
- import { randomUUID } from "node:crypto";
42415
42482
  function failed() {
42416
42483
  return Object.assign(new Error("\u6388\u6743\u670D\u52A1\u8BF7\u6C42\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"), {
42417
42484
  code: "AUTHORIZATION_GATEWAY_FAILED"
@@ -42555,7 +42622,13 @@ function toAuthorizationChallenge(result, serviceName) {
42555
42622
  }
42556
42623
  async function confirmAuthorization(input, options) {
42557
42624
  if (input.authorizationKind === "apass") {
42558
- const result = await invokeApassAuthorization(options.baseUrl, options.authorizationHeader, "confirmAuth", { agentId: input.agentId, authSessionId: input.authSessionId }, options.fetch);
42625
+ const result = await invokeApassAuthorization(options.baseUrl, options.authorizationHeader, "confirmAuth", { agentId: input.agentId, authSessionId: input.authSessionId }, options.fetch, void 0, (event) => options.log?.({
42626
+ operation: "confirmAuth",
42627
+ authorizationKind: "apass",
42628
+ authSessionId: input.authSessionId,
42629
+ agentId: input.agentId,
42630
+ ...event
42631
+ }));
42559
42632
  if (result.status !== "confirmed" || result.authSessionId !== input.authSessionId)
42560
42633
  throw failed();
42561
42634
  return;
@@ -43781,7 +43854,7 @@ function validateSchemaNode(value, path2, issues, options) {
43781
43854
  if (options.requireCompleteStructures) {
43782
43855
  issues.push(issue2(`${path2}.items`, "INCOMPLETE_ARRAY_SCHEMA", "array schemas must declare items"));
43783
43856
  }
43784
- } else {
43857
+ } else if (!options.allowEmptyArrayItemSchema || Object.keys(value.items).length > 0) {
43785
43858
  validateSchemaNode(value.items, `${path2}.items`, issues, options);
43786
43859
  }
43787
43860
  }
@@ -44892,11 +44965,11 @@ function validateClientAction(body, path2, issues) {
44892
44965
  issues.push(issue2(`${path2}.context`, "INVALID_CLIENT_ACTION_CONTEXT", "ui.surface.open requires context.surfaceId"));
44893
44966
  return;
44894
44967
  }
44895
- if (body.name === "ui.page.open" || body.name === "ui.miniprogram.embed") {
44896
- if (!isPlainRecord(body.context) || Object.keys(body.context).length !== 1 || typeof body.context.url !== "string" && !isStrictBinding(body.context.url))
44968
+ if (body.name === "ui.page.open" || body.name === "ui.miniprogram.embed" || body.name === "ui.miniprogram.open") {
44969
+ if (!isPlainRecord(body.context) || Object.keys(body.context).some((key) => key !== "url" && !((body.name === "ui.miniprogram.embed" || body.name === "ui.miniprogram.open") && key === "returnQuery")) || body.context.returnQuery !== void 0 && typeof body.context.returnQuery !== "boolean" || typeof body.context.url !== "string" && !isStrictBinding(body.context.url))
44897
44970
  issues.push(issue2(`${path2}.context`, "INVALID_CLIENT_ACTION_CONTEXT", `${body.name} requires one literal or bound URL`));
44898
44971
  else if (typeof body.context.url === "string" && !isSafePageUrl(body.context.url, body.name))
44899
- issues.push(issue2(`${path2}.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"));
44972
+ issues.push(issue2(`${path2}.context.url`, "INVALID_PAGE_URL", body.name === "ui.miniprogram.embed" || body.name === "ui.miniprogram.open" ? `${body.name} URL must include appId parameter` : "ui.page.open URL must use https or the approved Alipay scheme"));
44900
44973
  return;
44901
44974
  }
44902
44975
  issues.push(issue2(`${path2}.name`, "UNSUPPORTED_CLIENT_ACTION", `unsupported client action ${String(body.name)}`));
@@ -45006,7 +45079,7 @@ function rejectUnknownKeys(value, allowed, path2, issues) {
45006
45079
  function isSafePageUrl(value, actionName) {
45007
45080
  if (value.length > 2e3)
45008
45081
  return false;
45009
- if (actionName === "ui.miniprogram.embed") {
45082
+ if (actionName === "ui.miniprogram.embed" || actionName === "ui.miniprogram.open") {
45010
45083
  try {
45011
45084
  return Boolean(new URL(value).searchParams.get("appId"));
45012
45085
  } catch {
@@ -45252,7 +45325,7 @@ function getA2UICardResourceConfigV4PipelineIssues(value, standard = false) {
45252
45325
  requiredString(value.whenToUse, "config.whenToUse", issues);
45253
45326
  optionalString(value.whenNotToUse, "config.whenNotToUse", issues);
45254
45327
  validateLooseJsonSchema(value.presentationInputSchema, "config.presentationInputSchema", issues);
45255
- const fields = validateFields(value.fields, "config.fields", issues);
45328
+ const fields = validateFields(value.fields, "config.fields", issues, standard);
45256
45329
  const pipelineSources = validatePipelineDataSources(value.dataSources, "config.dataSources", issues);
45257
45330
  if (value.argumentMode === "model" && pipelineSources) {
45258
45331
  validateModelPipelineArguments(value, pipelineSources, "config", issues);
@@ -45298,7 +45371,7 @@ function getA2UICardResourceConfigV3Issues(value, standard = false) {
45298
45371
  requiredString(value.description, "config.description", issues);
45299
45372
  requiredString(value.whenToUse, "config.whenToUse", issues);
45300
45373
  optionalString(value.whenNotToUse, "config.whenNotToUse", issues);
45301
- const fields = validateFields(value.fields, "config.fields", issues);
45374
+ const fields = validateFields(value.fields, "config.fields", issues, standard);
45302
45375
  if (value.schemaVersion === "4") {
45303
45376
  validateBindingOutputSchemas(value.bindingOutputSchemas, fields, "config.bindingOutputSchemas", issues);
45304
45377
  }
@@ -45544,7 +45617,7 @@ function hasOverlappingJsonPointer(fixedInput, inputPath) {
45544
45617
  }
45545
45618
  return fixedPaths.some((fixedPath) => fixedPath === inputPath || fixedPath.startsWith(`${inputPath}/`) || inputPath.startsWith(`${fixedPath}/`));
45546
45619
  }
45547
- function validateFields(value, path2, issues) {
45620
+ function validateFields(value, path2, issues, allowEmptyArrayItemSchema = false) {
45548
45621
  if (!Array.isArray(value)) {
45549
45622
  issues.push(issue2(path2, "INVALID_FIELDS", `${path2} must be an array`));
45550
45623
  return void 0;
@@ -45597,7 +45670,7 @@ function validateFields(value, path2, issues) {
45597
45670
  if (!FIELD_SOURCES.has(candidate.source)) {
45598
45671
  issues.push(issue2(`${itemPath}.source`, "INVALID_FIELD_SOURCE", "field source is invalid"));
45599
45672
  }
45600
- const schemaIssues = getJsonSchemaIssues2(candidate.valueSchema, `${itemPath}.valueSchema`, { requireCompleteStructures: true });
45673
+ const schemaIssues = getJsonSchemaIssues2(candidate.valueSchema, `${itemPath}.valueSchema`, { requireCompleteStructures: true, allowEmptyArrayItemSchema });
45601
45674
  issues.push(...schemaIssues);
45602
45675
  if (isPlainRecord(candidate.valueSchema) && candidate.valueSchema.type !== candidate.type) {
45603
45676
  issues.push(issue2(`${itemPath}.valueSchema.type`, "FIELD_SCHEMA_TYPE_MISMATCH", `valueSchema.type must equal field type ${String(candidate.type)}`));
@@ -47066,6 +47139,7 @@ var ETelemetryEventPhase;
47066
47139
  var ETelemetryEventName;
47067
47140
  (function(ETelemetryEventName2) {
47068
47141
  ETelemetryEventName2["TOOL_EXECUTION_FAILED"] = "linkque.tool.execution.failed";
47142
+ ETelemetryEventName2["CARD_MCP_FAILED"] = "linkque.card.mcp.failed";
47069
47143
  ETelemetryEventName2["TELEMETRY_COVERAGE"] = "linkque.telemetry.coverage";
47070
47144
  ETelemetryEventName2["HOOK_MATCHED"] = "linkque.hook.matched";
47071
47145
  ETelemetryEventName2["HOOK_SCHEDULED"] = "linkque.hook.scheduled";
@@ -47656,6 +47730,58 @@ function recordMcpContentSection(observation, section, value, schema) {
47656
47730
  });
47657
47731
  }
47658
47732
 
47733
+ // ../linkque-agent-runtime/dist/esm/core/telemetry/mcpIoError.js
47734
+ function summarizeMcpIoError(error, secrets) {
47735
+ const seen = /* @__PURE__ */ new Set();
47736
+ let remaining = 8;
47737
+ const redact = (value) => {
47738
+ let text = value;
47739
+ for (const secret of [...secrets].filter(Boolean).sort((a, b) => b.length - a.length))
47740
+ text = text.split(secret).join("[REDACTED]");
47741
+ return text.replace(/\b(?:Bearer|Scenario)\s+\S+/giu, "[REDACTED]").replace(/https?:\/\/[^\s"'<>]+/giu, (url2) => {
47742
+ try {
47743
+ const parsed = new URL(url2);
47744
+ return `${parsed.protocol}//${parsed.host}${parsed.pathname}`;
47745
+ } catch {
47746
+ return "[URL]";
47747
+ }
47748
+ }).slice(0, 2e3);
47749
+ };
47750
+ const visit = (value, depth) => {
47751
+ if (depth > 3 || remaining-- <= 0)
47752
+ return { truncated: true };
47753
+ if (!value || typeof value !== "object")
47754
+ return { message: redact(String(value)) };
47755
+ if (seen.has(value))
47756
+ return { circular: true };
47757
+ seen.add(value);
47758
+ const source = value;
47759
+ const result = {};
47760
+ for (const key of [
47761
+ "name",
47762
+ "message",
47763
+ "code",
47764
+ "errno",
47765
+ "syscall",
47766
+ "address",
47767
+ "port",
47768
+ "stack"
47769
+ ]) {
47770
+ const field = source[key];
47771
+ if (typeof field === "string")
47772
+ result[key] = redact(field);
47773
+ else if (typeof field === "number")
47774
+ result[key] = field;
47775
+ }
47776
+ if (source.cause !== void 0)
47777
+ result.cause = visit(source.cause, depth + 1);
47778
+ if (Array.isArray(source.errors))
47779
+ result.errors = source.errors.slice(0, 4).map((item) => visit(item, depth + 1));
47780
+ return result;
47781
+ };
47782
+ return visit(error, 0);
47783
+ }
47784
+
47659
47785
  // ../linkque-agent-runtime/dist/esm/core/authorizationExecution.js
47660
47786
  var AuthorizationPauseError = class extends Error {
47661
47787
  code = "AUTHORIZATION_PAUSED";
@@ -47975,12 +48101,33 @@ var McpProxyTool = class {
47975
48101
  inputSchema: tool.inputSchema,
47976
48102
  outputSchema: tool.outputSchema,
47977
48103
  execute: async (args, sig, context2) => {
47978
- return this.invokeCall(entry, tool, [resourceId], args, sig, context2);
48104
+ return this.invokeCall(entry, tool, [resourceId], args, sig, context2, resourceId);
47979
48105
  }
47980
48106
  };
47981
48107
  }
47982
48108
  /** 并发发现所有 server;每个 server 独立限时,失败结果不阻断其他目录。 */
47983
- invokeCall(entry, tool, resourceIds, args, signal, context2) {
48109
+ invokeCall(entry, tool, resourceIds, args, signal, context2, cardMcpResourceId) {
48110
+ const cardObservation = cardMcpResourceId ? context2?.observation : void 0;
48111
+ const recordCardFailure = (failure4, headers) => {
48112
+ try {
48113
+ cardObservation?.record(ETelemetryEventName.CARD_MCP_FAILED, {
48114
+ [ETelemetryAttribute.HARNESS_OPERATION_OUTCOME]: ETelemetryOutcome.ERROR
48115
+ }, {
48116
+ mcpResourceId: cardMcpResourceId,
48117
+ serverName: entry.server.serverName,
48118
+ toolName: tool.name,
48119
+ callKey: context2?.mcpCallKey,
48120
+ ..."error" in failure4 ? {
48121
+ error: summarizeMcpIoError(failure4.error, Object.values(headers ?? {}))
48122
+ } : failure4
48123
+ });
48124
+ } catch {
48125
+ }
48126
+ };
48127
+ const input = tool.annotations?.sensitiveInput === true;
48128
+ const output = tool.annotations?.sensitiveOutput === true;
48129
+ if (input || output)
48130
+ context2?.markToolHistorySensitive?.({ input, output });
47984
48131
  const execute = async (callSignal = signal) => {
47985
48132
  const standardAuthorization = !!this.authorization;
47986
48133
  const headers = standardAuthorization ? void 0 : await this.authorizeCall?.({
@@ -48000,10 +48147,16 @@ var McpProxyTool = class {
48000
48147
  ...context2 ? { context: context2 } : {}
48001
48148
  });
48002
48149
  callSignal?.throwIfAborted();
48150
+ if (cardObservation && data && typeof data === "object" && "isError" in data && data.isError === true) {
48151
+ recordCardFailure({ isError: true });
48152
+ }
48003
48153
  return { success: true, data };
48004
48154
  } catch (error) {
48005
48155
  callSignal?.throwIfAborted();
48006
- if (isAuthorizationPause(error) || error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError"))
48156
+ if (isAuthorizationPause(error))
48157
+ throw error;
48158
+ recordCardFailure({ error }, headers);
48159
+ if (error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError"))
48007
48160
  throw error;
48008
48161
  return {
48009
48162
  success: false,
@@ -56693,58 +56846,6 @@ var StreamableHTTPClientTransport = class {
56693
56846
  }
56694
56847
  };
56695
56848
 
56696
- // ../linkque-agent-runtime/dist/esm/impl/mcp/alipay/mcpIoError.js
56697
- function summarizeMcpIoError(error, secrets) {
56698
- const seen = /* @__PURE__ */ new Set();
56699
- let remaining = 8;
56700
- const redact = (value) => {
56701
- let text = value;
56702
- for (const secret of [...secrets].filter(Boolean).sort((a, b) => b.length - a.length))
56703
- text = text.split(secret).join("[REDACTED]");
56704
- return text.replace(/\b(?:Bearer|Scenario)\s+\S+/giu, "[REDACTED]").replace(/https?:\/\/[^\s"'<>]+/giu, (url2) => {
56705
- try {
56706
- const parsed = new URL(url2);
56707
- return `${parsed.protocol}//${parsed.host}${parsed.pathname}`;
56708
- } catch {
56709
- return "[URL]";
56710
- }
56711
- }).slice(0, 2e3);
56712
- };
56713
- const visit = (value, depth) => {
56714
- if (depth > 3 || remaining-- <= 0)
56715
- return { truncated: true };
56716
- if (!value || typeof value !== "object")
56717
- return { message: redact(String(value)) };
56718
- if (seen.has(value))
56719
- return { circular: true };
56720
- seen.add(value);
56721
- const source = value;
56722
- const result = {};
56723
- for (const key of [
56724
- "name",
56725
- "message",
56726
- "code",
56727
- "errno",
56728
- "syscall",
56729
- "address",
56730
- "port",
56731
- "stack"
56732
- ]) {
56733
- const field = source[key];
56734
- if (typeof field === "string")
56735
- result[key] = redact(field);
56736
- else if (typeof field === "number")
56737
- result[key] = field;
56738
- }
56739
- if (source.cause !== void 0)
56740
- result.cause = visit(source.cause, depth + 1);
56741
- if (Array.isArray(source.errors))
56742
- result.errors = source.errors.slice(0, 4).map((item) => visit(item, depth + 1));
56743
- return result;
56744
- };
56745
- return visit(error, 0);
56746
- }
56747
-
56748
56849
  // ../linkque-agent-runtime/dist/esm/impl/mcp/alipay/mcpErrorLog.js
56749
56850
  function createMcpErrorLogger(debugLog, context2) {
56750
56851
  const startedAt = Date.now();
@@ -59670,7 +59771,7 @@ var OtelObservation = class {
59670
59771
  record(name, attributes, body) {
59671
59772
  if (this.lost || !/^(harness|linkque)\.[a-z0-9_.]{1,128}$/.test(name))
59672
59773
  return;
59673
- const critical = name.endsWith(`.${ETelemetryEventPhase.FINISHED}`) || name === ETelemetryEventName.MODEL_USAGE_RECORDED || name === ETelemetryEventName.RUNTIME_UNCAUGHT_ERROR || name.endsWith(`.${ETelemetryEventPhase.OBSERVATION_LOST}`);
59774
+ const critical = name.endsWith(`.${ETelemetryEventPhase.FINISHED}`) || name === ETelemetryEventName.MODEL_USAGE_RECORDED || name === ETelemetryEventName.CARD_MCP_FAILED || name === ETelemetryEventName.RUNTIME_UNCAUGHT_ERROR || name.endsWith(`.${ETelemetryEventPhase.OBSERVATION_LOST}`);
59674
59775
  this.owner.emit(this, name, attributes, critical, body);
59675
59776
  }
59676
59777
  finish(outcome, attributes) {
@@ -59833,6 +59934,9 @@ export {
59833
59934
  parseConversationToolCallDisplayName,
59834
59935
  createConversationAGUIEvent,
59835
59936
  encodeConversationSseEvent,
59937
+ diagnosticCode,
59938
+ diagnosticResponse,
59939
+ emitA2aDiagnostic,
59836
59940
  ApassAuthorizationRequiredError,
59837
59941
  apassChallenge,
59838
59942
  invokeApassAuthorization,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  EModelProvider
3
- } from "./chunk-IMRER6VX.js";
3
+ } from "./chunk-PYP7WCXN.js";
4
4
 
5
5
  // ../linkque-agent-appwrite-integrate/dist/esm/runtime/protocol.js
6
6
  var baked;