linkque-cli-v2 1.6.11 → 1.6.13

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
@@ -11942,11 +11942,6 @@ var ERROR_CATALOG = {
11942
11942
  MCP_RESOURCE_NOT_CONFIGURED: { retryable: false, exitCode: 1 },
11943
11943
  MCP_DETAIL_DISABLED: { retryable: false, exitCode: 1 },
11944
11944
  MCP_DETAIL_CONFIG_INVALID: { retryable: false, exitCode: 1 },
11945
- MCP_DETAIL_CONTEXT_REQUIRED: { retryable: false, exitCode: 1 },
11946
- MCP_DETAIL_CONTEXT_INVALID: { retryable: false, exitCode: 1 },
11947
- MCP_DETAIL_CONTEXT_MISMATCH: { retryable: false, exitCode: 1 },
11948
- MCP_DETAIL_CONTEXT_EXPIRED: { retryable: false, exitCode: 1 },
11949
- MCP_DETAIL_CONTEXT_REVOKED: { retryable: false, exitCode: 1 },
11950
11945
  MCP_DETAIL_ENDPOINT_INVALID: { retryable: false, exitCode: 1 },
11951
11946
  MCP_DETAIL_AUTH_REQUIRED: { retryable: false, exitCode: 1 },
11952
11947
  MCP_DETAIL_FORBIDDEN: { retryable: false, exitCode: 1 },
@@ -17698,8 +17693,8 @@ function validateClientAction(body, path25, issues) {
17698
17693
  if (body.name === "ui.page.open" || body.name === "ui.miniprogram.embed") {
17699
17694
  if (!isPlainRecord(body.context) || Object.keys(body.context).length !== 1 || typeof body.context.url !== "string" && !isStrictBinding(body.context.url))
17700
17695
  issues.push(issue2(`${path25}.context`, "INVALID_CLIENT_ACTION_CONTEXT", `${body.name} requires one literal or bound URL`));
17701
- else if (typeof body.context.url === "string" && !isSafePageUrl(body.context.url))
17702
- issues.push(issue2(`${path25}.context.url`, "INVALID_PAGE_URL", `${body.name} URL must use https or the approved Alipay scheme`));
17696
+ else if (typeof body.context.url === "string" && !isSafePageUrl(body.context.url, body.name))
17697
+ issues.push(issue2(`${path25}.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"));
17703
17698
  return;
17704
17699
  }
17705
17700
  issues.push(issue2(`${path25}.name`, "UNSUPPORTED_CLIENT_ACTION", `unsupported client action ${String(body.name)}`));
@@ -17806,8 +17801,17 @@ function rejectUnknownKeys(value, allowed, path25, issues) {
17806
17801
  issues.push(issue2(`${path25}.${key}`, "UNKNOWN_PROTOCOL_FIELD", `unknown field ${key}`));
17807
17802
  });
17808
17803
  }
17809
- function isSafePageUrl(value) {
17810
- return value.length <= 2e3 && (value.startsWith("https://") || value.startsWith("alipays://"));
17804
+ function isSafePageUrl(value, actionName) {
17805
+ if (value.length > 2e3)
17806
+ return false;
17807
+ if (actionName === "ui.miniprogram.embed") {
17808
+ try {
17809
+ return Boolean(new URL(value).searchParams.get("appId"));
17810
+ } catch {
17811
+ return false;
17812
+ }
17813
+ }
17814
+ return value.startsWith("https://") || value.startsWith("alipays://");
17811
17815
  }
17812
17816
  function validateReferences(surfaces, path25, issues) {
17813
17817
  for (const [surfaceId, components] of surfaces) {
@@ -19657,11 +19661,11 @@ function getA2UICardAuthoringDiagnostics(bundle, partial2) {
19657
19661
  const client = action && isPlainRecord(action.client) ? action.client : void 0;
19658
19662
  if (client?.name === "ui.page.open" || client?.name === "ui.miniprogram.embed") {
19659
19663
  const context = isPlainRecord(client.context) ? client.context : void 0;
19660
- if (typeof context?.url === "string" && !isSafePageUrl2(context.url)) {
19664
+ if (typeof context?.url === "string" && !isSafePageUrl2(context.url, typeof client?.name === "string" ? client.name : void 0)) {
19661
19665
  diagnostics.push({
19662
19666
  code: "UNSAFE_PAGE_URL",
19663
19667
  path: `${group.occurrenceId}.action.client.context.url`,
19664
- message: "\u9875\u9762\u5730\u5740\u5FC5\u987B\u662F\u5B89\u5168\u7684 http(s) \u5730\u5740\u6216\u7AD9\u5185\u7EDD\u5BF9\u8DEF\u5F84",
19668
+ 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",
19665
19669
  severity: "hard-error",
19666
19670
  occurrenceId: group.occurrenceId
19667
19671
  });
@@ -19687,7 +19691,7 @@ function createA2UICardAuthoringOccurrenceId(surfaceId, componentId) {
19687
19691
  function createA2UICardAuthoringTargetId(occurrenceId, propertyPath) {
19688
19692
  return `${occurrenceId}:${encodeURIComponent(propertyPath)}`;
19689
19693
  }
19690
- function isSafePageUrl2(url2) {
19694
+ function isSafePageUrl2(url2, actionName) {
19691
19695
  const trimmed = url2.trim();
19692
19696
  if (trimmed.length === 0 || trimmed.length > 2e3)
19693
19697
  return false;
@@ -19706,7 +19710,11 @@ function isSafePageUrl2(url2) {
19706
19710
  if (candidate.includes("{{") || candidate.includes("}}"))
19707
19711
  return false;
19708
19712
  try {
19709
- return ["https:", "alipays:"].includes(new URL(candidate).protocol);
19713
+ const parsedUrl = new URL(candidate);
19714
+ if (actionName === "ui.miniprogram.embed") {
19715
+ return Boolean(parsedUrl.searchParams.get("appId"));
19716
+ }
19717
+ return ["https:", "alipays:"].includes(parsedUrl.protocol);
19710
19718
  } catch {
19711
19719
  return false;
19712
19720
  }
@@ -19804,7 +19812,7 @@ function actionTargets(component, occurrenceId) {
19804
19812
  targetId: createA2UICardAuthoringTargetId(occurrenceId, "action"),
19805
19813
  occurrenceId,
19806
19814
  propertyPath: "action",
19807
- label: client.name === "ui.miniprogram.embed" ? "\u5C0F\u7A0B\u5E8F\u534A\u5C4F\u6253\u5F00" : "\u6253\u5F00\u9875\u9762",
19815
+ label: client.name === "ui.miniprogram.embed" ? "\u534A\u5C4F\u6253\u5F00\u5C0F\u7A0B\u5E8F" : "\u6253\u5F00\u9875\u9762",
19808
19816
  ...typeof url2 === "string" ? { url: url2 } : {},
19809
19817
  dynamic: isPlainRecord(url2) && typeof url2.path === "string"
19810
19818
  }
@@ -27573,6 +27581,7 @@ var OAUTH_ERRORS = {
27573
27581
 
27574
27582
  // ../linkque-agent-runtime/dist/esm/impl/mcp/alipay/argsMapper.js
27575
27583
  var USER_ID = Symbol("\u7CFB\u7EDF\u53D8\u91CF\u7528\u6237\u6807\u8BC6");
27584
+ var APP_ID = Symbol("\u7CFB\u7EDF\u53D8\u91CF\u5C0F\u7A0B\u5E8F\u6807\u8BC6");
27576
27585
 
27577
27586
  // ../linkque-agent-runtime/dist/esm/impl/knowledge/linkqueKnowledgeSearchPort.js
27578
27587
  var DEFAULT_LINKQUEGW_KNOWLEDGE_BASE_URL = RUNTIME_CONFIG_DEFAULTS.LINKQUEGW_KNOWLEDGE_BASE_URL;
@@ -40473,7 +40482,6 @@ var import_promises15 = require("fs/promises");
40473
40482
  var import_path22 = __toESM(require("path"));
40474
40483
  var MCP_DETAIL_ENDPOINT_ENV = "LINKQUE_MCP_DETAIL_ENDPOINT";
40475
40484
  var MCP_DETAIL_ENABLED_ENV = "LINKQUE_MCP_DETAIL_ENABLED";
40476
- var MCP_DETAIL_CONTEXT_ENV = "LINKQUE_MCP_DETAIL_CONTEXT";
40477
40485
  var TIMEOUT_MS = 15e3;
40478
40486
  var MAX_RESPONSE_BYTES = 1024 * 1024;
40479
40487
  var MAX_CONFIG_BYTES = 16 * 1024 * 1024;
@@ -40484,14 +40492,8 @@ async function describeMcp(cwd, resourceId, env = process.env) {
40484
40492
  "resource-id \u5FC5\u987B\u4E3A\u975E\u7A7A\u6807\u8BC6"
40485
40493
  );
40486
40494
  }
40487
- const context = readExecutionContext(env);
40495
+ requireEnabled(env);
40488
40496
  const mounted = await readMountedMcp(cwd, resourceId);
40489
- if (mounted.agentId !== context.agentId) {
40490
- throw new LinkqueCliError(
40491
- "MCP_DETAIL_CONTEXT_MISMATCH",
40492
- "\u5F53\u524D\u5DE5\u4F5C\u533A\u4E0E MCP \u67E5\u8BE2\u59D4\u6258\u4E0D\u5339\u914D"
40493
- );
40494
- }
40495
40497
  const endpoint = resolveEndpoint(env[MCP_DETAIL_ENDPOINT_ENV]);
40496
40498
  const controller = new AbortController();
40497
40499
  const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
@@ -40500,29 +40502,21 @@ async function describeMcp(cwd, resourceId, env = process.env) {
40500
40502
  method: "POST",
40501
40503
  headers: {
40502
40504
  "content-type": "application/json",
40503
- accept: "application/json",
40505
+ accept: "application/json"
40504
40506
  // ARCA 身份只能由可信出口注入;不接受本地伪造或用户凭据降级。
40505
- "x-linkque-sandbox-execution-id": context.executionId,
40506
- "x-linkque-agent-id": mounted.agentId
40507
40507
  },
40508
40508
  redirect: "manual",
40509
40509
  signal: controller.signal,
40510
40510
  body: JSON.stringify({
40511
- schemaVersion: "2",
40512
- agentId: mounted.agentId,
40513
- workspaceId: context.workspaceId,
40514
- sprintId: context.sprintId,
40515
- sessionId: context.sessionId,
40516
- resourceId: mounted.resourceId,
40517
- resourceType: mounted.resourceType,
40518
- serverName: mounted.serverName
40511
+ schemaVersion: "3",
40512
+ abilityCode: mounted.abilityCode
40519
40513
  })
40520
40514
  });
40521
40515
  if (!response.ok) {
40522
40516
  throw await readHttpError(response);
40523
40517
  }
40524
40518
  const value = await readResponse(response);
40525
- return parseDetail(value, mounted, context);
40519
+ return parseDetail(value, mounted);
40526
40520
  } catch (cause) {
40527
40521
  if (cause instanceof LinkqueCliError) throw cause;
40528
40522
  if (controller.signal.aborted) {
@@ -40536,7 +40530,7 @@ async function describeMcp(cwd, resourceId, env = process.env) {
40536
40530
  clearTimeout(timer);
40537
40531
  }
40538
40532
  }
40539
- function readExecutionContext(env) {
40533
+ function requireEnabled(env) {
40540
40534
  const enabled = env[MCP_DETAIL_ENABLED_ENV]?.trim();
40541
40535
  if (!enabled || enabled === "false") {
40542
40536
  throw new LinkqueCliError(
@@ -40550,57 +40544,6 @@ function readExecutionContext(env) {
40550
40544
  "MCP \u8BE6\u60C5\u67E5\u8BE2\u5F00\u5173\u914D\u7F6E\u65E0\u6548"
40551
40545
  );
40552
40546
  }
40553
- const raw = env[MCP_DETAIL_CONTEXT_ENV];
40554
- if (!raw?.trim()) {
40555
- throw new LinkqueCliError(
40556
- "MCP_DETAIL_CONTEXT_REQUIRED",
40557
- "\u7F3A\u5C11\u5E73\u53F0\u4E0B\u53D1\u7684 MCP \u67E5\u8BE2\u59D4\u6258"
40558
- );
40559
- }
40560
- let value;
40561
- try {
40562
- if (Buffer.byteLength(raw, "utf8") > 8192) throw new Error();
40563
- value = JSON.parse(raw);
40564
- } catch {
40565
- throw contextError();
40566
- }
40567
- const keys = [
40568
- "schemaVersion",
40569
- "scope",
40570
- "executionId",
40571
- "agentId",
40572
- "workspaceId",
40573
- "sprintId",
40574
- "sessionId",
40575
- "expiresAt"
40576
- ];
40577
- if (!object2(value) || Object.keys(value).length !== keys.length || !Object.keys(value).every((key) => keys.includes(key)) || value.schemaVersion !== "1" || value.scope !== "mcp:describe" || typeof value.executionId !== "string" || !/^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/u.test(
40578
- value.executionId
40579
- ) || !identifier(value.agentId) || !identifier(value.workspaceId) || !identifier(value.sprintId) || !identifier(value.sessionId) || typeof value.expiresAt !== "number" || !Number.isSafeInteger(value.expiresAt) || value.expiresAt <= 0) {
40580
- throw contextError();
40581
- }
40582
- if (value.expiresAt <= Date.now()) {
40583
- throw new LinkqueCliError(
40584
- "MCP_DETAIL_CONTEXT_EXPIRED",
40585
- "MCP \u67E5\u8BE2\u59D4\u6258\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u7531\u5E73\u53F0\u91CD\u65B0\u7B7E\u53D1"
40586
- );
40587
- }
40588
- return {
40589
- schemaVersion: "1",
40590
- scope: "mcp:describe",
40591
- executionId: value.executionId,
40592
- agentId: value.agentId,
40593
- workspaceId: value.workspaceId,
40594
- sprintId: value.sprintId,
40595
- sessionId: value.sessionId,
40596
- expiresAt: value.expiresAt
40597
- };
40598
- }
40599
- function contextError() {
40600
- return new LinkqueCliError(
40601
- "MCP_DETAIL_CONTEXT_INVALID",
40602
- "\u5E73\u53F0\u4E0B\u53D1\u7684 MCP \u67E5\u8BE2\u59D4\u6258\u683C\u5F0F\u65E0\u6548"
40603
- );
40604
40547
  }
40605
40548
  async function readMountedMcp(cwd, resourceId) {
40606
40549
  let content;
@@ -40645,7 +40588,25 @@ async function readMountedMcp(cwd, resourceId) {
40645
40588
  if (config3.allowedTools.length > 0)
40646
40589
  allowedTools = [...new Set(config3.allowedTools)];
40647
40590
  }
40591
+ let abilityCode = resourceId;
40592
+ if (resource.resourceType === "MCP_TOOL") {
40593
+ if (config3.mcpCode !== void 0) {
40594
+ if (!identifier(config3.mcpCode)) throw configError();
40595
+ abilityCode = config3.mcpCode;
40596
+ } else {
40597
+ const candidates = /* @__PURE__ */ new Set();
40598
+ for (const item of value.agent.resources) {
40599
+ if (object2(item) && item.resourceType === "MCP" && item.providerType === "ALIPAY_OPEN" && object2(item.config) && item.config.serverName === config3.serverName) {
40600
+ if (!identifier(item.resourceId)) throw configError();
40601
+ candidates.add(item.resourceId);
40602
+ }
40603
+ }
40604
+ if (candidates.size !== 1) throw configError();
40605
+ abilityCode = [...candidates][0];
40606
+ }
40607
+ }
40648
40608
  return {
40609
+ abilityCode,
40649
40610
  agentId: value.agentId,
40650
40611
  resourceId,
40651
40612
  resourceType: resource.resourceType,
@@ -40697,7 +40658,7 @@ async function readResponse(response) {
40697
40658
  throw responseError();
40698
40659
  }
40699
40660
  }
40700
- function parseDetail(value, mounted, context) {
40661
+ function parseDetail(value, mounted) {
40701
40662
  if (!object2(value)) throw responseError();
40702
40663
  if (value.success === false) {
40703
40664
  throw businessError(value) ?? new LinkqueCliError(
@@ -40706,7 +40667,7 @@ function parseDetail(value, mounted, context) {
40706
40667
  );
40707
40668
  }
40708
40669
  const data = value.data;
40709
- if (value.success !== true || !object2(data) || data.schemaVersion !== "2" || data.agentId !== mounted.agentId || data.workspaceId !== context.workspaceId || data.sprintId !== context.sprintId || data.sessionId !== context.sessionId || data.resourceId !== mounted.resourceId || data.resourceType !== mounted.resourceType || data.serverName !== mounted.serverName || !Array.isArray(data.tools) || data.tools.length > 256)
40670
+ if (value.success !== true || !object2(data) || data.schemaVersion !== "3" || data.abilityCode !== mounted.abilityCode || !Array.isArray(data.tools) || data.tools.length > 256)
40710
40671
  throw responseError();
40711
40672
  const names = /* @__PURE__ */ new Set();
40712
40673
  const tools = data.tools.map((tool) => {
@@ -40726,18 +40687,22 @@ function parseDetail(value, mounted, context) {
40726
40687
  ...typeof readOnlyHint === "boolean" ? { annotations: { readOnlyHint } } : {}
40727
40688
  };
40728
40689
  });
40690
+ if (mounted.allowedTools?.some((name) => !names.has(name))) {
40691
+ throw new LinkqueCliError(
40692
+ "MCP_DETAIL_CONFIG_STALE",
40693
+ "\u5DF2\u914D\u7F6E\u7684\u5DE5\u5177\u8C03\u7528\u540D\u4E0E Mng \u8FD4\u56DE\u7684\u5DE5\u5177\u8BE6\u60C5\u4E0D\u5339\u914D\uFF0C\u8BF7\u5E73\u53F0\u68C0\u67E5 toolEnName \u6620\u5C04\u53CA\u6302\u8F7D\u914D\u7F6E"
40694
+ );
40695
+ }
40729
40696
  return {
40730
- schemaVersion: "2",
40697
+ schemaVersion: "3",
40698
+ abilityCode: mounted.abilityCode,
40731
40699
  agentId: mounted.agentId,
40732
- workspaceId: context.workspaceId,
40733
- sprintId: context.sprintId,
40734
- sessionId: context.sessionId,
40735
40700
  resourceId: mounted.resourceId,
40736
40701
  resourceType: mounted.resourceType,
40737
40702
  serverName: mounted.serverName,
40738
40703
  ...optionalText(data, "abilityName"),
40739
40704
  ...optionalText(data, "abilityVersion"),
40740
- // 只收窄当前选中资源的范围,不合并同服务下其他资源的权限。
40705
+ // 按当前本地资源过滤展示工具;这是调用方选择,不是服务端授权。
40741
40706
  tools: tools.filter(
40742
40707
  (tool) => !mounted.allowedTools || mounted.allowedTools.includes(tool.toolName)
40743
40708
  )
@@ -40782,26 +40747,6 @@ function businessError(value, status2) {
40782
40747
  status: 503,
40783
40748
  message: "\u5F53\u524D\u4F1A\u8BDD\u672A\u542F\u7528 MCP \u8BE6\u60C5\u67E5\u8BE2\uFF0C\u65E0\u6CD5\u5B8C\u6210\u6570\u636E\u7ED1\u5B9A"
40784
40749
  },
40785
- EXECUTION_INVALID: {
40786
- code: "MCP_DETAIL_CONTEXT_INVALID",
40787
- status: 403,
40788
- message: "Mng \u62D2\u7EDD MCP \u67E5\u8BE2\u59D4\u6258"
40789
- },
40790
- EXECUTION_CONTEXT_MISMATCH: {
40791
- code: "MCP_DETAIL_CONTEXT_MISMATCH",
40792
- status: 403,
40793
- message: "MCP \u67E5\u8BE2\u59D4\u6258\u4E0E\u5F53\u524D\u4F1A\u8BDD\u4E0D\u5339\u914D"
40794
- },
40795
- EXECUTION_EXPIRED: {
40796
- code: "MCP_DETAIL_CONTEXT_EXPIRED",
40797
- status: 410,
40798
- message: "MCP \u67E5\u8BE2\u59D4\u6258\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u7531\u5E73\u53F0\u91CD\u65B0\u7B7E\u53D1"
40799
- },
40800
- EXECUTION_REVOKED: {
40801
- code: "MCP_DETAIL_CONTEXT_REVOKED",
40802
- status: 410,
40803
- message: "MCP \u67E5\u8BE2\u59D4\u6258\u5DF2\u64A4\u9500"
40804
- },
40805
40750
  AUTH_REQUIRED: {
40806
40751
  code: "MCP_DETAIL_AUTH_REQUIRED",
40807
40752
  status: 401,
@@ -44060,11 +44005,6 @@ var mcpDescribe = {
44060
44005
  name: MCP_DETAIL_ENDPOINT_ENV,
44061
44006
  description: "\u542F\u7528\u65F6\u5FC5\u586B\u7684\u5E73\u53F0\u5B8C\u6574\u8BE6\u60C5\u67E5\u8BE2\u7AEF\u70B9\uFF0C\u65E0\u751F\u4EA7\u9ED8\u8BA4\u503C",
44062
44007
  required: true
44063
- },
44064
- {
44065
- name: MCP_DETAIL_CONTEXT_ENV,
44066
- description: "\u542F\u7528\u65F6\u5FC5\u586B\u7684\u5E73\u53F0 MCP \u67E5\u8BE2\u59D4\u6258 JSON\uFF0C\u4E0D\u63A5\u53D7\u7528\u6237 token \u6216 AAK \u964D\u7EA7",
44067
- required: true
44068
44008
  }
44069
44009
  ],
44070
44010
  summarize: ({ serverName, tools }) => `${serverName}\uFF1A\u5DF2\u8BFB\u53D6 ${tools.length} \u4E2A\u5DE5\u5177\u8BE6\u60C5\u3002\u4F7F\u7528 --json \u83B7\u53D6\u5B8C\u6574 Schema\u3002
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linkque-cli-v2",
3
- "version": "1.6.11",
3
+ "version": "1.6.13",
4
4
  "description": "Public Linkque CLI bundle for sandbox debugging",
5
5
  "bin": {
6
6
  "linkquejs": "linkquejs.js"
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  EModelProvider
3
- } from "./chunk-DPHKD4SK.js";
3
+ } from "./chunk-WO3KBDHU.js";
4
4
 
5
5
  // ../linkque-agent-appwrite-integrate/dist/esm/runtime/protocol.js
6
6
  var baked;
@@ -24275,8 +24275,8 @@ function validateClientAction(body, path2, issues) {
24275
24275
  if (body.name === "ui.page.open" || body.name === "ui.miniprogram.embed") {
24276
24276
  if (!isPlainRecord(body.context) || Object.keys(body.context).length !== 1 || typeof body.context.url !== "string" && !isStrictBinding(body.context.url))
24277
24277
  issues.push(issue2(`${path2}.context`, "INVALID_CLIENT_ACTION_CONTEXT", `${body.name} requires one literal or bound URL`));
24278
- else if (typeof body.context.url === "string" && !isSafePageUrl(body.context.url))
24279
- issues.push(issue2(`${path2}.context.url`, "INVALID_PAGE_URL", `${body.name} URL must use https or the approved Alipay scheme`));
24278
+ else if (typeof body.context.url === "string" && !isSafePageUrl(body.context.url, body.name))
24279
+ 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"));
24280
24280
  return;
24281
24281
  }
24282
24282
  issues.push(issue2(`${path2}.name`, "UNSUPPORTED_CLIENT_ACTION", `unsupported client action ${String(body.name)}`));
@@ -24383,8 +24383,17 @@ function rejectUnknownKeys(value, allowed, path2, issues) {
24383
24383
  issues.push(issue2(`${path2}.${key}`, "UNKNOWN_PROTOCOL_FIELD", `unknown field ${key}`));
24384
24384
  });
24385
24385
  }
24386
- function isSafePageUrl(value) {
24387
- return value.length <= 2e3 && (value.startsWith("https://") || value.startsWith("alipays://"));
24386
+ function isSafePageUrl(value, actionName) {
24387
+ if (value.length > 2e3)
24388
+ return false;
24389
+ if (actionName === "ui.miniprogram.embed") {
24390
+ try {
24391
+ return Boolean(new URL(value).searchParams.get("appId"));
24392
+ } catch {
24393
+ return false;
24394
+ }
24395
+ }
24396
+ return value.startsWith("https://") || value.startsWith("alipays://");
24388
24397
  }
24389
24398
  function validateReferences(surfaces, path2, issues) {
24390
24399
  for (const [surfaceId, components] of surfaces) {
@@ -25974,13 +25983,27 @@ function collectA2UISurfaceIdsForLegacyContract(protocol) {
25974
25983
  }
25975
25984
  return [...surfaceIds];
25976
25985
  }
25986
+ var CARD_SEQUENCE = "\u540C\u4E00\u65F6\u95F4\u53EA\u80FD\u5236\u4F5C\u4E00\u5F20\u5361\u7247\uFF1A\u5148\u5B8C\u6210\u5F53\u524D\u5361\u7247\u7684\u9009\u62E9 \u2192 \u6570\u636E\u6E90\u8C03\u7528 \u2192 \u5C55\u793A\uFF0C\u518D\u9009\u62E9\u4E0B\u4E00\u5F20\u5361\u7247\u3002\u4E0D\u8981\u4EA4\u53C9\u8C03\u7528\u4E0D\u540C\u672A\u5B8C\u6210\u5361\u7247\u7684\u5DE5\u5177\u3002";
25987
+ function bindingSequence(hasSources) {
25988
+ return hasSources ? `\u5148\u9009\u62E9\u6B64\u5361\u7247\uFF0C\u518D\u6309\u4F9D\u8D56\u8C03\u7528\u5B83\u7684 card_source \u6570\u636E\u6E90\u5DE5\u5177\uFF0C\u6240\u6709\u5FC5\u9700\u7684 card_source \u6570\u636E\u6E90\u5DE5\u5177\u6210\u529F\u540E\uFF0C\u6700\u540E\u8C03\u7528 card_finish\u3002${CARD_SEQUENCE}` : "\u5148\u9009\u62E9\u6B64\u5361\u7247\uFF0C\u518D\u8C03\u7528\u5B83\u7684 card_finish \u5C55\u793A\u5DE5\u5177\uFF1B\u6B64\u5361\u7247\u6CA1\u6709\u6570\u636E\u6E90\uFF0C\u4E0D\u9700\u8981\u8C03\u7528 card_source \u6216\u8BFB\u53D6\u7F13\u5B58\u3002";
25989
+ }
25990
+ function cacheGuidance(hasSources) {
25991
+ return hasSources ? "\u82E5\u8FD4\u56DE card_skipped\uFF0C\u4EC5\u4F7F\u7528\u672C\u5361\u7247\u6570\u636E\u6E90\u56DE\u6267\u4E2D\u771F\u5B9E\u7684 resultRef \u8BFB\u53D6\u7F13\u5B58\u5E76\u56DE\u7B54\uFF1B\u6CA1\u6709\u6709\u6548\u5F15\u7528\u65F6\u4E0D\u8981\u8C03\u7528\u8BFB\u53D6\u5DE5\u5177\uFF0C\u4E0D\u8981\u91CD\u8C03\u4E1A\u52A1 MCP\u3002" : "\u82E5\u672A\u5C55\u793A\u5361\u7247\uFF0C\u4F9D\u636E\u5DF2\u6709\u4FE1\u606F\u56DE\u7B54\uFF0C\u4E0D\u8981\u7F16\u9020 resultRef \u6216\u8BFB\u53D6\u5176\u4ED6\u5361\u7247\u7684\u7F13\u5B58\u3002";
25992
+ }
25977
25993
  function createPresentationDescription(config) {
25978
- return [
25994
+ const description = [
25979
25995
  config.description,
25980
25996
  `\u9002\u7528\u573A\u666F\uFF1A${config.whenToUse}`,
25981
25997
  ...config.whenNotToUse ? [`\u4E0D\u9002\u7528\u573A\u666F\uFF1A${config.whenNotToUse}`] : [],
25982
25998
  "\u53EA\u63D0\u4F9B\u5DF2\u58F0\u660E\u7684\u6807\u8BC6\u6216\u7B5B\u9009\u53C2\u6570\u3002\u6743\u5A01\u4E1A\u52A1\u6570\u636E\u7531\u5E73\u53F0\u89E3\u6790\u83B7\u53D6\u3002"
25983
- ].join("\n");
25999
+ ];
26000
+ if (config.schemaVersion === "4" && config.dataMode === "pipeline") {
26001
+ description.push("\u8C03\u7528\u540E\u4F1A\u4E00\u6B21\u6027\u6821\u9A8C\u53C2\u6570\u3001\u5E76\u884C\u83B7\u53D6\u5168\u90E8\u6570\u636E\u5E76\u751F\u6210\u5361\u7247\uFF1B\u4E0D\u9700\u8981\u518D\u8C03\u7528 card_source \u6216 card_finish\u3002\u6210\u529F\u540E\u6839\u636E\u5C55\u793A\u56DE\u6267\u56DE\u7B54\uFF1B\u672A\u5C55\u793A\u65F6\u4F9D\u636E\u5DF2\u6709\u4FE1\u606F\u56DE\u7B54\uFF0C\u4E0D\u8981\u7F16\u9020 resultRef \u6216\u8C03\u7528\u5176\u4ED6\u5361\u7247\u7684\u8BFB\u53D6\u5DE5\u5177\u3002");
26002
+ } else if (config.schemaVersion === "3" || config.schemaVersion === "4") {
26003
+ const hasSources = (config.dataSources?.length ?? 0) > 0;
26004
+ description.push(`${bindingSequence(hasSources)} ${cacheGuidance(hasSources)}`);
26005
+ }
26006
+ return description.join("\n");
25984
26007
  }
25985
26008
  function cloneJsonObject2(value, label) {
25986
26009
  if (!isJsonObject(value))
@@ -29143,15 +29166,13 @@ var LINKQUEGW_EVENT_TYPE_BY_STAGE = {
29143
29166
  function truncateMessageContent(messageContent) {
29144
29167
  return Array.from(messageContent).slice(0, LINKQUEGW_MESSAGE_CONTENT_MAX_LENGTH).join("");
29145
29168
  }
29146
- function buildLinkquegwEventBody(context2, temporaryFrontendAppId) {
29169
+ function buildLinkquegwEventBody(context2, frontendAppId) {
29147
29170
  const eventType = LINKQUEGW_EVENT_TYPE_BY_STAGE[context2.stage];
29148
29171
  if (eventType === void 0)
29149
29172
  return void 0;
29150
29173
  const { commonParams } = context2;
29151
29174
  const payload = {
29152
- ...temporaryFrontendAppId !== void 0 && {
29153
- appId: temporaryFrontendAppId
29154
- },
29175
+ ...frontendAppId !== void 0 && { appId: frontendAppId },
29155
29176
  ...context2.stage === EHookStage.RUN_COMPLETED && context2.run.messageContent !== void 0 && {
29156
29177
  messageContent: truncateMessageContent(context2.run.messageContent)
29157
29178
  }
@@ -29183,7 +29204,7 @@ var LinkquegwEventHookExecutor = class {
29183
29204
  getAuthHeaders;
29184
29205
  fetchImpl;
29185
29206
  metricsSink;
29186
- temporaryFrontendAppId;
29207
+ frontendAppId;
29187
29208
  now;
29188
29209
  constructor(options) {
29189
29210
  this.baseUrl = options.baseUrl ?? DEFAULT_LINKQUEGW_EVENT_BASE_URL;
@@ -29191,7 +29212,7 @@ var LinkquegwEventHookExecutor = class {
29191
29212
  const baseFetch = options.fetchImpl ?? globalThis.fetch;
29192
29213
  this.fetchImpl = options.debugLog ? createHttpLoggingFetch(options.debugLog, "hook-linkque", baseFetch) : baseFetch;
29193
29214
  this.metricsSink = options.metricsSink;
29194
- this.temporaryFrontendAppId = options.temporaryFrontendAppId;
29215
+ this.frontendAppId = options.frontendAppId ?? options.temporaryFrontendAppId;
29195
29216
  this.now = options.now ?? Date.now;
29196
29217
  }
29197
29218
  async execute(resource, context2, options) {
@@ -29203,7 +29224,7 @@ var LinkquegwEventHookExecutor = class {
29203
29224
  message: `hook \u671F\u671B executor=${resource.config.executorName} provider=${resource.providerType},\u975E LinkquegwEventHookExecutor \u6D88\u8D39\u8303\u56F4`
29204
29225
  };
29205
29226
  }
29206
- const body = buildLinkquegwEventBody(context2, this.temporaryFrontendAppId);
29227
+ const body = buildLinkquegwEventBody(context2, this.frontendAppId);
29207
29228
  if (body === void 0) {
29208
29229
  return {
29209
29230
  ok: true,
@@ -40323,6 +40344,7 @@ function createStreamableHttpTransport(config, signer, onTraceId, debugLog, getC
40323
40344
 
40324
40345
  // ../linkque-agent-runtime/dist/esm/impl/mcp/alipay/argsMapper.js
40325
40346
  var USER_ID = Symbol("\u7CFB\u7EDF\u53D8\u91CF\u7528\u6237\u6807\u8BC6");
40347
+ var APP_ID = Symbol("\u7CFB\u7EDF\u53D8\u91CF\u5C0F\u7A0B\u5E8F\u6807\u8BC6");
40326
40348
  function assertSafePath(segments) {
40327
40349
  if (segments.some((s) => ["__proto__", "constructor", "prototype"].includes(String(s)))) {
40328
40350
  throw new McpInvocationError("MCP_SYSTEM_VARIABLE_INVALID", "\u6620\u5C04\u8DEF\u5F84\u7981\u6B62\u8BBF\u95EE\u539F\u578B");
@@ -40419,10 +40441,10 @@ function createArgsMappingPlan(toolName, args, rules) {
40419
40441
  continue;
40420
40442
  }
40421
40443
  if (rule.valueType === EArgsMappingValueType.SYSTEM_VARIABLE) {
40422
- if (rule.value !== "${userId}" || segments.length === 0) {
40444
+ if (!["${userId}", "${appId}"].includes(rule.value ?? "") || segments.length === 0) {
40423
40445
  throw new McpInvocationError("MCP_SYSTEM_VARIABLE_INVALID", "\u7CFB\u7EDF\u53D8\u91CF\u914D\u7F6E\u65E0\u6548");
40424
40446
  }
40425
- setByPath(out, segments, USER_ID);
40447
+ setByPath(out, segments, rule.value === "${userId}" ? USER_ID : APP_ID);
40426
40448
  continue;
40427
40449
  }
40428
40450
  if (rule.valueType === EArgsMappingValueType.CONST) {
@@ -40436,17 +40458,24 @@ function createArgsMappingPlan(toolName, args, rules) {
40436
40458
  continue;
40437
40459
  }
40438
40460
  }
40439
- const contains = (value) => value === USER_ID || value !== null && typeof value === "object" && Object.values(value).some(contains);
40440
- const requiresUserId = contains(out);
40461
+ const contains = (value, marker) => value === marker || value !== null && typeof value === "object" && Object.values(value).some((item) => contains(item, marker));
40462
+ const requiresUserId = contains(out, USER_ID);
40463
+ const requiresAppId = contains(out, APP_ID);
40441
40464
  return {
40442
40465
  requiresUserId,
40466
+ requiresAppId,
40443
40467
  resolve(identity) {
40444
40468
  if (requiresUserId && !identity?.userId?.trim()) {
40445
40469
  throw new McpInvocationError("MCP_USER_AUTH_REQUIRED", "\u7CFB\u7EDF\u53D8\u91CF\u9700\u8981\u53EF\u4FE1\u7528\u6237\u8EAB\u4EFD");
40446
40470
  }
40471
+ if (requiresAppId && !identity?.appId?.trim()) {
40472
+ throw new McpInvocationError("MCP_APP_ID_UNAVAILABLE", "\u5F53\u524D\u73AF\u5883\u65E0\u6CD5\u83B7\u53D6\u5C0F\u7A0B\u5E8F AppId");
40473
+ }
40447
40474
  const visit = (value) => {
40448
40475
  if (value === USER_ID)
40449
40476
  return identity.userId;
40477
+ if (value === APP_ID)
40478
+ return identity.appId;
40450
40479
  if (Array.isArray(value))
40451
40480
  return value.map(visit);
40452
40481
  if (value !== null && typeof value === "object") {
@@ -40524,6 +40553,7 @@ var RemoteGatewayMcpServerProvider = class {
40524
40553
  invocationContext = new McpInvocationContext();
40525
40554
  createTokenVerifier;
40526
40555
  resolveConfig;
40556
+ clientContext;
40527
40557
  getAuthorizationHeader;
40528
40558
  createSigner;
40529
40559
  createClient;
@@ -40531,6 +40561,7 @@ var RemoteGatewayMcpServerProvider = class {
40531
40561
  debugLog;
40532
40562
  constructor(options) {
40533
40563
  this.resolveConfig = options.resolveConfig;
40564
+ this.clientContext = { ...options.clientContext };
40534
40565
  this.createTokenVerifier = options.createTokenVerifier;
40535
40566
  this.getAuthorizationHeader = options.getAuthorizationHeader;
40536
40567
  this.createSigner = options.createSigner;
@@ -40638,7 +40669,10 @@ var RemoteGatewayMcpServerProvider = class {
40638
40669
  agentId: identity.agentId
40639
40670
  };
40640
40671
  }
40641
- const mapped = resolveArgsMappingPlan(plan, invocation.auth);
40672
+ const mapped = resolveArgsMappingPlan(plan, {
40673
+ ...invocation.auth,
40674
+ appId: this.clientContext.appId
40675
+ });
40642
40676
  recordMcpContentSection(innerObservation, ETelemetryContentSection.MCP_INPUT, mapped, options?.toolSchema?.inputSchema);
40643
40677
  invocation.signal.throwIfAborted();
40644
40678
  const remaining = Math.max(1, invocation.deadline - performance.now());
@@ -43126,6 +43160,9 @@ export {
43126
43160
  parseCardConfig,
43127
43161
  isAgentPresentationToolResult,
43128
43162
  isAgentPresentationSkippedToolResult,
43163
+ CARD_SEQUENCE,
43164
+ bindingSequence,
43165
+ cacheGuidance,
43129
43166
  createPresentationDescription,
43130
43167
  readStructuredContent,
43131
43168
  normalizeMcpInputSchema,
@@ -22,7 +22,7 @@ import {
22
22
  RUNTIME_CONFIG_DEFAULTS,
23
23
  RuntimeConfigProvider,
24
24
  isDebugLoggingEnabled
25
- } from "./chunk-DPHKD4SK.js";
25
+ } from "./chunk-WO3KBDHU.js";
26
26
  import {
27
27
  __commonJS,
28
28
  __require,
@@ -15664,7 +15664,7 @@ var TRIGGER_HEADER = "x-appwrite-trigger";
15664
15664
  var ENV_SELECTOR_HEADER = "x-linkque-env";
15665
15665
  var TRACE_ID_HEADER = "x-trace-id";
15666
15666
  var OTEL_TRACE_ID_HEADER = "x-linkque-otel-trace-id";
15667
- var TEMPORARY_FRONTEND_APP_ID_HEADER = "x-linkque-alipay-app-id";
15667
+ var FRONTEND_APP_ID_HEADER = "x-linkque-alipay-app-id";
15668
15668
  var ALIPAY_AUTH_CODE_HEADER = "x-alipay-authcode";
15669
15669
  var AUTH_UNAVAILABLE_HEADER = "x-linkque-phone-auth-unavailable";
15670
15670
  function readMcpPhoneAuthorization(headers) {
@@ -15765,20 +15765,20 @@ function readOtelTraceId(headers) {
15765
15765
  const traceId = raw.toLowerCase();
15766
15766
  return /^[0-9a-f]{32}$/u.test(traceId) && traceId !== "00000000000000000000000000000000" ? { kind: "valid", traceId } : { kind: "invalid" };
15767
15767
  }
15768
- function readTemporaryFrontendAppId(headers) {
15768
+ function readFrontendAppId(headers) {
15769
15769
  if (!headers)
15770
15770
  return void 0;
15771
- const direct = normalizeTemporaryFrontendAppId(headers[TEMPORARY_FRONTEND_APP_ID_HEADER]);
15771
+ const direct = normalizeFrontendAppId(headers[FRONTEND_APP_ID_HEADER]);
15772
15772
  if (direct)
15773
15773
  return direct;
15774
15774
  for (const [key, value] of Object.entries(headers)) {
15775
- if (key.toLowerCase() === TEMPORARY_FRONTEND_APP_ID_HEADER) {
15776
- return normalizeTemporaryFrontendAppId(value);
15775
+ if (key.toLowerCase() === FRONTEND_APP_ID_HEADER) {
15776
+ return normalizeFrontendAppId(value);
15777
15777
  }
15778
15778
  }
15779
15779
  return void 0;
15780
15780
  }
15781
- function normalizeTemporaryFrontendAppId(value) {
15781
+ function normalizeFrontendAppId(value) {
15782
15782
  const normalized = headValue(value);
15783
15783
  return normalized && !/[\r\n]/u.test(normalized) ? normalized : void 0;
15784
15784
  }
@@ -15940,7 +15940,7 @@ export {
15940
15940
  readEnvSelector,
15941
15941
  readTraceId,
15942
15942
  readOtelTraceId,
15943
- readTemporaryFrontendAppId,
15943
+ readFrontendAppId,
15944
15944
  readAuthenticatedUserId,
15945
15945
  readAppwriteApiKey,
15946
15946
  createClientCapabilityStore,