linkque-cli-v2 1.4.3 → 1.4.4

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/worker.js CHANGED
@@ -45,7 +45,6 @@ var init_types = __esm({
45
45
  EDebugLogScope2["LLM"] = "LLM";
46
46
  EDebugLogScope2["PI_EVENT"] = "PI_EVENT";
47
47
  EDebugLogScope2["MCP"] = "MCP";
48
- EDebugLogScope2["SKILL"] = "SKILL";
49
48
  EDebugLogScope2["HTTP"] = "HTTP";
50
49
  EDebugLogScope2["HOOK"] = "HOOK";
51
50
  })(EDebugLogScope || (EDebugLogScope = {}));
@@ -4362,14 +4361,13 @@ var require_fast_uri = __commonJS({
4362
4361
  if (!malformedIPLiteral) {
4363
4362
  malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP2);
4364
4363
  }
4365
- if (uri.indexOf("%") !== -1 && parsed.host !== void 0 && !malformedIPLiteral) {
4366
- let host = isIP2 ? parsed.host : normalizePercentEncoding(parsed.host, true);
4367
- if (!isIP2) {
4368
- host = normalizePercentEncoding(host.toLowerCase());
4369
- }
4370
- parsed.host = reescapeHostDelimiters(host, isIP2);
4371
- }
4372
4364
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
4365
+ if (uri.indexOf("%") !== -1) {
4366
+ if (parsed.host !== void 0 && !malformedIPLiteral) {
4367
+ const host = isIP2 ? parsed.host : normalizePercentEncoding(parsed.host, true);
4368
+ parsed.host = reescapeHostDelimiters(host, isIP2);
4369
+ }
4370
+ }
4373
4371
  if (parsed.path) {
4374
4372
  parsed.path = normalizePathEncoding(parsed.path);
4375
4373
  }
@@ -12017,10 +12015,6 @@ var init_mcpProxyTool = __esm({
12017
12015
  context: context2
12018
12016
  });
12019
12017
  return entry.server.callTool(tool.name, args, sig, {
12020
- toolSchema: {
12021
- inputSchema: tool.inputSchema,
12022
- outputSchema: tool.outputSchema
12023
- },
12024
12018
  ...headers ? { headers } : {},
12025
12019
  ...context2 ? { context: context2 } : {}
12026
12020
  });
@@ -12268,10 +12262,6 @@ ${formatSchema(tool.inputSchema)}`);
12268
12262
  context: context2
12269
12263
  });
12270
12264
  const result = await entry.server.callTool(tool.name, args, signal, {
12271
- toolSchema: {
12272
- inputSchema: tool.inputSchema,
12273
- outputSchema: tool.outputSchema
12274
- },
12275
12265
  ...headers ? { headers } : {},
12276
12266
  ...context2 ? { context: context2 } : {}
12277
12267
  });
@@ -12637,7 +12627,7 @@ var init_hookRegistry = __esm({
12637
12627
  });
12638
12628
 
12639
12629
  // ../linkque-agent-protocol/dist/esm/telemetry/telemetryEnums.js
12640
- var ETelemetryAttribute, ETelemetryEventPrefix, ETelemetryEventPhase, ETelemetryEventName, ETelemetryContentSection, ETelemetryOperationName, ETelemetryOutcome, ETelemetrySignal, ETelemetryLossReason, ETelemetryAdvanceOutcome, ETelemetryStreamTermination, ETelemetryCancelSource, ETelemetryObservationBoundary, ETelemetryRemoteCompletion, ETelemetryCommitStatus, ETelemetryHookMode, ETelemetryHookResult, ETelemetrySource, ETelemetryEvidence, ETelemetryCompleteness, ETelemetryCoverage, ETelemetryUsageSource, ETelemetryAttemptVisibility, ETelemetryLinkRelation, ETelemetryToolFailureStage, ETelemetryTerminalEvidence, ETelemetryTerminalSource, ETelemetryModelPurpose, ETelemetryErrorType, ETelemetrySpanKind, ETelemetryGenAiOperation, ETelemetryVersion;
12630
+ var ETelemetryAttribute, ETelemetryEventPrefix, ETelemetryEventPhase, ETelemetryEventName, ETelemetryOperationName, ETelemetryOutcome, ETelemetrySignal, ETelemetryLossReason, ETelemetryAdvanceOutcome, ETelemetryStreamTermination, ETelemetryCancelSource, ETelemetryObservationBoundary, ETelemetryRemoteCompletion, ETelemetryCommitStatus, ETelemetryHookMode, ETelemetryHookResult, ETelemetrySource, ETelemetryEvidence, ETelemetryCompleteness, ETelemetryCoverage, ETelemetryUsageSource, ETelemetryAttemptVisibility, ETelemetryLinkRelation, ETelemetryToolFailureStage, ETelemetryTerminalEvidence, ETelemetryTerminalSource, ETelemetryModelPurpose, ETelemetryErrorType, ETelemetrySpanKind, ETelemetryGenAiOperation, ETelemetryVersion;
12641
12631
  var init_telemetryEnums = __esm({
12642
12632
  "../linkque-agent-protocol/dist/esm/telemetry/telemetryEnums.js"() {
12643
12633
  "use strict";
@@ -12796,20 +12786,7 @@ var init_telemetryEnums = __esm({
12796
12786
  ETelemetryEventName2["HISTORY_APPEND_FINISHED"] = "linkque.history.append.finished";
12797
12787
  ETelemetryEventName2["HOOK_DRAIN_STARTED"] = "linkque.hook.drain.started";
12798
12788
  ETelemetryEventName2["HOOK_DRAIN_FINISHED"] = "linkque.hook.drain.finished";
12799
- ETelemetryEventName2["DEBUG_CONTENT_RECORDED"] = "linkque.debug.content.recorded";
12800
12789
  })(ETelemetryEventName || (ETelemetryEventName = {}));
12801
- (function(ETelemetryContentSection2) {
12802
- ETelemetryContentSection2["QUERY_INPUT"] = "query.input";
12803
- ETelemetryContentSection2["TOOL_INPUT"] = "tool.input";
12804
- ETelemetryContentSection2["TOOL_OUTPUT"] = "tool.output";
12805
- ETelemetryContentSection2["MCP_REQUESTED_INPUT"] = "mcp.requested_input";
12806
- ETelemetryContentSection2["MCP_INPUT"] = "mcp.input";
12807
- ETelemetryContentSection2["MCP_OUTPUT"] = "mcp.output";
12808
- ETelemetryContentSection2["SKILL_INPUT"] = "skill.input";
12809
- ETelemetryContentSection2["SKILL_OUTPUT"] = "skill.output";
12810
- ETelemetryContentSection2["KNOWLEDGE_INPUT"] = "knowledge.input";
12811
- ETelemetryContentSection2["KNOWLEDGE_OUTPUT"] = "knowledge.output";
12812
- })(ETelemetryContentSection || (ETelemetryContentSection = {}));
12813
12790
  (function(ETelemetryOperationName2) {
12814
12791
  ETelemetryOperationName2["OPERATION"] = "linkque.operation";
12815
12792
  ETelemetryOperationName2["TOOL_INVOKE"] = "harness.tool.invoke";
@@ -14207,43 +14184,6 @@ var init_linkquegwEventHookExecutor = __esm({
14207
14184
  }
14208
14185
  });
14209
14186
 
14210
- // ../linkque-agent-runtime/dist/esm/core/telemetry/contentRecording.js
14211
- function recordContentSection(observation, section, value, availability = "available") {
14212
- observation?.record(ETelemetryEventName.DEBUG_CONTENT_RECORDED, {}, { section, value, availability });
14213
- }
14214
- function recordMcpContentSection(observation, section, value, schema) {
14215
- if (!observation)
14216
- return;
14217
- const fieldTitles = {};
14218
- const visit = (node, path9) => {
14219
- if (!node || typeof node !== "object" || Array.isArray(node))
14220
- return;
14221
- const definition = node;
14222
- if (path9 && typeof definition.title === "string" && definition.title.trim())
14223
- fieldTitles[path9] = definition.title;
14224
- const properties = definition.properties;
14225
- if (properties && typeof properties === "object" && !Array.isArray(properties)) {
14226
- for (const [key, child] of Object.entries(properties))
14227
- visit(child, `${path9}/${key.replaceAll("~", "~0").replaceAll("/", "~1")}`);
14228
- }
14229
- if (definition.items)
14230
- visit(definition.items, `${path9}/*`);
14231
- };
14232
- visit(schema, section === ETelemetryContentSection.MCP_OUTPUT ? "/structuredContent" : "");
14233
- observation.record(ETelemetryEventName.DEBUG_CONTENT_RECORDED, {}, {
14234
- section,
14235
- value,
14236
- availability: "available",
14237
- ...Object.keys(fieldTitles).length ? { fieldTitles } : {}
14238
- });
14239
- }
14240
- var init_contentRecording = __esm({
14241
- "../linkque-agent-runtime/dist/esm/core/telemetry/contentRecording.js"() {
14242
- "use strict";
14243
- init_telemetry();
14244
- }
14245
- });
14246
-
14247
14187
  // ../linkque-agent-runtime/dist/esm/core/skillTools.js
14248
14188
  function parseSkillFile(raw, fallbackName) {
14249
14189
  const parsed = splitFrontmatter(raw);
@@ -14312,45 +14252,18 @@ function createActivateSkillTool(records) {
14312
14252
  required: ["name"],
14313
14253
  additionalProperties: false
14314
14254
  },
14315
- execute: async (args, _signal, context2) => {
14255
+ execute: async (args) => {
14316
14256
  const name = extractName(args);
14317
- const startedAt = Date.now();
14318
- const obs = context2?.observation;
14319
- recordContentSection(obs, ETelemetryContentSection.SKILL_INPUT, {
14320
- name: name ?? null
14321
- });
14322
- if (!name) {
14323
- recordContentSection(obs, ETelemetryContentSection.SKILL_OUTPUT, {
14324
- status: "failed",
14325
- error: "\u7F3A\u5C11 name \u53C2\u6570",
14326
- durationMs: Date.now() - startedAt
14327
- });
14257
+ if (!name)
14328
14258
  return "\u6FC0\u6D3B\u6280\u80FD\u5931\u8D25:\u7F3A\u5C11 name \u53C2\u6570\u3002";
14329
- }
14330
14259
  if (!bodyByName.has(name)) {
14331
- recordContentSection(obs, ETelemetryContentSection.SKILL_OUTPUT, {
14332
- name,
14333
- status: "failed",
14334
- error: `\u672A\u627E\u5230\u6280\u80FD "${name}"`,
14335
- durationMs: Date.now() - startedAt
14336
- });
14337
14260
  return `\u6FC0\u6D3B\u6280\u80FD\u5931\u8D25:\u672A\u627E\u5230\u6280\u80FD "${name}"\u3002\u53EF\u7528:${[...bodyByName.keys()].join(", ")}`;
14338
14261
  }
14339
14262
  if (activated.has(name)) {
14340
- recordContentSection(obs, ETelemetryContentSection.SKILL_OUTPUT, {
14341
- name,
14342
- status: "already_loaded",
14343
- durationMs: Date.now() - startedAt
14344
- });
14345
14263
  return `\u6280\u80FD "${name}" \u5DF2\u5728\u672C\u8F6E\u52A0\u8F7D,\u65E0\u9700\u91CD\u590D\u6FC0\u6D3B\u3002`;
14346
14264
  }
14347
14265
  activated.add(name);
14348
14266
  const body = bodyByName.get(name) ?? "";
14349
- recordContentSection(obs, ETelemetryContentSection.SKILL_OUTPUT, {
14350
- name,
14351
- status: "loaded",
14352
- durationMs: Date.now() - startedAt
14353
- });
14354
14267
  return `<skill name="${escapeXml(name)}">
14355
14268
  ${body}
14356
14269
  </skill>`;
@@ -14408,8 +14321,6 @@ var ACTIVATE_SKILL_TOOL_NAME, AVAILABLE_SKILLS_OPEN, AVAILABLE_SKILLS_CLOSE;
14408
14321
  var init_skillTools = __esm({
14409
14322
  "../linkque-agent-runtime/dist/esm/core/skillTools.js"() {
14410
14323
  "use strict";
14411
- init_telemetry();
14412
- init_contentRecording();
14413
14324
  ACTIVATE_SKILL_TOOL_NAME = "activate_skill";
14414
14325
  AVAILABLE_SKILLS_OPEN = "<available_skills>";
14415
14326
  AVAILABLE_SKILLS_CLOSE = "</available_skills>";
@@ -14637,7 +14548,7 @@ function createKnowledgeTools(resources, searchPort, agentId) {
14637
14548
  additionalProperties: false
14638
14549
  },
14639
14550
  annotations: { readOnlyHint: true },
14640
- execute: (_args, _signal, context2) => listKnowledge(context2)
14551
+ execute: () => listKnowledge()
14641
14552
  },
14642
14553
  {
14643
14554
  name: KNOWLEDGE_RECALL_TOOL_NAME,
@@ -14664,48 +14575,24 @@ function createKnowledgeTools(resources, searchPort, agentId) {
14664
14575
  additionalProperties: false
14665
14576
  },
14666
14577
  annotations: { readOnlyHint: true },
14667
- execute: (args, signal, context2) => recallKnowledge(args, signal, context2)
14578
+ execute: (args, signal) => recallKnowledge(args, signal)
14668
14579
  }
14669
14580
  ];
14670
- async function listKnowledge(context2) {
14671
- const result = { knowledgeBases: await getKnowledgeBases() };
14672
- recordContentSection(context2?.observation, ETelemetryContentSection.KNOWLEDGE_OUTPUT, {
14673
- knowledgeBases: result.knowledgeBases.map((kb) => ({
14674
- knowledgeBaseId: kb.knowledgeBaseId,
14675
- knowledgeDesc: kb.knowledgeDesc
14676
- }))
14677
- });
14678
- return result;
14581
+ async function listKnowledge() {
14582
+ return { knowledgeBases: await getKnowledgeBases() };
14679
14583
  }
14680
- async function recallKnowledge(args, signal, context2) {
14584
+ async function recallKnowledge(args, signal) {
14681
14585
  const parsed = parseRecallArgs(args);
14682
- const obs = context2?.observation;
14683
14586
  if ("error" in parsed) {
14684
- recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_INPUT, {
14685
- error: parsed.error
14686
- });
14687
- recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_OUTPUT, {
14688
- status: "failed",
14689
- hits: [],
14690
- error: parsed.error
14691
- });
14692
14587
  return { hits: [], error: parsed.error };
14693
14588
  }
14694
- recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_INPUT, {
14695
- knowledgeBaseId: parsed.knowledgeBaseId,
14696
- query: parsed.query,
14697
- topK: parsed.topK
14698
- });
14699
14589
  const knowledgeBases = await getKnowledgeBases();
14700
14590
  const bound = knowledgeBases.some((info) => info.knowledgeBaseId === parsed.knowledgeBaseId);
14701
14591
  if (!bound) {
14702
- const error40 = `knowledgeBaseId \u672A\u7ED1\u5B9A: ${parsed.knowledgeBaseId}\u3002\u8BF7\u5148\u8C03\u7528 knowledge_list \u67E5\u770B\u53EF\u7528\u77E5\u8BC6\u5E93\u3002`;
14703
- recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_OUTPUT, {
14704
- status: "failed",
14592
+ return {
14705
14593
  hits: [],
14706
- error: error40
14707
- });
14708
- return { hits: [], error: error40 };
14594
+ error: `knowledgeBaseId \u672A\u7ED1\u5B9A: ${parsed.knowledgeBaseId}\u3002\u8BF7\u5148\u8C03\u7528 knowledge_list \u67E5\u770B\u53EF\u7528\u77E5\u8BC6\u5E93\u3002`
14595
+ };
14709
14596
  }
14710
14597
  try {
14711
14598
  const result = await searchPort.search({
@@ -14714,20 +14601,10 @@ function createKnowledgeTools(resources, searchPort, agentId) {
14714
14601
  agentId,
14715
14602
  topK: parsed.topK
14716
14603
  }, signal);
14717
- recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_OUTPUT, {
14718
- status: result.hits.length ? "matched" : "no_hits",
14719
- hits: result.hits
14720
- });
14721
14604
  return { hits: result.hits };
14722
14605
  } catch (e2) {
14723
14606
  const msg = e2 instanceof Error ? e2.message : String(e2);
14724
- const error40 = `\u77E5\u8BC6\u5E93\u68C0\u7D22\u5931\u8D25: ${msg}`;
14725
- recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_OUTPUT, {
14726
- status: "failed",
14727
- hits: [],
14728
- error: error40
14729
- });
14730
- return { hits: [], error: error40 };
14607
+ return { hits: [], error: `\u77E5\u8BC6\u5E93\u68C0\u7D22\u5931\u8D25: ${msg}` };
14731
14608
  }
14732
14609
  }
14733
14610
  async function getKnowledgeBases() {
@@ -14741,8 +14618,6 @@ var init_createKnowledgeTools = __esm({
14741
14618
  "../linkque-agent-runtime/dist/esm/core/createKnowledgeTools.js"() {
14742
14619
  "use strict";
14743
14620
  init_knowledgeTools();
14744
- init_telemetry();
14745
- init_contentRecording();
14746
14621
  }
14747
14622
  });
14748
14623
 
@@ -14773,7 +14648,7 @@ var init_noopRuntimeTelemetry = __esm({
14773
14648
  startOperation(_operation) {
14774
14649
  return this;
14775
14650
  }
14776
- record(_name, _attributes, _body) {
14651
+ record(_name, _attributes) {
14777
14652
  }
14778
14653
  finish(_outcome, _attributes) {
14779
14654
  }
@@ -14871,7 +14746,7 @@ var init_runtimeObservation = __esm({
14871
14746
  find(key) {
14872
14747
  return this.associations.get(key);
14873
14748
  }
14874
- record(name, attributes, body) {
14749
+ record(name, attributes) {
14875
14750
  if (this.abandoned)
14876
14751
  return;
14877
14752
  try {
@@ -14879,7 +14754,7 @@ var init_runtimeObservation = __esm({
14879
14754
  this.resultAttributes = {
14880
14755
  [ETelemetryAttribute.LINKQUE_TOOL_FAILURE_STAGE]: attributes[ETelemetryAttribute.LINKQUE_TOOL_FAILURE_STAGE]
14881
14756
  };
14882
- this.sink.record(name, attributes, body);
14757
+ this.sink.record(name, attributes);
14883
14758
  } catch {
14884
14759
  }
14885
14760
  }
@@ -49206,19 +49081,8 @@ function observeTool(tool, observation) {
49206
49081
  detached: false,
49207
49082
  links: []
49208
49083
  });
49209
- const captureBody = !isSkillTool(tool);
49210
49084
  try {
49211
- if (captureBody) {
49212
- recordContentSection(operation, ETelemetryContentSection.TOOL_INPUT, args);
49213
- }
49214
- const execContext = {
49215
- ...context2 ?? { toolCallId: "", emit: () => void 0 },
49216
- observation: operation
49217
- };
49218
- const result = await tool.execute(args, signal, execContext);
49219
- if (captureBody) {
49220
- recordContentSection(operation, ETelemetryContentSection.TOOL_OUTPUT, result);
49221
- }
49085
+ const result = await tool.execute(args, signal, context2);
49222
49086
  operation.finish(toolResultOutcome(result), {
49223
49087
  [ETelemetryAttribute.HARNESS_TOOL_RESULT_STATUS]: toolResultOutcome(result)
49224
49088
  });
@@ -49236,16 +49100,13 @@ function observeTool(tool, observation) {
49236
49100
  }
49237
49101
  };
49238
49102
  }
49239
- var import_node_crypto6, isSkillTool;
49103
+ var import_node_crypto6;
49240
49104
  var init_toolObservation = __esm({
49241
49105
  "../linkque-agent-runtime/dist/esm/core/telemetry/toolObservation.js"() {
49242
49106
  "use strict";
49243
49107
  init_telemetry();
49244
49108
  init_telemetryEnums2();
49245
- init_skillTools();
49246
49109
  import_node_crypto6 = require("node:crypto");
49247
- init_contentRecording();
49248
- isSkillTool = (tool) => (tool.modelName ?? tool.name) === ACTIVATE_SKILL_TOOL_NAME;
49249
49110
  }
49250
49111
  });
49251
49112
 
@@ -207561,36 +207422,11 @@ var init_agentRuntime = __esm({
207561
207422
  }
207562
207423
  }, (observation) => this.runObservedAdvance(request, auth2, options, observation), options.signal);
207563
207424
  }
207564
- /**
207565
- * 记录本次用户输入(RFC §4.1):取进入 Runtime 的本次新消息中最后一条 user message
207566
- * 的 content,作为 `linkque.debug.content.recorded` 的 body 走 record 链路落入
207567
- * OTLP logs(body 含 section/value/availability)。不以模型 messages 上下文为输入;
207568
- * 无 user 文本(卡片交互等)时按可用性如实标记,不伪造自然语言 Query。
207569
- */
207570
- recordCurrentQuery(observation, request) {
207571
- let lastUser;
207572
- for (const message of request.messages) {
207573
- if (message.role === "user")
207574
- lastUser = message;
207575
- }
207576
- const content = lastUser?.content;
207577
- const text2 = typeof content === "string" && content ? content : void 0;
207578
- const card = content && typeof content === "object" && "type" in content && content.type === "a2ui.event" ? content : void 0;
207579
- const displayText = card && "displayText" in card && typeof card.displayText === "string" && card.displayText ? card.displayText : void 0;
207580
- const body = {
207581
- section: ETelemetryContentSection.QUERY_INPUT,
207582
- ...text2 !== void 0 ? { value: text2 } : {},
207583
- ...card ? { inputType: "card", ...displayText ? { displayText } : {} } : {},
207584
- availability: text2 !== void 0 || card ? "available" : "not_recorded"
207585
- };
207586
- observation.record(ETelemetryEventName.DEBUG_CONTENT_RECORDED, {}, body);
207587
- }
207588
207425
  async *runObservedAdvance(request, auth2, options, observation) {
207589
207426
  observation.record(ETelemetryEventName.TELEMETRY_COVERAGE, {
207590
207427
  [ETelemetryAttribute.LINKQUE_TELEMETRY_COVERAGE]: this.agentLoop instanceof PiAgentLoop ? ETelemetryCoverage.PI_MODEL_TOOL_HOOK : ETelemetryCoverage.CORE_ONLY,
207591
207428
  [ETelemetryAttribute.HARNESS_TELEMETRY_COMPLETENESS]: this.agentLoop instanceof PiAgentLoop ? ETelemetryCompleteness.COMPLETE : ETelemetryCompleteness.PARTIAL
207592
207429
  });
207593
- this.recordCurrentQuery(observation, request);
207594
207430
  const cleanup = [];
207595
207431
  let termination = ETelemetryStreamTermination.CANCEL;
207596
207432
  let failed = false;
@@ -208695,22 +208531,6 @@ var EModelRequestSource;
208695
208531
 
208696
208532
  // ../linkque-agent-runtime/dist/esm/core/index.js
208697
208533
  init_types();
208698
-
208699
- // ../linkque-agent-runtime/dist/esm/core/debugLog.js
208700
- init_types();
208701
- function isDebugLoggingEnabled(level) {
208702
- return level?.trim().toLowerCase() === "debug";
208703
- }
208704
- function createRuntimeDebugLog(level, sink) {
208705
- const debug = isDebugLoggingEnabled(level);
208706
- return (line, scope) => {
208707
- if (!debug && (scope === EDebugLogScope.PI_EVENT || scope === EDebugLogScope.HTTP || scope === EDebugLogScope.MCP || scope === EDebugLogScope.SKILL))
208708
- return;
208709
- sink(line, scope);
208710
- };
208711
- }
208712
-
208713
- // ../linkque-agent-runtime/dist/esm/core/index.js
208714
208534
  init_esm();
208715
208535
  init_cardTools();
208716
208536
  init_mcpNaming();
@@ -214705,10 +214525,6 @@ init_esm();
214705
214525
 
214706
214526
  // ../linkque-agent-runtime/dist/esm/impl/mcp/alipay/remoteGatewayMcpServer.js
214707
214527
  var import_node_async_hooks2 = require("node:async_hooks");
214708
- init_telemetry();
214709
- init_logFailure();
214710
- init_contentRecording();
214711
- init_types();
214712
214528
 
214713
214529
  // ../linkque-agent-runtime/dist/esm/impl/mcp/alipay/linkquegwTokenVerifier.js
214714
214530
  init_config();
@@ -214755,6 +214571,8 @@ var LinkquegwTokenVerifier = class {
214755
214571
  };
214756
214572
 
214757
214573
  // ../linkque-agent-runtime/dist/esm/impl/mcp/alipay/remoteGatewayMcpServer.js
214574
+ init_types();
214575
+ init_logFailure();
214758
214576
  var defaultCreateSigner = (config2, getAuthorizationHeader, debugLog) => new RemoteSignatureSigner({
214759
214577
  agentId: config2.agentId,
214760
214578
  signEndpoint: config2.signEndpoint,
@@ -214805,14 +214623,7 @@ var RemoteGatewayMcpServerProvider = class {
214805
214623
  if (!this.debugLog)
214806
214624
  return;
214807
214625
  try {
214808
- this.debugLog(`[mcp-client] ${JSON.stringify({
214809
- serverName,
214810
- resourceId: resource.resourceId,
214811
- requestId,
214812
- method,
214813
- phase,
214814
- payload: this.invocationContext.current()?.auth ? { redacted: true } : payload
214815
- })}`, EDebugLogScope.MCP);
214626
+ this.debugLog(`[mcp-client] ${JSON.stringify({ serverName, resourceId: resource.resourceId, requestId, method, phase, payload: this.invocationContext.current()?.auth ? { redacted: true } : payload })}`, EDebugLogScope.MCP);
214816
214627
  } catch (error40) {
214817
214628
  warnLogFailure("remoteGatewayMcpServer.log", error40);
214818
214629
  }
@@ -214832,8 +214643,6 @@ var RemoteGatewayMcpServerProvider = class {
214832
214643
  callTool: (params, resultSchema, requestOptions) => request("tools/call", params, () => client.callTool(params, resultSchema, requestOptions))
214833
214644
  };
214834
214645
  const callTool = (name, args, signal, options) => callHeaders.run(options?.headers ?? {}, () => this.invocationContext.run(timeoutMs, signal, async (invocation) => {
214835
- const observation = options?.context?.observation;
214836
- recordMcpContentSection(observation, ETelemetryContentSection.MCP_REQUESTED_INPUT, args, options?.toolSchema?.inputSchema);
214837
214646
  const plan = createArgsMappingPlan(name, args, argsMappingRules);
214838
214647
  if (plan.requiresUserId) {
214839
214648
  if (config2.signEndpoint !== void 0 && config2.signEndpoint !== DEFAULT_SIGN_ENDPOINT && !config2.verifyTokenEndpoint?.trim())
@@ -214856,18 +214665,15 @@ var RemoteGatewayMcpServerProvider = class {
214856
214665
  };
214857
214666
  }
214858
214667
  const mapped = resolveArgsMappingPlan(plan, invocation.auth);
214859
- recordMcpContentSection(observation, ETelemetryContentSection.MCP_INPUT, mapped, options?.toolSchema?.inputSchema);
214860
214668
  invocation.signal.throwIfAborted();
214861
214669
  const remaining = Math.max(1, invocation.deadline - performance.now());
214862
214670
  try {
214863
- const result = await loggedClient.callTool({ name, arguments: mapped }, void 0, {
214671
+ return await loggedClient.callTool({ name, arguments: mapped }, void 0, {
214864
214672
  signal: invocation.signal,
214865
214673
  timeout: remaining,
214866
214674
  maxTotalTimeout: remaining,
214867
214675
  resetTimeoutOnProgress: false
214868
214676
  });
214869
- recordMcpContentSection(observation, ETelemetryContentSection.MCP_OUTPUT, result, options?.toolSchema?.outputSchema);
214870
- return result;
214871
214677
  } catch (error40) {
214872
214678
  invocation.signal.throwIfAborted();
214873
214679
  if (invocation.auth && !(error40 instanceof McpInvocationError))
@@ -214896,13 +214702,7 @@ async function listToolsFromClient(client, resourceId, callTool) {
214896
214702
  const descriptor = {
214897
214703
  name: tool.name,
214898
214704
  resourceId,
214899
- execute: (args, signal, context2) => callTool(tool.name, args, signal, {
214900
- context: context2,
214901
- toolSchema: {
214902
- inputSchema: tool.inputSchema,
214903
- outputSchema: tool.outputSchema
214904
- }
214905
- })
214705
+ execute: (args, signal) => callTool(tool.name, args, signal)
214906
214706
  };
214907
214707
  if (tool.description !== void 0)
214908
214708
  descriptor.description = tool.description;
@@ -215253,8 +215053,6 @@ function parseResponse(body, query, topK) {
215253
215053
  }
215254
215054
 
215255
215055
  // ../linkque-agent-runtime/dist/esm/impl/mcp/localHttpMcpServerProvider.js
215256
- init_telemetry();
215257
- init_contentRecording();
215258
215056
  init_httpLoggingFetch();
215259
215057
  var LocalHttpMcpServerProvider = class {
215260
215058
  baseUrl;
@@ -215283,7 +215081,7 @@ var LocalHttpMcpServerProvider = class {
215283
215081
  }
215284
215082
  return body.tools.map((value) => this.createDescriptor(resource.resourceId, value));
215285
215083
  },
215286
- callTool: (name, args, signal, options) => this.callTool(resource.resourceId, name, args, signal, options)
215084
+ callTool: (name, args, signal) => this.callTool(resource.resourceId, name, args, signal)
215287
215085
  };
215288
215086
  }
215289
215087
  createDescriptor(resourceId, value) {
@@ -215297,28 +215095,17 @@ var LocalHttpMcpServerProvider = class {
215297
215095
  ...isRecord2(value.inputSchema) ? { inputSchema: value.inputSchema } : {},
215298
215096
  ...isRecord2(value.outputSchema) ? { outputSchema: value.outputSchema } : {},
215299
215097
  ...isRecord2(value.annotations) ? { annotations: value.annotations } : {},
215300
- execute: (args, signal, context2) => this.callTool(resourceId, value.name, args, signal, {
215301
- context: context2,
215302
- toolSchema: {
215303
- inputSchema: value.inputSchema,
215304
- outputSchema: value.outputSchema
215305
- }
215306
- })
215098
+ execute: (args, signal) => this.callTool(resourceId, value.name, args, signal)
215307
215099
  };
215308
215100
  }
215309
- async callTool(resourceId, toolName, args, signal, options) {
215310
- const observation = options?.context?.observation;
215311
- recordMcpContentSection(observation, ETelemetryContentSection.MCP_REQUESTED_INPUT, args, options?.toolSchema?.inputSchema);
215312
- recordMcpContentSection(observation, ETelemetryContentSection.MCP_INPUT, args, options?.toolSchema?.inputSchema);
215101
+ async callTool(resourceId, toolName, args, signal) {
215313
215102
  const response = await this.fetchImpl(this.resourceUrl(resourceId, `tools/${encodeURIComponent(toolName)}/call`), {
215314
215103
  method: "POST",
215315
215104
  headers: { "content-type": "application/json" },
215316
215105
  body: JSON.stringify({ arguments: args }),
215317
215106
  signal
215318
215107
  });
215319
- const result = await readJsonResponse(response);
215320
- recordMcpContentSection(observation, ETelemetryContentSection.MCP_OUTPUT, result, options?.toolSchema?.outputSchema);
215321
- return result;
215108
+ return readJsonResponse(response);
215322
215109
  }
215323
215110
  resourceUrl(resourceId, suffix) {
215324
215111
  return new URL(`resources/${encodeURIComponent(resourceId)}/${suffix}`, ensureTrailingSlash(this.baseUrl));
@@ -215997,7 +215784,6 @@ function unzip(data, opts, cb) {
215997
215784
  }
215998
215785
 
215999
215786
  // ../linkque-agent-runtime/dist/esm/impl/webSkillLoader.js
216000
- init_types();
216001
215787
  init_skillTools();
216002
215788
  init_httpLoggingFetch();
216003
215789
  var ESkillUrlScheme;
@@ -216035,7 +215821,7 @@ var WebSkillLoader = class {
216035
215821
  return records.filter((record4, idx) => {
216036
215822
  if (record4 !== void 0)
216037
215823
  return true;
216038
- this.debugLog?.(`[skill] \u8DF3\u8FC7\u8D44\u6E90 ${resources[idx]?.resourceId ?? "?"}:SKILL.md \u7F3A description(\u524D\u7F6E\u65E0\u6548),\u6309 spec \u4E0D\u52A0\u8F7D`, EDebugLogScope.SKILL);
215824
+ this.debugLog?.(`[skill] \u8DF3\u8FC7\u8D44\u6E90 ${resources[idx]?.resourceId ?? "?"}:SKILL.md \u7F3A description(\u524D\u7F6E\u65E0\u6548),\u6309 spec \u4E0D\u52A0\u8F7D`);
216039
215825
  return false;
216040
215826
  });
216041
215827
  }
@@ -216696,7 +216482,7 @@ var OtelRuntimeTelemetry = class {
216696
216482
  {
216697
216483
  onEmit: (record4, ctx) => {
216698
216484
  const route = ctx?.getValue(this.routeKey);
216699
- this.output(ETelemetrySignal.LOGS, import_otlp_transformer.JsonLogsSerializer.serializeRequest([record4]), route?.route, route?.critical ?? false, route?.localOnly ?? false);
216485
+ this.output(ETelemetrySignal.LOGS, import_otlp_transformer.JsonLogsSerializer.serializeRequest([record4]), route?.route, route?.critical ?? false);
216700
216486
  },
216701
216487
  forceFlush: async () => void 0,
216702
216488
  shutdown: async () => void 0
@@ -216704,13 +216490,12 @@ var OtelRuntimeTelemetry = class {
216704
216490
  ]
216705
216491
  });
216706
216492
  }
216707
- output(signal, encoded, route, critical, localOnly = false) {
216493
+ output(signal, encoded, route, critical) {
216708
216494
  if (!encoded || this.outputActive || this.disposed)
216709
216495
  return;
216710
216496
  this.outputActive = true;
216711
216497
  try {
216712
- if (!localOnly)
216713
- this.queue.enqueue(route, signal, encoded, critical);
216498
+ this.queue.enqueue(route, signal, encoded, critical);
216714
216499
  if (this.options.localSink) {
216715
216500
  try {
216716
216501
  const payload = JSON.parse(new TextDecoder().decode(encoded));
@@ -216735,6 +216520,7 @@ var OtelRuntimeTelemetry = class {
216735
216520
  return new NoopRuntimeObservation();
216736
216521
  }
216737
216522
  const state2 = {
216523
+ agentId: input.agentId,
216738
216524
  sequence: 0,
216739
216525
  route: auth2 ? this.queue.authorize(auth2) : void 0,
216740
216526
  attributes: sanitizeTelemetryAttributes({
@@ -216790,6 +216576,7 @@ var OtelRuntimeTelemetry = class {
216790
216576
  isRemote: upstream !== null,
216791
216577
  traceState: parentContext.traceState ? createTraceState(parentContext.traceState) : void 0
216792
216578
  });
216579
+ const spanName = spec.name === ETelemetryOperationName.MODEL_ATTEMPT ? `${ETelemetryGenAiOperation.CHAT} ${spec.attributes[ETelemetryAttribute.GEN_AI_REQUEST_MODEL]}` : spec.name === ETelemetryOperationName.TOOL_INVOKE ? `${ETelemetryGenAiOperation.EXECUTE_TOOL} ${spec.attributes[ETelemetryAttribute.GEN_AI_TOOL_NAME]}` : spec.name === ETelemetryOperationName.ADVANCE && state2.agentId ? `${ETelemetryGenAiOperation.INVOKE_AGENT} ${state2.agentId}` : spec.name;
216793
216580
  const attributes = sanitizeTelemetryAttributes({
216794
216581
  ...state2.attributes,
216795
216582
  ...parent?.attributes,
@@ -216807,11 +216594,11 @@ var OtelRuntimeTelemetry = class {
216807
216594
  ETelemetryAttribute.LINKQUE_CONVERSATION_ID
216808
216595
  ].some((attribute) => attribute === key))),
216809
216596
  [ETelemetryAttribute.LINKQUE_OPERATION_ID]: (0, import_node_crypto5.randomUUID)(),
216810
- [ETelemetryAttribute.LINKQUE_OPERATION_NAME]: spec.name,
216597
+ [ETelemetryAttribute.LINKQUE_OPERATION_NAME]: spanName,
216811
216598
  [ETelemetryAttribute.LINKQUE_OPERATION_PARENT_ID]: spec.detached ? "" : parent?.operationId ?? "",
216812
216599
  [ETelemetryAttribute.LINKQUE_SPAN_PARENT_ID]: spec.detached ? "" : parentContext?.spanId ?? ""
216813
216600
  });
216814
- const span = this.tracerProvider.getTracer(ETelemetryMetadata.SCOPE_NAME, ETelemetryVersion.V1_0).startSpan(spec.name, {
216601
+ const span = this.tracerProvider.getTracer(ETelemetryMetadata.SCOPE_NAME, ETelemetryVersion.V1_0).startSpan(spanName.slice(0, 256), {
216815
216602
  kind: spec.name === ETelemetryOperationName.MODEL_ATTEMPT ? SpanKind.CLIENT : SpanKind.INTERNAL,
216816
216603
  attributes,
216817
216604
  links: spec.links.filter((link) => validContext(link.context)).slice(0, 16).map((link) => ({
@@ -216839,7 +216626,7 @@ var OtelRuntimeTelemetry = class {
216839
216626
  operation.record(`${spec.eventPrefix}.${ETelemetryEventPhase.STARTED}`, {});
216840
216627
  return operation;
216841
216628
  }
216842
- emit(operation, name, attributes, critical, body) {
216629
+ emit(operation, name, attributes, critical) {
216843
216630
  if (this.disposed || this.queue.isExporting)
216844
216631
  return;
216845
216632
  const contextAttributes = operation.attributes;
@@ -216866,24 +216653,18 @@ var OtelRuntimeTelemetry = class {
216866
216653
  Math.floor(now / 1e3),
216867
216654
  now % 1e3 * 1e6
216868
216655
  ];
216869
- const localOnly = name === ETelemetryEventName.DEBUG_CONTENT_RECORDED;
216870
- if (!localOnly && operation.span.isRecording())
216656
+ if (operation.span.isRecording())
216871
216657
  operation.span.addEvent(
216872
216658
  name,
216873
216659
  // 复用已投影的属性;Span 已持有上下文,事件只保留本次事实及去重字段。
216874
216660
  Object.fromEntries(Object.entries(record4).filter(([key]) => Object.hasOwn(attributes, key) || key === ETelemetryAttribute.HARNESS_RECORD_ID || key === ETelemetryAttribute.HARNESS_EVENT_SEQUENCE)),
216875
216661
  time3
216876
216662
  );
216877
- const ctx = trace.setSpan(ROOT_CONTEXT, operation.span).setValue(this.routeKey, {
216878
- route: operation.state.route,
216879
- critical,
216880
- localOnly
216881
- });
216663
+ const ctx = trace.setSpan(ROOT_CONTEXT, operation.span).setValue(this.routeKey, { route: operation.state.route, critical });
216882
216664
  this.loggerProvider.getLogger(ETelemetryMetadata.SCOPE_NAME, ETelemetryVersion.V1_0).emit({
216883
216665
  eventName: name,
216884
216666
  timestamp: time3,
216885
216667
  observedTimestamp: time3,
216886
- ...body !== void 0 ? { body } : {},
216887
216668
  severityNumber: record4[ETelemetryAttribute.HARNESS_OPERATION_OUTCOME] === ETelemetryOutcome.ERROR || record4[ETelemetryAttribute.HARNESS_OPERATION_OUTCOME] === ETelemetryOutcome.TIMEOUT ? import_api_logs.SeverityNumber.ERROR : import_api_logs.SeverityNumber.INFO,
216888
216669
  severityText: record4[ETelemetryAttribute.HARNESS_OPERATION_OUTCOME] === ETelemetryOutcome.ERROR || record4[ETelemetryAttribute.HARNESS_OPERATION_OUTCOME] === ETelemetryOutcome.TIMEOUT ? import_api_logs.SeverityNumber[import_api_logs.SeverityNumber.ERROR] : import_api_logs.SeverityNumber[import_api_logs.SeverityNumber.INFO],
216889
216670
  attributes: record4,
@@ -216954,11 +216735,10 @@ var OtelObservation = class {
216954
216735
  return new NoopRuntimeObservation();
216955
216736
  return this.owner.createOperation(this.state, spec, this);
216956
216737
  }
216957
- record(name, attributes, body) {
216738
+ record(name, attributes) {
216958
216739
  if (this.lost || !/^(harness|linkque)\.[a-z0-9_.]{1,128}$/.test(name))
216959
216740
  return;
216960
- const critical = name.endsWith(`.${ETelemetryEventPhase.FINISHED}`) || name === ETelemetryEventName.MODEL_USAGE_RECORDED || name === ETelemetryEventName.RUNTIME_UNCAUGHT_ERROR || name.endsWith(`.${ETelemetryEventPhase.OBSERVATION_LOST}`);
216961
- this.owner.emit(this, name, attributes, critical, body);
216741
+ this.owner.emit(this, name, attributes, name.endsWith(`.${ETelemetryEventPhase.FINISHED}`) || name === ETelemetryEventName.MODEL_USAGE_RECORDED || name === ETelemetryEventName.RUNTIME_UNCAUGHT_ERROR || name.endsWith(`.${ETelemetryEventPhase.OBSERVATION_LOST}`));
216962
216742
  }
216963
216743
  finish(outcome, attributes) {
216964
216744
  if (this.ended)
@@ -217198,7 +216978,6 @@ var OtlpFileSink = class {
217198
216978
  // src/commands/agentdev/sandboxIntegrate/sandboxRuntimeConfigProvider.ts
217199
216979
  var SANDBOX_RUNTIME_CONFIG_DEFAULTS = Object.freeze({
217200
216980
  ...RUNTIME_CONFIG_DEFAULTS,
217201
- LOG_LEVEL: "DEBUG",
217202
216981
  LINKQUE_MCP_SIGN_ENDPOINT: RUNTIME_CONFIG_DEFAULTS.LINKQUEGW_MCP_SIGN_ENDPOINT,
217203
216982
  LINKQUE_OPEN_MCP_BASE_URL: "https://opengw.alipay.com",
217204
216983
  LINKQUEGW_TELEMETRY_LOGS_ENDPOINT: `${LINKQUE_ENDPOINT_PROD}/api/telemetry/v1/logs`,
@@ -217656,7 +217435,6 @@ var fileSize = async (filePath) => {
217656
217435
  };
217657
217436
  var maskSecret = (raw) => raw ? "<set>" : "<unset>";
217658
217437
  var AGENT_ENV_SNAPSHOT = [
217659
- ["LOG_LEVEL", false],
217660
217438
  ["LINKQUE_AGENT_API_KEY", true],
217661
217439
  ["LINKQUE_AGENT_ACCESS_KEY", true],
217662
217440
  ["LINKQUE_USER_TOKEN", true],
@@ -217893,15 +217671,11 @@ var main = async () => {
217893
217671
  `[${(/* @__PURE__ */ new Date()).toISOString()}] agent worker loading agent runtime
217894
217672
  `
217895
217673
  );
217896
- const config2 = new SandboxRuntimeConfigProvider();
217897
- const debugLog = createRuntimeDebugLog(
217898
- config2.get("LOG_LEVEL"),
217899
- (line, scope) => {
217900
- const prefix = scope ? `[${scope}] ` : "";
217901
- log.write(`[${(/* @__PURE__ */ new Date()).toISOString()}]${prefix}${line}
217674
+ const debugLog = (line, scope) => {
217675
+ const prefix = scope ? `[${scope}] ` : "";
217676
+ log.write(`[${(/* @__PURE__ */ new Date()).toISOString()}]${prefix}${line}
217902
217677
  `);
217903
- }
217904
- );
217678
+ };
217905
217679
  agentDevTelemetry = await createAgentDevTelemetry(
217906
217680
  input.agentId,
217907
217681
  input.logPath,
@@ -217915,6 +217689,7 @@ var main = async () => {
217915
217689
  executeHomeData2 = executeHomeData;
217916
217690
  executeCardAction2 = executeCardAction;
217917
217691
  executeFunctionActionMcp2 = executeFunctionActionMcp;
217692
+ const config2 = new SandboxRuntimeConfigProvider();
217918
217693
  const localMcpUrl = config2.get("LINKQUE_AGENT_MCP_FIXTURE_URL");
217919
217694
  const gatewayAuthorization = resolveSandboxGatewayAuthorization(process.env);
217920
217695
  const remoteAuthorizationHeader = gatewayAuthorization ? async () => gatewayAuthorization : void 0;
@@ -217989,9 +217764,9 @@ var main = async () => {
217989
217764
  // opengw 响应头 alipay-trace-id 下沉到 agent.log(同 SSE 会话级复用,
217990
217765
  // 每会话首个 POST 上报一次有效值),供 MCP 调用链路归因排查。
217991
217766
  onTraceId: (info) => {
217992
- debugLog(
217993
- `[mcp-trace] ${info.httpMethod} ${info.requestUrl} alipay-trace-id=${info.traceId}`,
217994
- EDebugLogScope.MCP
217767
+ log.write(
217768
+ `[${(/* @__PURE__ */ new Date()).toISOString()}] [mcp-trace] ${info.httpMethod} ${info.requestUrl} alipay-trace-id=${info.traceId}
217769
+ `
217995
217770
  );
217996
217771
  },
217997
217772
  // HTTP 出站日志下沉(scope=http):tag=mcp-sign(签名服务)+ mcp-call(SSE GET/POST 工具调用)→ agent.log。