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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linkque-cli-v2",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
4
4
  "description": "Public Linkque CLI bundle for sandbox debugging",
5
5
  "bin": {
6
6
  "linkquejs": "linkquejs.js"
@@ -20,9 +20,8 @@ import {
20
20
  McpPhoneAuthorizationFailedError,
21
21
  McpPhoneAuthorizationRequiredError,
22
22
  RUNTIME_CONFIG_DEFAULTS,
23
- RuntimeConfigProvider,
24
- isDebugLoggingEnabled
25
- } from "./chunk-Y36JLYIE.js";
23
+ RuntimeConfigProvider
24
+ } from "./chunk-OHRCYI66.js";
26
25
  import {
27
26
  __commonJS,
28
27
  __require,
@@ -15294,7 +15293,7 @@ function maskEndpoint(raw) {
15294
15293
  return raw ? raw.replace(/\/+$/, "") : "<unset>";
15295
15294
  }
15296
15295
  function isDebugLogLevel(env) {
15297
- return isDebugLoggingEnabled(new AppbaseRuntimeConfigProvider(env).get("LOG_LEVEL"));
15296
+ return new AppbaseRuntimeConfigProvider(env).get("LOG_LEVEL") === "debug";
15298
15297
  }
15299
15298
  function whichSource(env, candidates) {
15300
15299
  const config = new AppbaseRuntimeConfigProvider(env);
@@ -4514,14 +4514,13 @@ var require_fast_uri = __commonJS({
4514
4514
  if (!malformedIPLiteral) {
4515
4515
  malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
4516
4516
  }
4517
- if (uri.indexOf("%") !== -1 && parsed.host !== void 0 && !malformedIPLiteral) {
4518
- let host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true);
4519
- if (!isIP) {
4520
- host = normalizePercentEncoding(host.toLowerCase());
4521
- }
4522
- parsed.host = reescapeHostDelimiters(host, isIP);
4523
- }
4524
4517
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
4518
+ if (uri.indexOf("%") !== -1) {
4519
+ if (parsed.host !== void 0 && !malformedIPLiteral) {
4520
+ const host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true);
4521
+ parsed.host = reescapeHostDelimiters(host, isIP);
4522
+ }
4523
+ }
4525
4524
  if (parsed.path) {
4526
4525
  parsed.path = normalizePathEncoding(parsed.path);
4527
4526
  }
@@ -22826,24 +22825,10 @@ var EDebugLogScope;
22826
22825
  EDebugLogScope2["LLM"] = "LLM";
22827
22826
  EDebugLogScope2["PI_EVENT"] = "PI_EVENT";
22828
22827
  EDebugLogScope2["MCP"] = "MCP";
22829
- EDebugLogScope2["SKILL"] = "SKILL";
22830
22828
  EDebugLogScope2["HTTP"] = "HTTP";
22831
22829
  EDebugLogScope2["HOOK"] = "HOOK";
22832
22830
  })(EDebugLogScope || (EDebugLogScope = {}));
22833
22831
 
22834
- // ../linkque-agent-runtime/dist/esm/core/debugLog.js
22835
- function isDebugLoggingEnabled(level) {
22836
- return level?.trim().toLowerCase() === "debug";
22837
- }
22838
- function createRuntimeDebugLog(level, sink) {
22839
- const debug = isDebugLoggingEnabled(level);
22840
- return (line, scope) => {
22841
- if (!debug && (scope === EDebugLogScope.PI_EVENT || scope === EDebugLogScope.HTTP || scope === EDebugLogScope.MCP || scope === EDebugLogScope.SKILL))
22842
- return;
22843
- sink(line, scope);
22844
- };
22845
- }
22846
-
22847
22832
  // ../linkque-agent-runtime/dist/esm/core/cardTools.js
22848
22833
  import { randomUUID } from "node:crypto";
22849
22834
 
@@ -26109,10 +26094,6 @@ var McpProxyTool = class {
26109
26094
  context: context2
26110
26095
  });
26111
26096
  return entry.server.callTool(tool.name, args, sig, {
26112
- toolSchema: {
26113
- inputSchema: tool.inputSchema,
26114
- outputSchema: tool.outputSchema
26115
- },
26116
26097
  ...headers ? { headers } : {},
26117
26098
  ...context2 ? { context: context2 } : {}
26118
26099
  });
@@ -26360,10 +26341,6 @@ ${formatSchema(tool.inputSchema)}`);
26360
26341
  context: context2
26361
26342
  });
26362
26343
  const result = await entry.server.callTool(tool.name, args, signal, {
26363
- toolSchema: {
26364
- inputSchema: tool.inputSchema,
26365
- outputSchema: tool.outputSchema
26366
- },
26367
26344
  ...headers ? { headers } : {},
26368
26345
  ...context2 ? { context: context2 } : {}
26369
26346
  });
@@ -27379,21 +27356,7 @@ var ETelemetryEventName;
27379
27356
  ETelemetryEventName2["HISTORY_APPEND_FINISHED"] = "linkque.history.append.finished";
27380
27357
  ETelemetryEventName2["HOOK_DRAIN_STARTED"] = "linkque.hook.drain.started";
27381
27358
  ETelemetryEventName2["HOOK_DRAIN_FINISHED"] = "linkque.hook.drain.finished";
27382
- ETelemetryEventName2["DEBUG_CONTENT_RECORDED"] = "linkque.debug.content.recorded";
27383
27359
  })(ETelemetryEventName || (ETelemetryEventName = {}));
27384
- var ETelemetryContentSection;
27385
- (function(ETelemetryContentSection2) {
27386
- ETelemetryContentSection2["QUERY_INPUT"] = "query.input";
27387
- ETelemetryContentSection2["TOOL_INPUT"] = "tool.input";
27388
- ETelemetryContentSection2["TOOL_OUTPUT"] = "tool.output";
27389
- ETelemetryContentSection2["MCP_REQUESTED_INPUT"] = "mcp.requested_input";
27390
- ETelemetryContentSection2["MCP_INPUT"] = "mcp.input";
27391
- ETelemetryContentSection2["MCP_OUTPUT"] = "mcp.output";
27392
- ETelemetryContentSection2["SKILL_INPUT"] = "skill.input";
27393
- ETelemetryContentSection2["SKILL_OUTPUT"] = "skill.output";
27394
- ETelemetryContentSection2["KNOWLEDGE_INPUT"] = "knowledge.input";
27395
- ETelemetryContentSection2["KNOWLEDGE_OUTPUT"] = "knowledge.output";
27396
- })(ETelemetryContentSection || (ETelemetryContentSection = {}));
27397
27360
  var ETelemetryOperationName;
27398
27361
  (function(ETelemetryOperationName2) {
27399
27362
  ETelemetryOperationName2["OPERATION"] = "linkque.operation";
@@ -28720,37 +28683,6 @@ var LinkquegwEventHookExecutor = class {
28720
28683
  }
28721
28684
  };
28722
28685
 
28723
- // ../linkque-agent-runtime/dist/esm/core/telemetry/contentRecording.js
28724
- function recordContentSection(observation, section, value, availability = "available") {
28725
- observation?.record(ETelemetryEventName.DEBUG_CONTENT_RECORDED, {}, { section, value, availability });
28726
- }
28727
- function recordMcpContentSection(observation, section, value, schema) {
28728
- if (!observation)
28729
- return;
28730
- const fieldTitles = {};
28731
- const visit = (node, path2) => {
28732
- if (!node || typeof node !== "object" || Array.isArray(node))
28733
- return;
28734
- const definition = node;
28735
- if (path2 && typeof definition.title === "string" && definition.title.trim())
28736
- fieldTitles[path2] = definition.title;
28737
- const properties = definition.properties;
28738
- if (properties && typeof properties === "object" && !Array.isArray(properties)) {
28739
- for (const [key, child] of Object.entries(properties))
28740
- visit(child, `${path2}/${key.replaceAll("~", "~0").replaceAll("/", "~1")}`);
28741
- }
28742
- if (definition.items)
28743
- visit(definition.items, `${path2}/*`);
28744
- };
28745
- visit(schema, section === ETelemetryContentSection.MCP_OUTPUT ? "/structuredContent" : "");
28746
- observation.record(ETelemetryEventName.DEBUG_CONTENT_RECORDED, {}, {
28747
- section,
28748
- value,
28749
- availability: "available",
28750
- ...Object.keys(fieldTitles).length ? { fieldTitles } : {}
28751
- });
28752
- }
28753
-
28754
28686
  // ../linkque-agent-runtime/dist/esm/core/skillTools.js
28755
28687
  var ACTIVATE_SKILL_TOOL_NAME = "activate_skill";
28756
28688
  var AVAILABLE_SKILLS_OPEN = "<available_skills>";
@@ -28822,45 +28754,18 @@ function createActivateSkillTool(records) {
28822
28754
  required: ["name"],
28823
28755
  additionalProperties: false
28824
28756
  },
28825
- execute: async (args, _signal, context2) => {
28757
+ execute: async (args) => {
28826
28758
  const name = extractName(args);
28827
- const startedAt = Date.now();
28828
- const obs = context2?.observation;
28829
- recordContentSection(obs, ETelemetryContentSection.SKILL_INPUT, {
28830
- name: name ?? null
28831
- });
28832
- if (!name) {
28833
- recordContentSection(obs, ETelemetryContentSection.SKILL_OUTPUT, {
28834
- status: "failed",
28835
- error: "\u7F3A\u5C11 name \u53C2\u6570",
28836
- durationMs: Date.now() - startedAt
28837
- });
28759
+ if (!name)
28838
28760
  return "\u6FC0\u6D3B\u6280\u80FD\u5931\u8D25:\u7F3A\u5C11 name \u53C2\u6570\u3002";
28839
- }
28840
28761
  if (!bodyByName.has(name)) {
28841
- recordContentSection(obs, ETelemetryContentSection.SKILL_OUTPUT, {
28842
- name,
28843
- status: "failed",
28844
- error: `\u672A\u627E\u5230\u6280\u80FD "${name}"`,
28845
- durationMs: Date.now() - startedAt
28846
- });
28847
28762
  return `\u6FC0\u6D3B\u6280\u80FD\u5931\u8D25:\u672A\u627E\u5230\u6280\u80FD "${name}"\u3002\u53EF\u7528:${[...bodyByName.keys()].join(", ")}`;
28848
28763
  }
28849
28764
  if (activated.has(name)) {
28850
- recordContentSection(obs, ETelemetryContentSection.SKILL_OUTPUT, {
28851
- name,
28852
- status: "already_loaded",
28853
- durationMs: Date.now() - startedAt
28854
- });
28855
28765
  return `\u6280\u80FD "${name}" \u5DF2\u5728\u672C\u8F6E\u52A0\u8F7D,\u65E0\u9700\u91CD\u590D\u6FC0\u6D3B\u3002`;
28856
28766
  }
28857
28767
  activated.add(name);
28858
28768
  const body = bodyByName.get(name) ?? "";
28859
- recordContentSection(obs, ETelemetryContentSection.SKILL_OUTPUT, {
28860
- name,
28861
- status: "loaded",
28862
- durationMs: Date.now() - startedAt
28863
- });
28864
28769
  return `<skill name="${escapeXml(name)}">
28865
28770
  ${body}
28866
28771
  </skill>`;
@@ -29111,7 +29016,7 @@ function createKnowledgeTools(resources, searchPort, agentId) {
29111
29016
  additionalProperties: false
29112
29017
  },
29113
29018
  annotations: { readOnlyHint: true },
29114
- execute: (_args, _signal, context2) => listKnowledge(context2)
29019
+ execute: () => listKnowledge()
29115
29020
  },
29116
29021
  {
29117
29022
  name: KNOWLEDGE_RECALL_TOOL_NAME,
@@ -29138,48 +29043,24 @@ function createKnowledgeTools(resources, searchPort, agentId) {
29138
29043
  additionalProperties: false
29139
29044
  },
29140
29045
  annotations: { readOnlyHint: true },
29141
- execute: (args, signal, context2) => recallKnowledge(args, signal, context2)
29046
+ execute: (args, signal) => recallKnowledge(args, signal)
29142
29047
  }
29143
29048
  ];
29144
- async function listKnowledge(context2) {
29145
- const result = { knowledgeBases: await getKnowledgeBases() };
29146
- recordContentSection(context2?.observation, ETelemetryContentSection.KNOWLEDGE_OUTPUT, {
29147
- knowledgeBases: result.knowledgeBases.map((kb) => ({
29148
- knowledgeBaseId: kb.knowledgeBaseId,
29149
- knowledgeDesc: kb.knowledgeDesc
29150
- }))
29151
- });
29152
- return result;
29049
+ async function listKnowledge() {
29050
+ return { knowledgeBases: await getKnowledgeBases() };
29153
29051
  }
29154
- async function recallKnowledge(args, signal, context2) {
29052
+ async function recallKnowledge(args, signal) {
29155
29053
  const parsed = parseRecallArgs(args);
29156
- const obs = context2?.observation;
29157
29054
  if ("error" in parsed) {
29158
- recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_INPUT, {
29159
- error: parsed.error
29160
- });
29161
- recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_OUTPUT, {
29162
- status: "failed",
29163
- hits: [],
29164
- error: parsed.error
29165
- });
29166
29055
  return { hits: [], error: parsed.error };
29167
29056
  }
29168
- recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_INPUT, {
29169
- knowledgeBaseId: parsed.knowledgeBaseId,
29170
- query: parsed.query,
29171
- topK: parsed.topK
29172
- });
29173
29057
  const knowledgeBases = await getKnowledgeBases();
29174
29058
  const bound = knowledgeBases.some((info) => info.knowledgeBaseId === parsed.knowledgeBaseId);
29175
29059
  if (!bound) {
29176
- const error = `knowledgeBaseId \u672A\u7ED1\u5B9A: ${parsed.knowledgeBaseId}\u3002\u8BF7\u5148\u8C03\u7528 knowledge_list \u67E5\u770B\u53EF\u7528\u77E5\u8BC6\u5E93\u3002`;
29177
- recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_OUTPUT, {
29178
- status: "failed",
29060
+ return {
29179
29061
  hits: [],
29180
- error
29181
- });
29182
- return { hits: [], error };
29062
+ error: `knowledgeBaseId \u672A\u7ED1\u5B9A: ${parsed.knowledgeBaseId}\u3002\u8BF7\u5148\u8C03\u7528 knowledge_list \u67E5\u770B\u53EF\u7528\u77E5\u8BC6\u5E93\u3002`
29063
+ };
29183
29064
  }
29184
29065
  try {
29185
29066
  const result = await searchPort.search({
@@ -29188,20 +29069,10 @@ function createKnowledgeTools(resources, searchPort, agentId) {
29188
29069
  agentId,
29189
29070
  topK: parsed.topK
29190
29071
  }, signal);
29191
- recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_OUTPUT, {
29192
- status: result.hits.length ? "matched" : "no_hits",
29193
- hits: result.hits
29194
- });
29195
29072
  return { hits: result.hits };
29196
29073
  } catch (e) {
29197
29074
  const msg = e instanceof Error ? e.message : String(e);
29198
- const error = `\u77E5\u8BC6\u5E93\u68C0\u7D22\u5931\u8D25: ${msg}`;
29199
- recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_OUTPUT, {
29200
- status: "failed",
29201
- hits: [],
29202
- error
29203
- });
29204
- return { hits: [], error };
29075
+ return { hits: [], error: `\u77E5\u8BC6\u5E93\u68C0\u7D22\u5931\u8D25: ${msg}` };
29205
29076
  }
29206
29077
  }
29207
29078
  async function getKnowledgeBases() {
@@ -29228,7 +29099,7 @@ var NoopRuntimeObservation = class {
29228
29099
  startOperation(_operation) {
29229
29100
  return this;
29230
29101
  }
29231
- record(_name, _attributes, _body) {
29102
+ record(_name, _attributes) {
29232
29103
  }
29233
29104
  finish(_outcome, _attributes) {
29234
29105
  }
@@ -29311,7 +29182,7 @@ var RuntimeObservation = class _RuntimeObservation {
29311
29182
  find(key) {
29312
29183
  return this.associations.get(key);
29313
29184
  }
29314
- record(name, attributes, body) {
29185
+ record(name, attributes) {
29315
29186
  if (this.abandoned)
29316
29187
  return;
29317
29188
  try {
@@ -29319,7 +29190,7 @@ var RuntimeObservation = class _RuntimeObservation {
29319
29190
  this.resultAttributes = {
29320
29191
  [ETelemetryAttribute.LINKQUE_TOOL_FAILURE_STAGE]: attributes[ETelemetryAttribute.LINKQUE_TOOL_FAILURE_STAGE]
29321
29192
  };
29322
- this.sink.record(name, attributes, body);
29193
+ this.sink.record(name, attributes);
29323
29194
  } catch {
29324
29195
  }
29325
29196
  }
@@ -35911,14 +35782,7 @@ var RemoteGatewayMcpServerProvider = class {
35911
35782
  if (!this.debugLog)
35912
35783
  return;
35913
35784
  try {
35914
- this.debugLog(`[mcp-client] ${JSON.stringify({
35915
- serverName,
35916
- resourceId: resource.resourceId,
35917
- requestId,
35918
- method,
35919
- phase,
35920
- payload: this.invocationContext.current()?.auth ? { redacted: true } : payload
35921
- })}`, EDebugLogScope.MCP);
35785
+ this.debugLog(`[mcp-client] ${JSON.stringify({ serverName, resourceId: resource.resourceId, requestId, method, phase, payload: this.invocationContext.current()?.auth ? { redacted: true } : payload })}`, EDebugLogScope.MCP);
35922
35786
  } catch (error) {
35923
35787
  warnLogFailure("remoteGatewayMcpServer.log", error);
35924
35788
  }
@@ -35938,8 +35802,6 @@ var RemoteGatewayMcpServerProvider = class {
35938
35802
  callTool: (params, resultSchema, requestOptions) => request("tools/call", params, () => client.callTool(params, resultSchema, requestOptions))
35939
35803
  };
35940
35804
  const callTool = (name, args, signal, options) => callHeaders.run(options?.headers ?? {}, () => this.invocationContext.run(timeoutMs, signal, async (invocation) => {
35941
- const observation = options?.context?.observation;
35942
- recordMcpContentSection(observation, ETelemetryContentSection.MCP_REQUESTED_INPUT, args, options?.toolSchema?.inputSchema);
35943
35805
  const plan = createArgsMappingPlan(name, args, argsMappingRules);
35944
35806
  if (plan.requiresUserId) {
35945
35807
  if (config.signEndpoint !== void 0 && config.signEndpoint !== DEFAULT_SIGN_ENDPOINT && !config.verifyTokenEndpoint?.trim())
@@ -35962,18 +35824,15 @@ var RemoteGatewayMcpServerProvider = class {
35962
35824
  };
35963
35825
  }
35964
35826
  const mapped = resolveArgsMappingPlan(plan, invocation.auth);
35965
- recordMcpContentSection(observation, ETelemetryContentSection.MCP_INPUT, mapped, options?.toolSchema?.inputSchema);
35966
35827
  invocation.signal.throwIfAborted();
35967
35828
  const remaining = Math.max(1, invocation.deadline - performance.now());
35968
35829
  try {
35969
- const result = await loggedClient.callTool({ name, arguments: mapped }, void 0, {
35830
+ return await loggedClient.callTool({ name, arguments: mapped }, void 0, {
35970
35831
  signal: invocation.signal,
35971
35832
  timeout: remaining,
35972
35833
  maxTotalTimeout: remaining,
35973
35834
  resetTimeoutOnProgress: false
35974
35835
  });
35975
- recordMcpContentSection(observation, ETelemetryContentSection.MCP_OUTPUT, result, options?.toolSchema?.outputSchema);
35976
- return result;
35977
35836
  } catch (error) {
35978
35837
  invocation.signal.throwIfAborted();
35979
35838
  if (invocation.auth && !(error instanceof McpInvocationError))
@@ -36002,13 +35861,7 @@ async function listToolsFromClient(client, resourceId, callTool) {
36002
35861
  const descriptor = {
36003
35862
  name: tool.name,
36004
35863
  resourceId,
36005
- execute: (args, signal, context2) => callTool(tool.name, args, signal, {
36006
- context: context2,
36007
- toolSchema: {
36008
- inputSchema: tool.inputSchema,
36009
- outputSchema: tool.outputSchema
36010
- }
36011
- })
35864
+ execute: (args, signal) => callTool(tool.name, args, signal)
36012
35865
  };
36013
35866
  if (tool.description !== void 0)
36014
35867
  descriptor.description = tool.description;
@@ -37042,7 +36895,7 @@ var WebSkillLoader = class {
37042
36895
  return records.filter((record2, idx) => {
37043
36896
  if (record2 !== void 0)
37044
36897
  return true;
37045
- 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);
36898
+ this.debugLog?.(`[skill] \u8DF3\u8FC7\u8D44\u6E90 ${resources[idx]?.resourceId ?? "?"}:SKILL.md \u7F3A description(\u524D\u7F6E\u65E0\u6548),\u6309 spec \u4E0D\u52A0\u8F7D`);
37046
36899
  return false;
37047
36900
  });
37048
36901
  }
@@ -37867,7 +37720,7 @@ var OtelRuntimeTelemetry = class {
37867
37720
  {
37868
37721
  onEmit: (record2, ctx) => {
37869
37722
  const route = ctx?.getValue(this.routeKey);
37870
- this.output(ETelemetrySignal.LOGS, import_otlp_transformer.JsonLogsSerializer.serializeRequest([record2]), route?.route, route?.critical ?? false, route?.localOnly ?? false);
37723
+ this.output(ETelemetrySignal.LOGS, import_otlp_transformer.JsonLogsSerializer.serializeRequest([record2]), route?.route, route?.critical ?? false);
37871
37724
  },
37872
37725
  forceFlush: async () => void 0,
37873
37726
  shutdown: async () => void 0
@@ -37875,13 +37728,12 @@ var OtelRuntimeTelemetry = class {
37875
37728
  ]
37876
37729
  });
37877
37730
  }
37878
- output(signal, encoded, route, critical, localOnly = false) {
37731
+ output(signal, encoded, route, critical) {
37879
37732
  if (!encoded || this.outputActive || this.disposed)
37880
37733
  return;
37881
37734
  this.outputActive = true;
37882
37735
  try {
37883
- if (!localOnly)
37884
- this.queue.enqueue(route, signal, encoded, critical);
37736
+ this.queue.enqueue(route, signal, encoded, critical);
37885
37737
  if (this.options.localSink) {
37886
37738
  try {
37887
37739
  const payload = JSON.parse(new TextDecoder().decode(encoded));
@@ -37906,6 +37758,7 @@ var OtelRuntimeTelemetry = class {
37906
37758
  return new NoopRuntimeObservation();
37907
37759
  }
37908
37760
  const state = {
37761
+ agentId: input.agentId,
37909
37762
  sequence: 0,
37910
37763
  route: auth2 ? this.queue.authorize(auth2) : void 0,
37911
37764
  attributes: sanitizeTelemetryAttributes({
@@ -37961,6 +37814,7 @@ var OtelRuntimeTelemetry = class {
37961
37814
  isRemote: upstream !== null,
37962
37815
  traceState: parentContext.traceState ? createTraceState(parentContext.traceState) : void 0
37963
37816
  });
37817
+ 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 && state.agentId ? `${ETelemetryGenAiOperation.INVOKE_AGENT} ${state.agentId}` : spec.name;
37964
37818
  const attributes = sanitizeTelemetryAttributes({
37965
37819
  ...state.attributes,
37966
37820
  ...parent?.attributes,
@@ -37978,11 +37832,11 @@ var OtelRuntimeTelemetry = class {
37978
37832
  ETelemetryAttribute.LINKQUE_CONVERSATION_ID
37979
37833
  ].some((attribute) => attribute === key))),
37980
37834
  [ETelemetryAttribute.LINKQUE_OPERATION_ID]: randomUUID5(),
37981
- [ETelemetryAttribute.LINKQUE_OPERATION_NAME]: spec.name,
37835
+ [ETelemetryAttribute.LINKQUE_OPERATION_NAME]: spanName,
37982
37836
  [ETelemetryAttribute.LINKQUE_OPERATION_PARENT_ID]: spec.detached ? "" : parent?.operationId ?? "",
37983
37837
  [ETelemetryAttribute.LINKQUE_SPAN_PARENT_ID]: spec.detached ? "" : parentContext?.spanId ?? ""
37984
37838
  });
37985
- const span = this.tracerProvider.getTracer(ETelemetryMetadata.SCOPE_NAME, ETelemetryVersion.V1_0).startSpan(spec.name, {
37839
+ const span = this.tracerProvider.getTracer(ETelemetryMetadata.SCOPE_NAME, ETelemetryVersion.V1_0).startSpan(spanName.slice(0, 256), {
37986
37840
  kind: spec.name === ETelemetryOperationName.MODEL_ATTEMPT ? SpanKind.CLIENT : SpanKind.INTERNAL,
37987
37841
  attributes,
37988
37842
  links: spec.links.filter((link) => validContext(link.context)).slice(0, 16).map((link) => ({
@@ -38010,7 +37864,7 @@ var OtelRuntimeTelemetry = class {
38010
37864
  operation.record(`${spec.eventPrefix}.${ETelemetryEventPhase.STARTED}`, {});
38011
37865
  return operation;
38012
37866
  }
38013
- emit(operation, name, attributes, critical, body) {
37867
+ emit(operation, name, attributes, critical) {
38014
37868
  if (this.disposed || this.queue.isExporting)
38015
37869
  return;
38016
37870
  const contextAttributes = operation.attributes;
@@ -38037,24 +37891,18 @@ var OtelRuntimeTelemetry = class {
38037
37891
  Math.floor(now / 1e3),
38038
37892
  now % 1e3 * 1e6
38039
37893
  ];
38040
- const localOnly = name === ETelemetryEventName.DEBUG_CONTENT_RECORDED;
38041
- if (!localOnly && operation.span.isRecording())
37894
+ if (operation.span.isRecording())
38042
37895
  operation.span.addEvent(
38043
37896
  name,
38044
37897
  // 复用已投影的属性;Span 已持有上下文,事件只保留本次事实及去重字段。
38045
37898
  Object.fromEntries(Object.entries(record2).filter(([key]) => Object.hasOwn(attributes, key) || key === ETelemetryAttribute.HARNESS_RECORD_ID || key === ETelemetryAttribute.HARNESS_EVENT_SEQUENCE)),
38046
37899
  time
38047
37900
  );
38048
- const ctx = trace.setSpan(ROOT_CONTEXT, operation.span).setValue(this.routeKey, {
38049
- route: operation.state.route,
38050
- critical,
38051
- localOnly
38052
- });
37901
+ const ctx = trace.setSpan(ROOT_CONTEXT, operation.span).setValue(this.routeKey, { route: operation.state.route, critical });
38053
37902
  this.loggerProvider.getLogger(ETelemetryMetadata.SCOPE_NAME, ETelemetryVersion.V1_0).emit({
38054
37903
  eventName: name,
38055
37904
  timestamp: time,
38056
37905
  observedTimestamp: time,
38057
- ...body !== void 0 ? { body } : {},
38058
37906
  severityNumber: record2[ETelemetryAttribute.HARNESS_OPERATION_OUTCOME] === ETelemetryOutcome.ERROR || record2[ETelemetryAttribute.HARNESS_OPERATION_OUTCOME] === ETelemetryOutcome.TIMEOUT ? import_api_logs.SeverityNumber.ERROR : import_api_logs.SeverityNumber.INFO,
38059
37907
  severityText: record2[ETelemetryAttribute.HARNESS_OPERATION_OUTCOME] === ETelemetryOutcome.ERROR || record2[ETelemetryAttribute.HARNESS_OPERATION_OUTCOME] === ETelemetryOutcome.TIMEOUT ? import_api_logs.SeverityNumber[import_api_logs.SeverityNumber.ERROR] : import_api_logs.SeverityNumber[import_api_logs.SeverityNumber.INFO],
38060
37908
  attributes: record2,
@@ -38125,11 +37973,10 @@ var OtelObservation = class {
38125
37973
  return new NoopRuntimeObservation();
38126
37974
  return this.owner.createOperation(this.state, spec, this);
38127
37975
  }
38128
- record(name, attributes, body) {
37976
+ record(name, attributes) {
38129
37977
  if (this.lost || !/^(harness|linkque)\.[a-z0-9_.]{1,128}$/.test(name))
38130
37978
  return;
38131
- const critical = name.endsWith(`.${ETelemetryEventPhase.FINISHED}`) || name === ETelemetryEventName.MODEL_USAGE_RECORDED || name === ETelemetryEventName.RUNTIME_UNCAUGHT_ERROR || name.endsWith(`.${ETelemetryEventPhase.OBSERVATION_LOST}`);
38132
- this.owner.emit(this, name, attributes, critical, body);
37979
+ 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}`));
38133
37980
  }
38134
37981
  finish(outcome, attributes) {
38135
37982
  if (this.ended)
@@ -38175,8 +38022,6 @@ function validContext(value) {
38175
38022
  export {
38176
38023
  EModelRequestSource,
38177
38024
  EDebugLogScope,
38178
- isDebugLoggingEnabled,
38179
- createRuntimeDebugLog,
38180
38025
  EModelProvider,
38181
38026
  EResourceType,
38182
38027
  EResourceProviderType,
@@ -38220,7 +38065,6 @@ export {
38220
38065
  ETelemetryAttribute,
38221
38066
  ETelemetryEventPrefix,
38222
38067
  ETelemetryEventName,
38223
- ETelemetryContentSection,
38224
38068
  ETelemetryOperationName,
38225
38069
  ETelemetryOutcome,
38226
38070
  ETelemetryLossReason,
@@ -38256,8 +38100,6 @@ export {
38256
38100
  summarizeBody,
38257
38101
  formatHttpLogLine,
38258
38102
  LinkquegwEventHookExecutor,
38259
- recordContentSection,
38260
- ACTIVATE_SKILL_TOOL_NAME,
38261
38103
  parseSkillFile,
38262
38104
  buildSkillCatalog,
38263
38105
  createActivateSkillTool,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  EModelProvider
3
- } from "./chunk-Y36JLYIE.js";
3
+ } from "./chunk-OHRCYI66.js";
4
4
 
5
5
  // ../linkque-agent-appwrite-integrate/dist/esm/runtime/protocol.js
6
6
  var baked;
@@ -40,15 +40,14 @@ import {
40
40
  resolveRunStorage,
41
41
  toAgentRunMessages,
42
42
  withIsoTimestamp
43
- } from "../../chunk-SAQYWJAA.js";
43
+ } from "../../chunk-CUMXO6KK.js";
44
44
  import "../../chunk-IWOFD643.js";
45
45
  import "../../chunk-PXCGFBV5.js";
46
46
  import "../../chunk-ETG6PNHQ.js";
47
47
  import {
48
48
  getBakedProtocol
49
- } from "../../chunk-OMFQ2KRJ.js";
49
+ } from "../../chunk-XL6BPKTI.js";
50
50
  import {
51
- ACTIVATE_SKILL_TOOL_NAME,
52
51
  CANCEL_CONVERSATION_RUN_OPERATION,
53
52
  CONVERSATION_HISTORY_VERSION,
54
53
  CardActionDiagnostics,
@@ -75,7 +74,6 @@ import {
75
74
  ETelemetryCancelSource,
76
75
  ETelemetryCommitStatus,
77
76
  ETelemetryCompleteness,
78
- ETelemetryContentSection,
79
77
  ETelemetryCoverage,
80
78
  ETelemetryErrorType,
81
79
  ETelemetryEventName,
@@ -121,7 +119,6 @@ import {
121
119
  createCardPresentationToolName,
122
120
  createKnowledgeTools,
123
121
  createPresentationDescription,
124
- createRuntimeDebugLog,
125
122
  createWebSearchTool,
126
123
  encodeConversationSseEvent,
127
124
  executeA2UICardResolver,
@@ -152,7 +149,6 @@ import {
152
149
  projectPresentationReceiptForModel,
153
150
  readJsonPointer,
154
151
  readStructuredContent,
155
- recordContentSection,
156
152
  redactHeaders,
157
153
  resolvePhoneAuthorizationDependency,
158
154
  resolveWebSearchResource,
@@ -162,7 +158,7 @@ import {
162
158
  summarizeBody,
163
159
  warnLogFailure,
164
160
  wrapToolWithHooks
165
- } from "../../chunk-Y36JLYIE.js";
161
+ } from "../../chunk-OHRCYI66.js";
166
162
  import "../../chunk-EAODRPW4.js";
167
163
  import "../../chunk-XUFLSZM4.js";
168
164
  import "../../chunk-GAYNLDWK.js";
@@ -7949,7 +7945,6 @@ import { randomUUID as randomUUID7 } from "node:crypto";
7949
7945
 
7950
7946
  // ../linkque-agent-runtime/dist/esm/core/telemetry/toolObservation.js
7951
7947
  import { randomUUID } from "node:crypto";
7952
- var isSkillTool = (tool) => (tool.modelName ?? tool.name) === ACTIVATE_SKILL_TOOL_NAME;
7953
7948
  function toolResultOutcome(result) {
7954
7949
  try {
7955
7950
  if (!(result && typeof result === "object")) {
@@ -7983,19 +7978,8 @@ function observeTool(tool, observation) {
7983
7978
  detached: false,
7984
7979
  links: []
7985
7980
  });
7986
- const captureBody = !isSkillTool(tool);
7987
7981
  try {
7988
- if (captureBody) {
7989
- recordContentSection(operation, ETelemetryContentSection.TOOL_INPUT, args);
7990
- }
7991
- const execContext = {
7992
- ...context ?? { toolCallId: "", emit: () => void 0 },
7993
- observation: operation
7994
- };
7995
- const result = await tool.execute(args, signal, execContext);
7996
- if (captureBody) {
7997
- recordContentSection(operation, ETelemetryContentSection.TOOL_OUTPUT, result);
7998
- }
7982
+ const result = await tool.execute(args, signal, context);
7999
7983
  operation.finish(toolResultOutcome(result), {
8000
7984
  [ETelemetryAttribute.HARNESS_TOOL_RESULT_STATUS]: toolResultOutcome(result)
8001
7985
  });
@@ -41957,36 +41941,11 @@ var AgentRuntime = class _AgentRuntime {
41957
41941
  }
41958
41942
  }, (observation) => this.runObservedAdvance(request, auth, options, observation), options.signal);
41959
41943
  }
41960
- /**
41961
- * 记录本次用户输入(RFC §4.1):取进入 Runtime 的本次新消息中最后一条 user message
41962
- * 的 content,作为 `linkque.debug.content.recorded` 的 body 走 record 链路落入
41963
- * OTLP logs(body 含 section/value/availability)。不以模型 messages 上下文为输入;
41964
- * 无 user 文本(卡片交互等)时按可用性如实标记,不伪造自然语言 Query。
41965
- */
41966
- recordCurrentQuery(observation, request) {
41967
- let lastUser;
41968
- for (const message of request.messages) {
41969
- if (message.role === "user")
41970
- lastUser = message;
41971
- }
41972
- const content = lastUser?.content;
41973
- const text2 = typeof content === "string" && content ? content : void 0;
41974
- const card = content && typeof content === "object" && "type" in content && content.type === "a2ui.event" ? content : void 0;
41975
- const displayText = card && "displayText" in card && typeof card.displayText === "string" && card.displayText ? card.displayText : void 0;
41976
- const body = {
41977
- section: ETelemetryContentSection.QUERY_INPUT,
41978
- ...text2 !== void 0 ? { value: text2 } : {},
41979
- ...card ? { inputType: "card", ...displayText ? { displayText } : {} } : {},
41980
- availability: text2 !== void 0 || card ? "available" : "not_recorded"
41981
- };
41982
- observation.record(ETelemetryEventName.DEBUG_CONTENT_RECORDED, {}, body);
41983
- }
41984
41944
  async *runObservedAdvance(request, auth, options, observation) {
41985
41945
  observation.record(ETelemetryEventName.TELEMETRY_COVERAGE, {
41986
41946
  [ETelemetryAttribute.LINKQUE_TELEMETRY_COVERAGE]: this.agentLoop instanceof PiAgentLoop ? ETelemetryCoverage.PI_MODEL_TOOL_HOOK : ETelemetryCoverage.CORE_ONLY,
41987
41947
  [ETelemetryAttribute.HARNESS_TELEMETRY_COMPLETENESS]: this.agentLoop instanceof PiAgentLoop ? ETelemetryCompleteness.COMPLETE : ETelemetryCompleteness.PARTIAL
41988
41948
  });
41989
- this.recordCurrentQuery(observation, request);
41990
41949
  const cleanup = [];
41991
41950
  let termination = ETelemetryStreamTermination.CANCEL;
41992
41951
  let failed = false;
@@ -43099,10 +43058,10 @@ function resolveLinkqueEndpoints(env, envSelector) {
43099
43058
  }
43100
43059
  function createAppBaseRuntime(protocol, env = process.env, ports = {}, logCtx) {
43101
43060
  const log = (...a) => logCtx?.log?.("[runtime-factory]", ...a);
43102
- const debugLog = logCtx?.log ? createRuntimeDebugLog(new AppbaseRuntimeConfigProvider(env).get("LOG_LEVEL"), (line, scope) => {
43061
+ const debugLog = logCtx?.log ? (line, scope) => {
43103
43062
  const prefix = scope ? `[${scope}] ` : "";
43104
43063
  logCtx.log?.(prefix + line);
43105
- }) : void 0;
43064
+ } : void 0;
43106
43065
  const runtimePorts = {};
43107
43066
  if (ports.telemetry)
43108
43067
  runtimePorts.telemetry = ports.telemetry;
@@ -45403,9 +45362,14 @@ function resolveChatDeps(env, deps, logCtx, historyOwnerId, appwriteApiKey, envS
45403
45362
  remoteBaseUrl: openMcpBaseUrl,
45404
45363
  ...mcpSignEndpoint ? { signEndpoint: mcpSignEndpoint } : {}
45405
45364
  });
45365
+ const mcpDebugLog = isDebugLogLevel(env) && logCtx?.log ? (line, scope) => {
45366
+ const prefix = scope ? `[${scope}] ` : "";
45367
+ logCtx.log?.(prefix + line);
45368
+ } : void 0;
45406
45369
  const rawMcpServerProvider = deps?.mcpServerProvider ?? createAppbaseMcpProvider({
45407
45370
  resolveConfig: mcpConfigResolver,
45408
- getAuthorizationHeader: mcpAuthorizationHeaderProvider
45371
+ getAuthorizationHeader: mcpAuthorizationHeaderProvider,
45372
+ ...mcpDebugLog ? { debugLog: mcpDebugLog } : {}
45409
45373
  });
45410
45374
  const mcpServerProvider = rawMcpServerProvider;
45411
45375
  const securityAnswerPlugin = deps?.securityAnswerPlugin ?? createSecurityAnswerPlugin(historyStore, logCtx?.log);