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.
@@ -41,9 +41,9 @@ import {
41
41
  readAppwriteApiKey,
42
42
  readAuthenticatedUserId,
43
43
  readEnvSelector,
44
+ readFrontendAppId,
44
45
  readMcpPhoneAuthorization,
45
46
  readOtelTraceId,
46
- readTemporaryFrontendAppId,
47
47
  readTraceId,
48
48
  resolveBodyJSON,
49
49
  resolveGatewayAuthContext,
@@ -51,16 +51,17 @@ import {
51
51
  resolveRunStorage,
52
52
  toAgentRunMessages,
53
53
  withIsoTimestamp
54
- } from "../../chunk-EHNI5TX3.js";
54
+ } from "../../chunk-YJPCNMFN.js";
55
55
  import "../../chunk-IWOFD643.js";
56
56
  import "../../chunk-PXCGFBV5.js";
57
57
  import "../../chunk-ETG6PNHQ.js";
58
58
  import {
59
59
  getBakedProtocol
60
- } from "../../chunk-3J4AB676.js";
60
+ } from "../../chunk-A3WEBQGR.js";
61
61
  import {
62
62
  ACTIVATE_SKILL_TOOL_NAME,
63
63
  CANCEL_CONVERSATION_RUN_OPERATION,
64
+ CARD_SEQUENCE,
64
65
  CONTENT_VALUE_MAX_LENGTH,
65
66
  CONVERSATION_HISTORY_VERSION,
66
67
  CancellationScope,
@@ -135,8 +136,10 @@ import {
135
136
  abortableDelay,
136
137
  aggregateMcpServers,
137
138
  authorizeAgentRun,
139
+ bindingSequence,
138
140
  buildHookCommonParams,
139
141
  buildSkillCatalog,
142
+ cacheGuidance,
140
143
  cloneJsonObject,
141
144
  cloneJsonValue,
142
145
  createA2UICardPipelineModelInputSchema,
@@ -197,7 +200,7 @@ import {
197
200
  warnLogFailure,
198
201
  wrapToolWithHooks,
199
202
  writeJsonPointer
200
- } from "../../chunk-DPHKD4SK.js";
203
+ } from "../../chunk-WO3KBDHU.js";
201
204
  import "../../chunk-EAODRPW4.js";
202
205
  import "../../chunk-GTEZTRCK.js";
203
206
  import "../../chunk-6POVPTQH.js";
@@ -41406,6 +41409,31 @@ var resolveAgentRuntimeHookExecutor = (plugins = [], portHookExecutorList = [],
41406
41409
  return new MergedHookExecutorHandler(executorByName);
41407
41410
  };
41408
41411
 
41412
+ // ../linkque-agent-runtime/dist/esm/core/cardReadError.js
41413
+ var CardReadError = class _CardReadError extends Error {
41414
+ code;
41415
+ constructor(code, message) {
41416
+ super(`${code}: ${message}`);
41417
+ this.code = code;
41418
+ this.name = "CardReadError";
41419
+ }
41420
+ static invalid(field, requirement) {
41421
+ return new _CardReadError("CARD_READ_INVALID_ARGUMENT", `${field} ${requirement} \u8BF7\u4FEE\u6B63\u53C2\u6570\u540E\u4F7F\u7528\u539F resultRef \u518D\u6B21\u8BFB\u53D6\u7F13\u5B58\uFF0C\u65E0\u9700\u91CD\u8C03 source \u6216\u4E1A\u52A1 MCP\u3002`);
41422
+ }
41423
+ static pathNotFound() {
41424
+ return new _CardReadError("CARD_READ_PATH_NOT_FOUND", "\u7F13\u5B58\u8DEF\u5F84\u4E0D\u5B58\u5728\u3002\u8BF7\u6838\u5BF9 view \u548C\u56DE\u6267 fields.path\uFF1B\u53EF\u5148\u7701\u7565 path/select \u67E5\u770B\u8BE5\u89C6\u56FE\u7ED3\u6784\uFF0C\u4E0D\u91CD\u65B0\u67E5\u8BE2\u4E1A\u52A1\u6570\u636E\u3002");
41425
+ }
41426
+ static viewUnavailable() {
41427
+ return new _CardReadError("CARD_READ_VIEW_UNAVAILABLE", "bound \u89C6\u56FE\u4E0D\u53EF\u7528\u3002\u8BF7\u6539\u7528 raw \u5E76\u91CD\u65B0\u6838\u5BF9\u539F\u59CB\u6570\u636E\u8DEF\u5F84\uFF0C\u4E0D\u8981\u76F4\u63A5\u6CBF\u7528\u7ED1\u5B9A\u8DEF\u5F84\uFF1B\u65E0\u9700\u91CD\u8C03\u4E1A\u52A1 MCP\u3002");
41428
+ }
41429
+ static resultNotFound() {
41430
+ return new _CardReadError("CARD_READ_RESULT_NOT_FOUND", "\u7F13\u5B58\u5F15\u7528\u4E0D\u5B58\u5728\u6216\u5DF2\u5931\u6548\u3002\u8BF7\u4F7F\u7528\u5F53\u524D\u5361\u7247\u3001\u672C\u8F6E\u56DE\u6267\u4E2D\u7684\u771F\u5B9E resultRef\uFF1B\u6CA1\u6709\u6709\u6548\u5F15\u7528\u65F6\u505C\u6B62\u91CD\u8BD5\uFF0C\u4E0D\u7F16\u9020\u5F15\u7528\u6216\u81EA\u52A8\u91CD\u8C03\u4E1A\u52A1 MCP\u3002");
41431
+ }
41432
+ static budgetExceeded() {
41433
+ return new _CardReadError("CARD_READ_BUDGET_EXCEEDED", "\u7F13\u5B58\u8BFB\u53D6\u8D85\u51FA\u9884\u7B97\u3002\u8BF7\u7F29\u5C0F path \u8303\u56F4\u3001\u51CF\u5C11 select \u6216 limit\uFF0C\u4F7F\u7528\u540C\u4E00 resultRef \u518D\u6B21\u8BFB\u53D6\uFF0C\u65E0\u9700\u91CD\u8C03\u4E1A\u52A1 MCP\u3002");
41434
+ }
41435
+ };
41436
+
41409
41437
  // ../linkque-agent-runtime/dist/esm/core/cardSourceResult.js
41410
41438
  import { randomUUID as randomUUID4 } from "node:crypto";
41411
41439
  var MAX_RECEIPT_BYTES = 1e5;
@@ -41560,11 +41588,11 @@ function readCardSourceResult(entry, args) {
41560
41588
  const request = readRequest(args);
41561
41589
  const root = request.view === "raw" ? entry.raw : entry.bound;
41562
41590
  if (root === void 0) {
41563
- throw new Error(`\u7ED3\u679C ${entry.resultRef} \u6CA1\u6709\u53EF\u8BFB\u53D6\u7684 ${request.view} \u89C6\u56FE`);
41591
+ throw CardReadError.viewUnavailable();
41564
41592
  }
41565
41593
  const selected = request.path === "" ? root : readJsonPointer(root, request.path);
41566
41594
  if (selected === void 0)
41567
- throw new Error(`\u7F13\u5B58\u8DEF\u5F84\u4E0D\u5B58\u5728: ${request.path || "/"}`);
41595
+ throw CardReadError.pathNotFound();
41568
41596
  if (!isJsonValue(selected))
41569
41597
  throw new Error(`\u7F13\u5B58\u8DEF\u5F84\u4E0D\u662F\u5408\u6CD5 JSON \u503C: ${request.path || "/"}`);
41570
41598
  const readPage = paginate(selected, request.offset, request.limit, request.textLimit, request.select);
@@ -41586,7 +41614,7 @@ function readCardSourceResult(entry, args) {
41586
41614
  };
41587
41615
  fitReadReceipt(receipt, request.select.length > 0);
41588
41616
  if (byteLength(receipt) > MAX_RECEIPT_BYTES)
41589
- throw new Error("\u7F13\u5B58\u8BFB\u53D6\u56DE\u6267\u8D85\u51FA\u9884\u7B97\uFF0C\u8BF7\u7F29\u77ED\u8DEF\u5F84\u6216\u51CF\u5C11\u9009\u62E9\u5B57\u6BB5");
41617
+ throw CardReadError.budgetExceeded();
41590
41618
  return receipt;
41591
41619
  }
41592
41620
  function byteLength(value) {
@@ -41594,21 +41622,26 @@ function byteLength(value) {
41594
41622
  }
41595
41623
  function readRequest(args) {
41596
41624
  if (!args || typeof args !== "object" || Array.isArray(args)) {
41597
- throw new Error("\u7F13\u5B58\u8BFB\u53D6\u53C2\u6570\u5FC5\u987B\u662F\u5BF9\u8C61");
41625
+ throw CardReadError.invalid("arguments", "\u5FC5\u987B\u662F\u5BF9\u8C61\u3002");
41598
41626
  }
41599
41627
  const value = args;
41600
- const view = value.view ?? "bound";
41628
+ const view = value.view === void 0 ? "bound" : value.view;
41601
41629
  if (view !== "bound" && view !== "raw")
41602
- throw new Error("view \u5FC5\u987B\u662F bound \u6216 raw");
41603
- const path = value.path ?? "";
41630
+ throw CardReadError.invalid("view", "\u5FC5\u987B\u662F bound \u6216 raw\u3002");
41631
+ const path = value.path === void 0 ? "" : value.path;
41604
41632
  if (typeof path !== "string" || path !== "" && !isSafeJsonPointer(path, true)) {
41605
- throw new Error("path \u5FC5\u987B\u662F\u5B89\u5168\u7684 JSON Pointer");
41633
+ throw CardReadError.invalid("path", "\u5FC5\u987B\u662F\u5B89\u5168 JSON Pointer\uFF0C\u4F8B\u5982 /airlineName\uFF1B\u4E0D\u63A5\u53D7 airlineName \u6216 $.airlineName\uFF1B\u5B57\u6BB5\u540D\u4E2D\u7684 / \u548C ~ \u5206\u522B\u8F6C\u4E49\u4E3A ~1 \u548C ~0\u3002\u8BFB\u53D6\u6570\u7EC4\u5B57\u6BB5\u65F6\uFF0Cpath \u5FC5\u987B\u6307\u5411\u5B9E\u9645\u6570\u7EC4\uFF0Cselect \u76F8\u5BF9\u4E8E\u6BCF\u4E2A\u5143\u7D20\u3002");
41606
41634
  }
41607
41635
  if (path.length > 2048)
41608
- throw new Error("path \u6700\u591A 2048 \u4E2A\u5B57\u7B26");
41609
- const select = value.select ?? [];
41610
- if (!Array.isArray(select) || select.some((candidate) => typeof candidate !== "string" || candidate !== "" && !isSafeJsonPointer(candidate, true))) {
41611
- throw new Error("select \u5FC5\u987B\u662F\u5B89\u5168 JSON Pointer \u6570\u7EC4");
41636
+ throw CardReadError.invalid("path", "\u6700\u591A 2048 \u4E2A\u5B57\u7B26\u3002");
41637
+ const select = value.select === void 0 ? [] : value.select;
41638
+ if (!Array.isArray(select)) {
41639
+ throw CardReadError.invalid("select", "\u5FC5\u987B\u662F JSON Pointer \u5B57\u7B26\u4E32\u6570\u7EC4\u3002");
41640
+ }
41641
+ for (const [index2, candidate] of select.entries()) {
41642
+ if (typeof candidate !== "string" || candidate !== "" && !isSafeJsonPointer(candidate, true)) {
41643
+ throw CardReadError.invalid(`select[${index2}]`, "\u5FC5\u987B\u662F\u5B89\u5168 JSON Pointer\uFF0C\u4F8B\u5982 /airlineName\uFF1B\u4E0D\u63A5\u53D7 airlineName \u6216 $.airlineName\uFF1B\u5B57\u6BB5\u540D\u4E2D\u7684 / \u548C ~ \u5206\u522B\u8F6C\u4E49\u4E3A ~1 \u548C ~0\u3002\u8BFB\u53D6\u6570\u7EC4\u5B57\u6BB5\u65F6\uFF0Cpath \u5FC5\u987B\u6307\u5411\u5B9E\u9645\u6570\u7EC4\uFF0Cselect \u76F8\u5BF9\u4E8E\u6BCF\u4E2A\u5143\u7D20\u3002");
41644
+ }
41612
41645
  }
41613
41646
  const offset = readInteger(value.offset, 0, 0, Number.MAX_SAFE_INTEGER, "offset");
41614
41647
  const requestedLimit = readInteger(value.limit, DEFAULT_PAGE_ITEMS, 1, MAX_TEXT_PAGE, "limit");
@@ -41668,7 +41701,7 @@ function projectValue(value, path, maxItems, maxText) {
41668
41701
  let visited2 = 0;
41669
41702
  const visit = (candidate, candidatePath, depth) => {
41670
41703
  if (++visited2 > 2e4 || depth > 32)
41671
- throw new Error("\u6570\u636E\u6295\u5F71\u590D\u6742\u5EA6\u8D85\u51FA\u9884\u7B97");
41704
+ throw CardReadError.budgetExceeded();
41672
41705
  if (typeof candidate === "string" && candidate.length > maxText) {
41673
41706
  omissions.push({
41674
41707
  path: candidatePath || "/",
@@ -41802,7 +41835,7 @@ function readInteger(value, fallback, min, max, name) {
41802
41835
  if (value === void 0)
41803
41836
  return fallback;
41804
41837
  if (!Number.isInteger(value) || value < min || value > max) {
41805
- throw new Error(`${name} \u5FC5\u987B\u662F ${min} \u5230 ${max} \u7684\u6574\u6570`);
41838
+ throw CardReadError.invalid(name, `\u5FC5\u987B\u662F ${min} \u5230 ${max} \u7684\u6574\u6570\u3002`);
41806
41839
  }
41807
41840
  return value;
41808
41841
  }
@@ -41936,7 +41969,6 @@ function isJsonObject(value) {
41936
41969
  }
41937
41970
 
41938
41971
  // ../linkque-agent-runtime/dist/esm/core/cardRenderMcpServer.js
41939
- 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";
41940
41972
  var AFTER_CARD_DESCRIPTION = "\u968F\u5361\u7247\u4E00\u8D77\u5C55\u793A\u7684\u6587\u5B57\u3002card_only \u5FC5\u987B\u4E3A\u7A7A\u5B57\u7B26\u4E32\u3002supplement \u53EA\u5B8C\u6210\u5269\u4F59\u95EE\u9898\uFF0C\u76F4\u63A5\u7ED9\u7ED3\u8BBA\uFF0C\u4E0D\u5148\u6982\u8FF0\u5404\u4E2A\u5019\u9009\uFF1A\u4EF7\u683C\u603B\u7ED3\u5E94\u8BF4\u8303\u56F4/\u96C6\u4E2D\u533A\u95F4/\u53D6\u820D\uFF0C\u4E0D\u6309\u9152\u5E97\u5206\u522B\u5199\u8BC4\u4EF7\uFF1B\u8FFD\u95EE\u53EA\u95EE\u6240\u9700\u6761\u4EF6\uFF0C\u4E0D\u5148\u4ECB\u7ECD\u5168\u90E8\u9152\u5E97\uFF1B\u9009\u4E00\u5BB6\u53EA\u7ED9\u8BE5\u9879\u53CA\u7406\u7531\u3002\u5141\u8BB8\u5FC5\u8981\u5F15\u7528\u4E2A\u522B\u540D\u79F0\u6570\u503C\u3002\u4E0D\u8981\u4ECE\u8BC4\u5206\u63A8\u65AD\u536B\u751F\u3001\u4ECE\u8FD1\u5730\u94C1\u63A8\u65AD\u7279\u5B9A\u666F\u70B9\u4FBF\u5229\u6027\uFF0C\u672A\u77E5\u4FDD\u6301\u672A\u77E5\u3002user_requested_text \u53EF\u63D0\u4F9B\u7528\u6237\u660E\u786E\u8981\u6C42\u7684\u5B8C\u6574\u6587\u5B57/\u8868\u683C\u3002\u591A\u5361\u7247\u65F6\u586B\u5199\u7D27\u63A5\u5F53\u524D\u5361\u7247\u7684\u8BF4\u660E\uFF0C\u7136\u540E\u7EE7\u7EED\u8C03\u7528\u4E0B\u4E00\u5F20\u5361\u7247\u5DE5\u5177\u3002\u6B64\u5904\u6587\u5B57\u4F1A\u76F4\u63A5\u5C55\u793A\uFF0Cfinish \u6210\u529F\u540E\u4E0D\u8981\u53E6\u5199\u4E00\u904D\uFF1B\u5361\u7247\u5931\u8D25\u65F6\u4ECD\u53EF\u6B63\u5E38\u6587\u5B57\u56DE\u7B54\u3002";
41941
41973
  var RESPONSE_MODE_DESCRIPTION = "\u6309\u7528\u6237\u4EFB\u52A1\u9009\u62E9\uFF1Acard_only=\u67E5\u8BE2/\u5C55\u793A\u7ED3\u679C/\u6CDB\u6CDB\u63A8\u8350\u5019\u9009\uFF0C\u5361\u7247\u5DF2\u7ECF\u5B8C\u6210\u4EFB\u52A1\uFF0C\u4E0D\u4E3B\u52A8\u65B0\u589E\u89E3\u91CA\u6216\u8FFD\u95EE\uFF1Bsupplement=\u7528\u6237\u8FD8\u8981\u6C42\u9009\u4E00\u5BB6\u53CA\u7406\u7531\u3001\u603B\u7ED3\u53D6\u820D\u3001\u8865\u5145\u653F\u7B56\u3001\u9884\u8BA2\u6240\u9700\u4FE1\u606F\uFF0C\u6216\u67E5\u8BE2\u4E3A\u7A7A\u9700\u8BF4\u660E\uFF1Buser_requested_text=\u7528\u6237\u660E\u786E\u8981\u6C42\u53E6\u7ED9\u6587\u5B57/\u53EF\u590D\u5236\u8868\u683C\u3002\u793A\u4F8B\uFF1A\u201C\u63A8\u8350\u676D\u5DDE\u9152\u5E97\u201D\u2192card_only\uFF1B\u201C\u63A8\u8350\u676D\u5DDE\u9152\u5E97\uFF0C\u9009\u4E00\u5BB6\u9002\u5408\u5E26\u5B69\u5B50\u7684\u201D\u2192supplement\uFF1B\u201C\u65E2\u8981\u5361\u7247\u4E5F\u8981\u5B8C\u6574\u8868\u683C\u201D\u2192user_requested_text\u3002";
41942
41974
  var CardRenderMcpServer = class {
@@ -41993,8 +42025,7 @@ var CardRenderMcpServer = class {
41993
42025
  modelName: name,
41994
42026
  resourceId: resource.resourceId,
41995
42027
  label: config.displayName,
41996
- description: `${createPresentationDescription(config)}
41997
- \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`,
42028
+ description: createPresentationDescription(config),
41998
42029
  inputSchema: config.argumentMode === "model" ? createA2UICardPipelineModelInputSchema(config.dataSources) : config.presentationInputSchema,
41999
42030
  execute: async (args, signal, context) => {
42000
42031
  const startedAt = Date.now();
@@ -42049,8 +42080,7 @@ var CardRenderMcpServer = class {
42049
42080
  modelName: name,
42050
42081
  resourceId: resource.resourceId,
42051
42082
  label: config.displayName,
42052
- description: `${createPresentationDescription(config)}
42053
- \u5148\u9009\u62E9\u6B64\u5361\u7247\uFF0C\u518D\u4F9D\u6B21\u8C03\u7528\u5B83\u7684 card_source \u6570\u636E\u6E90\u5DE5\u5177\u548C card_finish \u5C55\u793A\u5DE5\u5177\u3002${CARD_SEQUENCE} \u82E5\u5361\u7247\u5DE5\u5177\u8FD4\u56DE card_skipped\uFF0C\u8BFB\u53D6\u5DF2\u6709\u6570\u636E\u7F13\u5B58\u5E76\u7528 Markdown \u56DE\u7B54\uFF0C\u4E0D\u8981\u91CD\u8C03 MCP \u6216\u5411\u7528\u6237\u63D0\u53CA\u5361\u7247\u6280\u672F\u6545\u969C\u3002`,
42083
+ description: createPresentationDescription(config),
42054
42084
  inputSchema: {
42055
42085
  type: "object",
42056
42086
  properties: {},
@@ -42078,7 +42108,7 @@ var CardRenderMcpServer = class {
42078
42108
  dependsOn: source.dependsOn ?? []
42079
42109
  })),
42080
42110
  finishTool: createCardFinishToolName(resource.resourceId),
42081
- readTool: readName
42111
+ ...config.dataSources.length > 0 ? { readTool: readName } : {}
42082
42112
  };
42083
42113
  }
42084
42114
  });
@@ -42154,35 +42184,53 @@ var CardRenderMcpServer = class {
42154
42184
  }
42155
42185
  });
42156
42186
  }
42157
- tools.push({
42158
- name: readName,
42159
- modelName: readName,
42160
- resourceId: resource.resourceId,
42161
- label: `\u8BFB\u53D6${config.displayName}\u6570\u636E\u6E90\u7F13\u5B58`,
42162
- description: "\u8BFB\u53D6\u672C\u8F6E\u5DF2\u6210\u529F\u6267\u884C\u7684\u6570\u636E\u6E90\u7F13\u5B58\uFF0C\u4E0D\u4F1A\u518D\u6B21\u8C03\u7528 MCP\u3002\u4EC5\u5F53\u6570\u636E\u6E90\u56DE\u6267\u7F3A\u5C11\u51B3\u7B56\u6240\u9700\u5B57\u6BB5\u3001\u6807\u8BB0\u4E3A\u4E0D\u5B8C\u6574\uFF0C\u6216\u540E\u7EED\u5DE5\u5177\u9700\u8981\u672A\u7ED1\u5B9A\u5B57\u6BB5\u65F6\u8C03\u7528\u3002\u4F18\u5148\u8BFB\u53D6 bound \u89C6\u56FE\uFF1B\u8BFB\u53D6\u96C6\u5408\u540E\u7EED\u6761\u76EE\u65F6\uFF0C\u628A\u56DE\u6267 fields.path \u4F5C\u4E3A path \u5E76\u8BBE\u7F6E offset/limit\uFF1B\u53EA\u6709\u672A\u7ED1\u5B9A\u5B57\u6BB5\u624D\u4F7F\u7528 raw\u3002\u4E0D\u8981\u628A\u5206\u9875\u6216\u622A\u65AD\u7ED3\u679C\u5F53\u4F5C\u5168\u96C6\u3002",
42163
- inputSchema: CARD_SOURCE_READ_INPUT_SCHEMA,
42164
- outputSchema: CARD_SOURCE_READ_OUTPUT_SCHEMA,
42165
- execute: async (args, _signal, context) => {
42166
- const resultRef = readResultRef(args);
42167
- const entry = this.sourceResultByRef.get(resultRef);
42168
- const matchingEntry = entry?.cardId === resource.resourceId ? entry : void 0;
42169
- this.observeCard(context, resource, config, "read", matchingEntry?.executionId);
42170
- if (this.closed)
42171
- throw new Error(`\u7F13\u5B58\u5DF2\u5931\u6548: ${resultRef}`);
42172
- if (!matchingEntry)
42173
- throw new Error(`\u672A\u77E5\u7ED3\u679C\u5F15\u7528: ${resultRef}`);
42174
- const startedAt = Date.now();
42175
- const receipt = readCardSourceResult(matchingEntry, args);
42176
- this.logMetric(() => `source=${matchingEntry.sourceId} cacheReadMs=${Date.now() - startedAt} receiptBytes=${byteLength(receipt)}`);
42177
- return receipt;
42178
- }
42179
- });
42187
+ if (config.dataSources.length > 0) {
42188
+ tools.push({
42189
+ name: readName,
42190
+ modelName: readName,
42191
+ resourceId: resource.resourceId,
42192
+ label: `\u8BFB\u53D6${config.displayName}\u6570\u636E\u6E90\u7F13\u5B58`,
42193
+ description: `\u4EC5\u7528\u4E8E ${config.displayName} \u7684\u6570\u636E\u6E90\u7F13\u5B58\u3002
42194
+ ${CARD_SOURCE_READ_DESCRIPTION}`,
42195
+ inputSchema: CARD_SOURCE_READ_INPUT_SCHEMA,
42196
+ outputSchema: CARD_SOURCE_READ_OUTPUT_SCHEMA,
42197
+ execute: async (args, _signal, context) => {
42198
+ try {
42199
+ const resultRef = readResultRef(args);
42200
+ const entry = this.sourceResultByRef.get(resultRef);
42201
+ const matchingEntry = entry?.cardId === resource.resourceId ? entry : void 0;
42202
+ this.observeCard(context, resource, config, "read", matchingEntry?.executionId);
42203
+ if (this.closed)
42204
+ throw CardReadError.resultNotFound();
42205
+ if (!matchingEntry)
42206
+ throw CardReadError.resultNotFound();
42207
+ const startedAt = Date.now();
42208
+ const receipt = readCardSourceResult(matchingEntry, args);
42209
+ const metricMessage = `source=${matchingEntry.sourceId} cacheReadMs=${Date.now() - startedAt} receiptBytes=${byteLength(receipt)}`;
42210
+ this.logMetric(metricMessage);
42211
+ return receipt;
42212
+ } catch (error) {
42213
+ if (error instanceof CardReadError) {
42214
+ this.logMetric(`phase=cache-read status=failed code=${error.code}`);
42215
+ throw error;
42216
+ }
42217
+ if (_signal?.aborted || error instanceof Error && error.name === "AbortError") {
42218
+ throw error;
42219
+ }
42220
+ this.logMetric("phase=cache-read status=failed code=CARD_TOOL_FAILED");
42221
+ throw new Error("CARD_TOOL_FAILED: \u5361\u7247\u7F13\u5B58\u8BFB\u53D6\u5931\u8D25\u3002", {
42222
+ cause: error
42223
+ });
42224
+ }
42225
+ }
42226
+ });
42227
+ }
42180
42228
  tools.push({
42181
42229
  name: finishName,
42182
42230
  modelName: finishName,
42183
42231
  resourceId: resource.resourceId,
42184
42232
  label: `\u5C55\u793A${config.displayName}`,
42185
- description: `\u6240\u6709\u5FC5\u9700\u7684 card_source \u6570\u636E\u6E90\u5DE5\u5177\u6210\u529F\u540E\uFF0C\u5B8C\u6210\u5E76\u5C55\u793A${config.displayName}\u3002\u82E5\u8FD4\u56DE card_skipped\uFF0C\u4E0D\u8981\u91CD\u8BD5\u5361\u7247\u6216 MCP\uFF1B\u8BFB\u53D6\u5DF2\u6709\u7F13\u5B58\u5E76\u4F9D\u636E\u771F\u5B9E\u7ED3\u679C\u7528 Markdown \u56DE\u7B54\uFF0C\u4E0D\u5411\u7528\u6237\u63D0\u53CA\u5361\u7247\u6E32\u67D3\u6216\u6280\u672F\u95EE\u9898\u3002${CARD_SEQUENCE}
42233
+ description: `\u5B8C\u6210\u5E76\u5C55\u793A${config.displayName}\u3002${bindingSequence(config.dataSources.length > 0)} ${cacheGuidance(config.dataSources.length > 0)}
42186
42234
  ${AFTER_CARD_DESCRIPTION}`,
42187
42235
  inputSchema: {
42188
42236
  type: "object",
@@ -42360,15 +42408,65 @@ var CARD_SOURCE_RECEIPT_SCHEMA = {
42360
42408
  },
42361
42409
  additionalProperties: false
42362
42410
  };
42411
+ var CARD_SOURCE_READ_DESCRIPTION = `\u529F\u80FD\u63CF\u8FF0
42412
+ \u8BFB\u53D6\u672C\u8F6E\u5F53\u524D\u5361\u7247\u5DF2\u6210\u529F\u6267\u884C\u7684\u6570\u636E\u6E90\u7F13\u5B58\uFF0C\u8FD4\u56DE\u6307\u5B9A\u5B57\u6BB5\u6216\u5206\u9875\u6570\u636E\uFF0C\u4E0D\u4F1A\u518D\u6B21\u8C03\u7528\u4E1A\u52A1 MCP\u3002
42413
+
42414
+ \u4F7F\u7528\u573A\u666F
42415
+ - \u6570\u636E\u6E90\u56DE\u6267\u7F3A\u5C11\u51B3\u7B56\u6240\u9700\u5B57\u6BB5\uFF0C\u6216\u9700\u8981\u7EE7\u7EED\u8BFB\u53D6\u672A\u8FD4\u56DE\u7684\u6761\u76EE\u65F6\u4F7F\u7528\u3002
42416
+ - \u9ED8\u8BA4\u8BFB\u53D6 bound\uFF08\u5DF2\u7ED1\u5B9A\u5B57\u6BB5\uFF09\uFF1B\u9700\u8981\u672A\u7ED1\u5B9A\u5B57\u6BB5\u6216 bound \u4E0D\u53EF\u7528\u65F6\u6539\u7528 raw\uFF08\u539F\u59CB\u7ED3\u679C\uFF09\uFF0C\u5E76\u91CD\u65B0\u6838\u5BF9\u539F\u59CB\u6570\u636E\u8DEF\u5F84\u3002
42417
+ - \u53C2\u6570\u9519\u8BEF\u540E\uFF0C\u53EF\u4FEE\u6B63\u53C2\u6570\u5E76\u4F7F\u7528\u539F resultRef \u518D\u6B21\u8BFB\u53D6\u7F13\u5B58\uFF0C\u65E0\u9700\u91CD\u8C03 source \u6216\u4E1A\u52A1 MCP\u3002
42418
+ - \u5206\u9875\u6216\u622A\u65AD\u7ED3\u679C\u4E0D\u662F\u5168\u96C6\uFF0C\u4E0D\u8981\u636E\u6B64\u65AD\u8A00\u6240\u6709\u6570\u636E\u5747\u5DF2\u8FD4\u56DE\u3002
42419
+
42420
+ \u53C2\u6570\u683C\u5F0F\u8981\u6C42
42421
+ - resultRef\uFF1A\u5FC5\u987B\u590D\u5236\u672C\u8F6E\u5F53\u524D\u5361\u7247\u6570\u636E\u6E90\u56DE\u6267\u4E2D\u7684\u771F\u5B9E\u503C\uFF0C\u4E0D\u5F97\u81EA\u884C\u751F\u6210\u3002
42422
+ - path\uFF1A\u4ECE\u6240\u9009\u89C6\u56FE\u7684\u6839\u8282\u70B9\u5B9A\u4F4D\u8981\u8BFB\u53D6\u7684\u6570\u636E\u3002\u8BFB\u53D6\u96C6\u5408\u65F6\u4F18\u5148\u590D\u5236\u56DE\u6267\u4E2D\u7684 fields.path\uFF1B\u7701\u7565\u6216\u4F20\u7A7A\u5B57\u7B26\u4E32\u8868\u793A\u6839\u8282\u70B9\u3002
42423
+ - select\uFF1A\u8981\u4FDD\u7559\u7684\u5B57\u6BB5\u8DEF\u5F84\u6570\u7EC4\u3002path \u9009\u4E2D\u6570\u7EC4\u65F6\uFF0C\u6BCF\u6761\u8DEF\u5F84\u4ECE\u6BCF\u4E2A\u6570\u7EC4\u5143\u7D20\u5F00\u59CB\uFF1B\u9009\u4E2D\u5BF9\u8C61\u65F6\uFF0C\u4ECE\u8BE5\u5BF9\u8C61\u5F00\u59CB\u3002\u7701\u7565\u8868\u793A\u4E0D\u7B5B\u9009\u5B57\u6BB5\u3002
42424
+ - path \u548C select \u4E2D\u7684\u6BCF\u6761\u8DEF\u5F84\u90FD\u5FC5\u987B\u4F7F\u7528 JSON Pointer\uFF1A\u7528 / \u5206\u9694\u9010\u5C42\u8BBF\u95EE\u7684\u5B57\u6BB5\u540D\uFF0C\u6570\u7EC4\u4E0B\u6807\u4ECE 0 \u5F00\u59CB\u3002\u4F8B\u5982 /flights \u8868\u793A\u6839\u5BF9\u8C61\u7684 flights \u5B57\u6BB5\uFF0C/flights/0/airlineName \u8868\u793A\u7B2C\u4E00\u4E2A\u822A\u73ED\u7684 airlineName \u5B57\u6BB5\uFF1B\u7A7A\u5B57\u7B26\u4E32\u8868\u793A\u5F53\u524D\u8D77\u70B9\u672C\u8EAB\u3002
42425
+ - \u4F8B\u5982 path \u4E3A /flights \u65F6\uFF0Cselect \u5E94\u5199\u6210 ["/airlineName", "/price"]\uFF0C\u8868\u793A\u8BFB\u53D6\u6BCF\u4E2A\u822A\u73ED\u7684\u8FD9\u4E24\u4E2A\u5B57\u6BB5\uFF0C\u4E0D\u8981\u91CD\u590D\u5199 /flights \u524D\u7F00\u3002/airlineName \u5408\u6CD5\uFF0CairlineName \u548C $.airlineName \u4E0D\u5408\u6CD5\uFF1B\u5DE5\u5177\u4E0D\u4F1A\u81EA\u52A8\u8865 /\u3002
42426
+ - \u5B57\u6BB5\u540D\u672C\u8EAB\u542B / \u6216 ~ \u65F6\uFF0C\u5206\u522B\u5199\u6210 ~1 \u6216 ~0\u3002\u4F8B\u5982\u5B57\u6BB5\u540D a/b \u5BF9\u5E94 /a~1b\uFF0C\u5B57\u6BB5\u540D a~b \u5BF9\u5E94 /a~0b\u3002
42427
+ - offset\uFF1A\u4ECE 0 \u5F00\u59CB\u7684\u5206\u9875\u504F\u79FB\uFF1Blimit\uFF1A\u672C\u6B21\u8BFB\u53D6\u6570\u91CF\u3002\u4E24\u8005\u5FC5\u987B\u4E3A\u6574\u6570\uFF0C\u5E76\u9075\u5B88\u53C2\u6570 Schema \u7684\u8303\u56F4\u9650\u5236\u3002
42428
+
42429
+ \u5B8C\u6574\u8C03\u7528\u793A\u4F8B\uFF08resultRef\u3001\u96C6\u5408\u8DEF\u5F84\u548C\u5B57\u6BB5\u5FC5\u987B\u66FF\u6362\u4E3A\u5B9E\u9645\u56DE\u6267\u53CA\u6570\u636E\u4E2D\u7684\u503C\uFF09\uFF1A
42430
+ {
42431
+ "resultRef": "\u590D\u5236\u672C\u8F6E\u56DE\u6267\u4E2D\u7684 resultRef",
42432
+ "view": "bound",
42433
+ "path": "/flights",
42434
+ "select": ["/airlineName", "/price"],
42435
+ "offset": 0,
42436
+ "limit": 10
42437
+ }`;
42363
42438
  var CARD_SOURCE_READ_INPUT_SCHEMA = {
42364
42439
  type: "object",
42365
42440
  required: ["resultRef"],
42366
42441
  properties: {
42367
- resultRef: { type: "string" },
42368
- view: { type: "string", enum: ["bound", "raw"], default: "bound" },
42369
- path: { type: "string", maxLength: 2048, default: "" },
42370
- select: { type: "array", items: { type: "string" }, maxItems: 32 },
42371
- offset: { type: "integer", minimum: 0, default: 0 },
42442
+ resultRef: {
42443
+ description: "\u590D\u5236\u672C\u8F6E\u5F53\u524D\u5361\u7247\u6570\u636E\u6E90\u56DE\u6267\u4E2D\u7684 resultRef\uFF0C\u4E0D\u5F97\u81EA\u884C\u751F\u6210\u3002",
42444
+ type: "string"
42445
+ },
42446
+ view: {
42447
+ description: "\u9ED8\u8BA4 bound\uFF1B\u4EC5\u5728\u9700\u8981\u672A\u7ED1\u5B9A\u5B57\u6BB5\u6216 bound \u4E0D\u53EF\u7528\u65F6\u4F7F\u7528 raw\uFF0C\u5E76\u91CD\u65B0\u6838\u5BF9\u8DEF\u5F84\u3002",
42448
+ type: "string",
42449
+ enum: ["bound", "raw"],
42450
+ default: "bound"
42451
+ },
42452
+ path: {
42453
+ description: "\u76F8\u5BF9\u4E8E\u6240\u9009\u89C6\u56FE\u6839\u8282\u70B9\u7684 JSON Pointer\uFF0C\u7A7A\u5B57\u7B26\u4E32\u8868\u793A\u6839\u8282\u70B9\u3002\u96C6\u5408\u8DEF\u5F84\u4F18\u5148\u590D\u5236\u56DE\u6267 fields.path\uFF0C\u5982 /flights\u3002",
42454
+ type: "string",
42455
+ maxLength: 2048,
42456
+ default: ""
42457
+ },
42458
+ select: {
42459
+ description: 'JSON Pointer \u6570\u7EC4\uFF0C\u5982 ["/airlineName","/price"]\u3002\u76F8\u5BF9\u4E8E path \u9009\u4E2D\u7684\u5BF9\u8C61\uFF1B\u82E5\u9009\u4E2D\u6570\u7EC4\uFF0C\u5219\u76F8\u5BF9\u4E8E\u6BCF\u4E2A\u5143\u7D20\u3002\u7701\u7565\u8868\u793A\u4E0D\u7B5B\u9009\u3002\u5B57\u6BB5\u540D\u4E2D\u7684 /\u3001~ \u8F6C\u4E49\u4E3A ~1\u3001~0\u3002',
42460
+ type: "array",
42461
+ items: { type: "string" },
42462
+ maxItems: 32
42463
+ },
42464
+ offset: {
42465
+ description: "\u4ECE 0 \u5F00\u59CB\u7684\u5206\u9875\u504F\u79FB\uFF1B\u5206\u9875\u4E0D\u662F\u5168\u96C6\u3002",
42466
+ type: "integer",
42467
+ minimum: 0,
42468
+ default: 0
42469
+ },
42372
42470
  limit: {
42373
42471
  type: "integer",
42374
42472
  minimum: 1,
@@ -42438,7 +42536,7 @@ function skippedCardResult(resultRefs) {
42438
42536
  resultRef,
42439
42537
  view: "raw"
42440
42538
  })),
42441
- next: "\u672C\u8F6E\u5361\u7247\u65E0\u6CD5\u5C55\u793A\uFF0C\u4E0D\u8981\u91CD\u8BD5\u5361\u7247\u6216\u91CD\u65B0\u8C03\u7528 MCP\u3002\u6309 sources \u4E2D\u7684 resultRef \u548C view \u8C03\u7528\u672C\u5361\u7247\u7684 card_source_read\uFF0C\u53EA\u6839\u636E\u5DF2\u67E5\u8BE2\u5230\u7684\u6570\u636E\u7528 Markdown \u56DE\u7B54\u7528\u6237\uFF1B\u82E5\u7ED3\u679C\u4E3A\u7A7A\uFF0C\u5982\u5B9E\u8BF4\u660E\u6682\u65E0\u7ED3\u679C\uFF0C\u4E0D\u731C\u6D4B\u539F\u56E0\u3002\u4E0D\u8981\u5411\u7528\u6237\u63D0\u53CA\u5361\u7247\u3001\u6E32\u67D3\u6216\u6280\u672F\u6545\u969C\u3002"
42539
+ next: resultRefs.size === 0 ? "\u672C\u8F6E\u5361\u7247\u65E0\u6CD5\u5C55\u793A\u4E14\u6CA1\u6709\u53EF\u8BFB\u53D6\u7684\u6570\u636E\u6E90\u7F13\u5B58\uFF0C\u8BF7\u4F9D\u636E\u5DF2\u6709\u4FE1\u606F\u56DE\u7B54\uFF0C\u4E0D\u8981\u7F16\u9020\u5F15\u7528\u6216\u91CD\u8C03 MCP\u3002" : "\u672C\u8F6E\u5361\u7247\u65E0\u6CD5\u5C55\u793A\uFF0C\u4E0D\u8981\u91CD\u8BD5\u5361\u7247\u6216\u91CD\u65B0\u8C03\u7528 MCP\u3002\u6309 sources \u4E2D\u7684 resultRef \u548C view \u8C03\u7528\u672C\u5361\u7247\u7684 card_source_read\uFF0C\u53EA\u6839\u636E\u5DF2\u67E5\u8BE2\u5230\u7684\u6570\u636E\u7528 Markdown \u56DE\u7B54\u7528\u6237\uFF1B\u82E5\u7ED3\u679C\u4E3A\u7A7A\uFF0C\u5982\u5B9E\u8BF4\u660E\u6682\u65E0\u7ED3\u679C\uFF0C\u4E0D\u731C\u6D4B\u539F\u56E0\u3002\u4E0D\u8981\u5411\u7528\u6237\u63D0\u53CA\u5361\u7247\u3001\u6E32\u67D3\u6216\u6280\u672F\u6545\u969C\u3002"
42442
42540
  };
42443
42541
  }
42444
42542
  function createCardSourceToolName(resourceId, sourceId) {
@@ -42453,7 +42551,7 @@ function createCardFinishToolName(resourceId) {
42453
42551
  function readResultRef(args) {
42454
42552
  const resultRef = args && typeof args === "object" && !Array.isArray(args) ? args.resultRef : void 0;
42455
42553
  if (typeof resultRef !== "string" || resultRef.length === 0 || resultRef.length > 128) {
42456
- throw new Error("resultRef \u5FC5\u987B\u662F\u957F\u5EA6 1 \u5230 128 \u7684\u5B57\u7B26\u4E32");
42554
+ throw CardReadError.invalid("resultRef", "\u5FC5\u987B\u590D\u5236\u672C\u8F6E\u56DE\u6267\u4E2D\u7684\u5F15\u7528\uFF0C\u957F\u5EA6\u4E3A 1 \u5230 128\u3002");
42457
42555
  }
42458
42556
  return resultRef;
42459
42557
  }
@@ -43757,6 +43855,7 @@ var LinkquegwEventPlugin = class {
43757
43855
  if (!getAuthorizationHeader) {
43758
43856
  throw new Error("LinkqueGW event trigger \u7F3A\u5C11\u8BA4\u8BC1\u5934\u63D0\u4F9B\u5668");
43759
43857
  }
43858
+ const frontendAppId = options.frontendAppId ?? options.temporaryFrontendAppId;
43760
43859
  const executorOptions = {
43761
43860
  getAuthHeaders: async () => {
43762
43861
  const authorization = await getAuthorizationHeader();
@@ -43774,9 +43873,7 @@ var LinkquegwEventPlugin = class {
43774
43873
  ...options.metricsSink !== void 0 && {
43775
43874
  metricsSink: options.metricsSink
43776
43875
  },
43777
- ...options.temporaryFrontendAppId !== void 0 && {
43778
- temporaryFrontendAppId: options.temporaryFrontendAppId
43779
- },
43876
+ ...frontendAppId !== void 0 && { frontendAppId },
43780
43877
  ...options.now !== void 0 && { now: options.now }
43781
43878
  };
43782
43879
  this.hookExecutorList = [new LinkquegwEventHookExecutor(executorOptions)];
@@ -43899,6 +43996,20 @@ var DefaultHarnessPromptPlugin = class {
43899
43996
  // ../linkque-agent-runtime/dist/esm/impl/plugin/currentTimePlugin.js
43900
43997
  var CURRENT_TIME_PLUGIN_NAME = "current-time";
43901
43998
  var CURRENT_TIME_TOOL_NAME = "get_current_time";
43999
+ function formatLocalDateTime2(date) {
44000
+ const pad = (value, length = 2) => String(value).padStart(length, "0");
44001
+ const offsetMinutes = -date.getTimezoneOffset();
44002
+ const offsetSign = offsetMinutes >= 0 ? "+" : "-";
44003
+ const absoluteOffset = Math.abs(offsetMinutes);
44004
+ const offset = `${offsetSign}${pad(Math.floor(absoluteOffset / 60))}:${pad(absoluteOffset % 60)}`;
44005
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}.${pad(date.getMilliseconds(), 3)}${offset}`;
44006
+ }
44007
+ function createCurrentTimePrompt() {
44008
+ const timestampMs = Date.now();
44009
+ const now = new Date(timestampMs);
44010
+ const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
44011
+ return `- \u5F53\u524D\u65F6\u95F4:\u5F53\u5730\u65F6\u95F4 ${formatLocalDateTime2(now)}\uFF0C\u5F53\u5730\u65F6\u533A ${timeZone}\uFF0CUnix \u6BEB\u79D2\u65F6\u95F4\u6233 ${timestampMs}\u3002`;
44012
+ }
43902
44013
  function createCurrentTimeTool() {
43903
44014
  return {
43904
44015
  name: CURRENT_TIME_TOOL_NAME,
@@ -43963,6 +44074,7 @@ var CurrentTimePlugin = class {
43963
44074
  ok: true,
43964
44075
  patch: {
43965
44076
  stage: EHookStage.PREPARE_AGENT_LOOP,
44077
+ systemPromptSuffixes: [createCurrentTimePrompt()],
43966
44078
  additionalTools: [createCurrentTimeTool()]
43967
44079
  }
43968
44080
  } : { ok: true, skipped: true }
@@ -44150,6 +44262,7 @@ function createAppbaseMcpProvider(options = {}) {
44150
44262
  }
44151
44263
  return new RemoteGatewayMcpServerProvider({
44152
44264
  resolveConfig: options.resolveConfig,
44265
+ clientContext: options.clientContext,
44153
44266
  ...options.getAuthorizationHeader ? { getAuthorizationHeader: options.getAuthorizationHeader } : {},
44154
44267
  ...options.onTraceId ? { onTraceId: options.onTraceId } : {},
44155
44268
  ...options.debugLog ? { debugLog: options.debugLog } : {}
@@ -44192,6 +44305,7 @@ function createAppBaseRuntime(protocol, env = process.env, ports = {}, logCtx) {
44192
44305
  const prefix = scope ? `[${scope}] ` : "";
44193
44306
  logCtx.log?.(prefix + line);
44194
44307
  }) : void 0;
44308
+ const frontendAppId = ports.frontendAppId ?? ports.temporaryFrontendAppId;
44195
44309
  const runtimePorts = {};
44196
44310
  if (ports.telemetry)
44197
44311
  runtimePorts.telemetry = ports.telemetry;
@@ -44229,6 +44343,7 @@ function createAppBaseRuntime(protocol, env = process.env, ports = {}, logCtx) {
44229
44343
  });
44230
44344
  log("skillLoader:", ports.skillLoader ? "\u4F7F\u7528\u6CE8\u5165\u5B9E\u73B0" : "AppbaseSkillLoader(\u9ED8\u8BA4)");
44231
44345
  runtimePorts.mcpServerProvider = ports.mcpServerProvider ?? createAppbaseMcpProvider({
44346
+ clientContext: { appId: frontendAppId },
44232
44347
  ...ports.mcpConfigResolver ? { resolveConfig: ports.mcpConfigResolver } : {},
44233
44348
  ...ports.mcpAuthorizationHeaderProvider ? { getAuthorizationHeader: ports.mcpAuthorizationHeaderProvider } : {},
44234
44349
  ...debugLog ? { debugLog } : {}
@@ -44267,9 +44382,7 @@ function createAppBaseRuntime(protocol, env = process.env, ports = {}, logCtx) {
44267
44382
  getGatewayAuthorizationHeader: mcpAuthHeader,
44268
44383
  ...eventBaseUrl ? { baseUrl: eventBaseUrl } : {},
44269
44384
  ...ports.gatewayAgentId ? { agentId: ports.gatewayAgentId } : {},
44270
- ...ports.temporaryFrontendAppId !== void 0 && {
44271
- temporaryFrontendAppId: ports.temporaryFrontendAppId
44272
- },
44385
+ ...frontendAppId !== void 0 && { frontendAppId },
44273
44386
  ...debugLog ? { debugLog } : {}
44274
44387
  }));
44275
44388
  }
@@ -45850,7 +45963,7 @@ function historyError(status, code, message) {
45850
45963
  }
45851
45964
 
45852
45965
  // ../linkque-agent-appwrite-integrate/dist/esm/runtime/handler/readStatus.js
45853
- async function runMarkConversationRunsRead(method, bodyJSON, env, deps, logCtx, ownerId, appwriteApiKey, envSelector, traceId, gatewayAuth, temporaryFrontendAppId) {
45966
+ async function runMarkConversationRunsRead(method, bodyJSON, env, deps, logCtx, ownerId, appwriteApiKey, envSelector, traceId, gatewayAuth, frontendAppId) {
45854
45967
  if (method !== "POST") {
45855
45968
  return readStatusError(405, "method_not_allowed", "\u4EC5\u652F\u6301 POST");
45856
45969
  }
@@ -45889,7 +46002,7 @@ async function runMarkConversationRunsRead(method, bodyJSON, env, deps, logCtx,
45889
46002
  envSelector,
45890
46003
  traceId,
45891
46004
  gatewayAuth,
45892
- temporaryFrontendAppId,
46005
+ frontendAppId,
45893
46006
  logCtx
45894
46007
  });
45895
46008
  }
@@ -45920,12 +46033,11 @@ async function publishConversationRunReadHooks(input) {
45920
46033
  }
45921
46034
  const { eventBaseUrl } = resolveLinkqueEndpoints(input.env, input.envSelector);
45922
46035
  const debugLog = input.logCtx?.log ? (line) => input.logCtx?.log?.("[readStatus]", line) : void 0;
46036
+ const frontendAppId = input.frontendAppId ?? input.temporaryFrontendAppId;
45923
46037
  const plugin = new LinkquegwEventPlugin({
45924
46038
  getGatewayAuthorizationHeader: async () => input.gatewayAuth?.authorizationHeader ?? "",
45925
46039
  agentId: input.protocol.agentId,
45926
- ...input.temporaryFrontendAppId !== void 0 && {
45927
- temporaryFrontendAppId: input.temporaryFrontendAppId
45928
- },
46040
+ ...frontendAppId !== void 0 && { frontendAppId },
45929
46041
  ...eventBaseUrl ? { baseUrl: eventBaseUrl } : {},
45930
46042
  ...debugLog ? { debugLog } : {},
45931
46043
  ...input.fetchImpl ? { fetchImpl: input.fetchImpl } : {}
@@ -46397,7 +46509,7 @@ function createSecurityAnswerPlugin(historyStore, log) {
46397
46509
  }
46398
46510
 
46399
46511
  // ../linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chatConfig.js
46400
- function resolveChatDeps(env, deps, logCtx, historyOwnerId, appwriteApiKey, envSelector, gatewayAuth, temporaryFrontendAppId, initialRootTraceId) {
46512
+ function resolveChatDeps(env, deps, logCtx, historyOwnerId, appwriteApiKey, envSelector, gatewayAuth, frontendAppId, initialRootTraceId) {
46401
46513
  const log = (...a) => logCtx?.log?.("[chat]", ...a);
46402
46514
  const logError = (...a) => logCtx?.error?.("[chat]", ...a);
46403
46515
  const protocol = deps?.protocol ?? getBakedProtocol();
@@ -46486,7 +46598,8 @@ function resolveChatDeps(env, deps, logCtx, historyOwnerId, appwriteApiKey, envS
46486
46598
  });
46487
46599
  const rawMcpServerProvider = deps?.mcpServerProvider ?? createAppbaseMcpProvider({
46488
46600
  resolveConfig: mcpConfigResolver,
46489
- getAuthorizationHeader: mcpAuthorizationHeaderProvider
46601
+ getAuthorizationHeader: mcpAuthorizationHeaderProvider,
46602
+ clientContext: { appId: frontendAppId }
46490
46603
  });
46491
46604
  const mcpServerProvider = rawMcpServerProvider;
46492
46605
  const securityAnswerPlugin = deps?.securityAnswerPlugin ?? createSecurityAnswerPlugin(historyStore, logCtx?.log);
@@ -46516,7 +46629,7 @@ function resolveChatDeps(env, deps, logCtx, historyOwnerId, appwriteApiKey, envS
46516
46629
  ...skillLoaderBaseUrl ? { skillLoaderBaseUrl } : {},
46517
46630
  ...webSearchBaseUrl ? { webSearchBaseUrl } : {},
46518
46631
  ...eventBaseUrl ? { eventBaseUrl } : {},
46519
- ...temporaryFrontendAppId !== void 0 && { temporaryFrontendAppId }
46632
+ ...frontendAppId !== void 0 && { frontendAppId }
46520
46633
  }, logCtx);
46521
46634
  return {
46522
46635
  ...runAuthorization ? { runAuthorization } : {},
@@ -47208,7 +47321,7 @@ function failure2(status, code, message, retryable = false) {
47208
47321
  }
47209
47322
 
47210
47323
  // ../linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js
47211
- async function runChat(method, bodyJSON, env, deps, logCtx, historyOwnerId, appwriteApiKey, envSelector, traceId, gatewayAuth, temporaryFrontendAppId, otelTraceId) {
47324
+ async function runChat(method, bodyJSON, env, deps, logCtx, historyOwnerId, appwriteApiKey, envSelector, traceId, gatewayAuth, frontendAppId, otelTraceId) {
47212
47325
  const log = (...args) => logCtx?.log?.("[chat]", ...args);
47213
47326
  const logError = (...args) => logCtx?.error?.("[chat]", ...args);
47214
47327
  const guarded = guardChatRequest(method, bodyJSON, logCtx);
@@ -47216,7 +47329,7 @@ async function runChat(method, bodyJSON, env, deps, logCtx, historyOwnerId, appw
47216
47329
  return guarded;
47217
47330
  let request = guarded;
47218
47331
  const isPresentationRun = request.executionScope === "presentation";
47219
- const cfg = resolveChatDeps(env, deps, logCtx, historyOwnerId, appwriteApiKey, envSelector, gatewayAuth, temporaryFrontendAppId, otelTraceId);
47332
+ const cfg = resolveChatDeps(env, deps, logCtx, historyOwnerId, appwriteApiKey, envSelector, gatewayAuth, frontendAppId, otelTraceId);
47220
47333
  if ("status" in cfg)
47221
47334
  return cfg;
47222
47335
  const leaseOwnerId = randomUUID8();
@@ -47525,7 +47638,7 @@ function waitForCancellationPoll(delayMs, signal) {
47525
47638
  }
47526
47639
  });
47527
47640
  }
47528
- async function runGateway(method, bodyJSON, env, deps, logCtx, historyOwnerId, appwriteApiKey, envSelector, traceId, gatewayAuth, temporaryFrontendAppId, mcpPhoneAuthorization, otelTraceId) {
47641
+ async function runGateway(method, bodyJSON, env, deps, logCtx, historyOwnerId, appwriteApiKey, envSelector, traceId, gatewayAuth, frontendAppId, mcpPhoneAuthorization, otelTraceId) {
47529
47642
  const operation = readOperation(bodyJSON);
47530
47643
  const startedAt = Date.now();
47531
47644
  const logGateway = (event, fields = {}, failed = false) => {
@@ -47575,7 +47688,7 @@ async function runGateway(method, bodyJSON, env, deps, logCtx, historyOwnerId, a
47575
47688
  protocol: deps.protocol,
47576
47689
  store: deps.historyStore,
47577
47690
  publishReadHooks: deps.readStatusHookPublisher
47578
- } : void 0, logCtx, historyOwnerId, appwriteApiKey, envSelector, traceId, gatewayAuth, temporaryFrontendAppId));
47691
+ } : void 0, logCtx, historyOwnerId, appwriteApiKey, envSelector, traceId, gatewayAuth, frontendAppId));
47579
47692
  }
47580
47693
  if (operation === ASR_CREATE_CREDENTIAL_OPERATION) {
47581
47694
  return observe(() => runAsrCredential(method, env, historyOwnerId, deps?.protocol?.agentId ?? getBakedProtocol().agentId, void 0, envSelector, gatewayAuth, logCtx));
@@ -47606,7 +47719,7 @@ async function runGateway(method, bodyJSON, env, deps, logCtx, historyOwnerId, a
47606
47719
  if (operation) {
47607
47720
  return observe(() => jsonError(400, "operation_unsupported", `\u4E0D\u652F\u6301\u7684 operation: ${operation}`));
47608
47721
  }
47609
- return observe(() => runChat(method, bodyJSON, env, deps, logCtx, historyOwnerId, appwriteApiKey, envSelector, traceId, gatewayAuth, temporaryFrontendAppId, otelTraceId));
47722
+ return observe(() => runChat(method, bodyJSON, env, deps, logCtx, historyOwnerId, appwriteApiKey, envSelector, traceId, gatewayAuth, frontendAppId, otelTraceId));
47610
47723
  }
47611
47724
  async function chat(ctx) {
47612
47725
  let result;
@@ -47624,9 +47737,9 @@ async function chat(ctx) {
47624
47737
  } else {
47625
47738
  const envSelector = readEnvSelector(ctx.req.headers);
47626
47739
  const traceId = readTraceId(ctx.req.headers);
47627
- const temporaryFrontendAppId = readTemporaryFrontendAppId(ctx.req.headers);
47740
+ const frontendAppId = readFrontendAppId(ctx.req.headers);
47628
47741
  const gatewayAuth = historyOwnerId ? resolveLinkqueGatewayRequestAuth(ctx.req.headers, process.env, logCtx) : void 0;
47629
- result = historyOwnerId ? await runGateway(ctx.req.method, bodyJSON, process.env, void 0, logCtx, historyOwnerId, appwriteApiKey, envSelector, traceId, gatewayAuth, temporaryFrontendAppId, readMcpPhoneAuthorization(ctx.req.headers), otelTraceIdResult.kind === "valid" ? otelTraceIdResult.traceId : void 0) : jsonError(401, "authentication_required", "\u7F3A\u5C11 Appwrite \u8BA4\u8BC1\u7528\u6237");
47742
+ result = historyOwnerId ? await runGateway(ctx.req.method, bodyJSON, process.env, void 0, logCtx, historyOwnerId, appwriteApiKey, envSelector, traceId, gatewayAuth, frontendAppId, readMcpPhoneAuthorization(ctx.req.headers), otelTraceIdResult.kind === "valid" ? otelTraceIdResult.traceId : void 0) : jsonError(401, "authentication_required", "\u7F3A\u5C11 Appwrite \u8BA4\u8BC1\u7528\u6237");
47630
47743
  }
47631
47744
  } catch (err2) {
47632
47745
  logCtx?.error?.(err2);
@@ -3,11 +3,11 @@ import {
3
3
  runClientCapability,
4
4
  runClientCapabilityCleanup,
5
5
  runClientCapabilityResult
6
- } from "../../chunk-EHNI5TX3.js";
6
+ } from "../../chunk-YJPCNMFN.js";
7
7
  import "../../chunk-IWOFD643.js";
8
8
  import "../../chunk-PXCGFBV5.js";
9
9
  import "../../chunk-ETG6PNHQ.js";
10
- import "../../chunk-DPHKD4SK.js";
10
+ import "../../chunk-WO3KBDHU.js";
11
11
  import "../../chunk-EAODRPW4.js";
12
12
  import "../../chunk-GTEZTRCK.js";
13
13
  import "../../chunk-6POVPTQH.js";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  getBakedProtocol,
3
3
  setBakedProtocol
4
- } from "../chunk-3J4AB676.js";
5
- import "../chunk-DPHKD4SK.js";
4
+ } from "../chunk-A3WEBQGR.js";
5
+ import "../chunk-WO3KBDHU.js";
6
6
  import "../chunk-EAODRPW4.js";
7
7
  import "../chunk-GTEZTRCK.js";
8
8
  import "../chunk-6POVPTQH.js";