linkque-cli-v2 1.4.2 → 1.4.3

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.2",
3
+ "version": "1.4.3",
4
4
  "description": "Public Linkque CLI bundle for sandbox debugging",
5
5
  "bin": {
6
6
  "linkquejs": "linkquejs.js"
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  EModelProvider
3
- } from "./chunk-OHRCYI66.js";
3
+ } from "./chunk-Y36JLYIE.js";
4
4
 
5
5
  // ../linkque-agent-appwrite-integrate/dist/esm/runtime/protocol.js
6
6
  var baked;
@@ -20,8 +20,9 @@ import {
20
20
  McpPhoneAuthorizationFailedError,
21
21
  McpPhoneAuthorizationRequiredError,
22
22
  RUNTIME_CONFIG_DEFAULTS,
23
- RuntimeConfigProvider
24
- } from "./chunk-OHRCYI66.js";
23
+ RuntimeConfigProvider,
24
+ isDebugLoggingEnabled
25
+ } from "./chunk-Y36JLYIE.js";
25
26
  import {
26
27
  __commonJS,
27
28
  __require,
@@ -15293,7 +15294,7 @@ function maskEndpoint(raw) {
15293
15294
  return raw ? raw.replace(/\/+$/, "") : "<unset>";
15294
15295
  }
15295
15296
  function isDebugLogLevel(env) {
15296
- return new AppbaseRuntimeConfigProvider(env).get("LOG_LEVEL") === "debug";
15297
+ return isDebugLoggingEnabled(new AppbaseRuntimeConfigProvider(env).get("LOG_LEVEL"));
15297
15298
  }
15298
15299
  function whichSource(env, candidates) {
15299
15300
  const config = new AppbaseRuntimeConfigProvider(env);
@@ -4514,13 +4514,14 @@ var require_fast_uri = __commonJS({
4514
4514
  if (!malformedIPLiteral) {
4515
4515
  malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
4516
4516
  }
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
- }
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());
4523
4521
  }
4522
+ parsed.host = reescapeHostDelimiters(host, isIP);
4523
+ }
4524
+ if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
4524
4525
  if (parsed.path) {
4525
4526
  parsed.path = normalizePathEncoding(parsed.path);
4526
4527
  }
@@ -22825,10 +22826,24 @@ var EDebugLogScope;
22825
22826
  EDebugLogScope2["LLM"] = "LLM";
22826
22827
  EDebugLogScope2["PI_EVENT"] = "PI_EVENT";
22827
22828
  EDebugLogScope2["MCP"] = "MCP";
22829
+ EDebugLogScope2["SKILL"] = "SKILL";
22828
22830
  EDebugLogScope2["HTTP"] = "HTTP";
22829
22831
  EDebugLogScope2["HOOK"] = "HOOK";
22830
22832
  })(EDebugLogScope || (EDebugLogScope = {}));
22831
22833
 
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
+
22832
22847
  // ../linkque-agent-runtime/dist/esm/core/cardTools.js
22833
22848
  import { randomUUID } from "node:crypto";
22834
22849
 
@@ -26094,6 +26109,10 @@ var McpProxyTool = class {
26094
26109
  context: context2
26095
26110
  });
26096
26111
  return entry.server.callTool(tool.name, args, sig, {
26112
+ toolSchema: {
26113
+ inputSchema: tool.inputSchema,
26114
+ outputSchema: tool.outputSchema
26115
+ },
26097
26116
  ...headers ? { headers } : {},
26098
26117
  ...context2 ? { context: context2 } : {}
26099
26118
  });
@@ -26341,6 +26360,10 @@ ${formatSchema(tool.inputSchema)}`);
26341
26360
  context: context2
26342
26361
  });
26343
26362
  const result = await entry.server.callTool(tool.name, args, signal, {
26363
+ toolSchema: {
26364
+ inputSchema: tool.inputSchema,
26365
+ outputSchema: tool.outputSchema
26366
+ },
26344
26367
  ...headers ? { headers } : {},
26345
26368
  ...context2 ? { context: context2 } : {}
26346
26369
  });
@@ -27356,7 +27379,21 @@ var ETelemetryEventName;
27356
27379
  ETelemetryEventName2["HISTORY_APPEND_FINISHED"] = "linkque.history.append.finished";
27357
27380
  ETelemetryEventName2["HOOK_DRAIN_STARTED"] = "linkque.hook.drain.started";
27358
27381
  ETelemetryEventName2["HOOK_DRAIN_FINISHED"] = "linkque.hook.drain.finished";
27382
+ ETelemetryEventName2["DEBUG_CONTENT_RECORDED"] = "linkque.debug.content.recorded";
27359
27383
  })(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 = {}));
27360
27397
  var ETelemetryOperationName;
27361
27398
  (function(ETelemetryOperationName2) {
27362
27399
  ETelemetryOperationName2["OPERATION"] = "linkque.operation";
@@ -28683,6 +28720,37 @@ var LinkquegwEventHookExecutor = class {
28683
28720
  }
28684
28721
  };
28685
28722
 
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
+
28686
28754
  // ../linkque-agent-runtime/dist/esm/core/skillTools.js
28687
28755
  var ACTIVATE_SKILL_TOOL_NAME = "activate_skill";
28688
28756
  var AVAILABLE_SKILLS_OPEN = "<available_skills>";
@@ -28754,18 +28822,45 @@ function createActivateSkillTool(records) {
28754
28822
  required: ["name"],
28755
28823
  additionalProperties: false
28756
28824
  },
28757
- execute: async (args) => {
28825
+ execute: async (args, _signal, context2) => {
28758
28826
  const name = extractName(args);
28759
- if (!name)
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
+ });
28760
28838
  return "\u6FC0\u6D3B\u6280\u80FD\u5931\u8D25:\u7F3A\u5C11 name \u53C2\u6570\u3002";
28839
+ }
28761
28840
  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
+ });
28762
28847
  return `\u6FC0\u6D3B\u6280\u80FD\u5931\u8D25:\u672A\u627E\u5230\u6280\u80FD "${name}"\u3002\u53EF\u7528:${[...bodyByName.keys()].join(", ")}`;
28763
28848
  }
28764
28849
  if (activated.has(name)) {
28850
+ recordContentSection(obs, ETelemetryContentSection.SKILL_OUTPUT, {
28851
+ name,
28852
+ status: "already_loaded",
28853
+ durationMs: Date.now() - startedAt
28854
+ });
28765
28855
  return `\u6280\u80FD "${name}" \u5DF2\u5728\u672C\u8F6E\u52A0\u8F7D,\u65E0\u9700\u91CD\u590D\u6FC0\u6D3B\u3002`;
28766
28856
  }
28767
28857
  activated.add(name);
28768
28858
  const body = bodyByName.get(name) ?? "";
28859
+ recordContentSection(obs, ETelemetryContentSection.SKILL_OUTPUT, {
28860
+ name,
28861
+ status: "loaded",
28862
+ durationMs: Date.now() - startedAt
28863
+ });
28769
28864
  return `<skill name="${escapeXml(name)}">
28770
28865
  ${body}
28771
28866
  </skill>`;
@@ -29016,7 +29111,7 @@ function createKnowledgeTools(resources, searchPort, agentId) {
29016
29111
  additionalProperties: false
29017
29112
  },
29018
29113
  annotations: { readOnlyHint: true },
29019
- execute: () => listKnowledge()
29114
+ execute: (_args, _signal, context2) => listKnowledge(context2)
29020
29115
  },
29021
29116
  {
29022
29117
  name: KNOWLEDGE_RECALL_TOOL_NAME,
@@ -29043,24 +29138,48 @@ function createKnowledgeTools(resources, searchPort, agentId) {
29043
29138
  additionalProperties: false
29044
29139
  },
29045
29140
  annotations: { readOnlyHint: true },
29046
- execute: (args, signal) => recallKnowledge(args, signal)
29141
+ execute: (args, signal, context2) => recallKnowledge(args, signal, context2)
29047
29142
  }
29048
29143
  ];
29049
- async function listKnowledge() {
29050
- return { knowledgeBases: await getKnowledgeBases() };
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;
29051
29153
  }
29052
- async function recallKnowledge(args, signal) {
29154
+ async function recallKnowledge(args, signal, context2) {
29053
29155
  const parsed = parseRecallArgs(args);
29156
+ const obs = context2?.observation;
29054
29157
  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
+ });
29055
29166
  return { hits: [], error: parsed.error };
29056
29167
  }
29168
+ recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_INPUT, {
29169
+ knowledgeBaseId: parsed.knowledgeBaseId,
29170
+ query: parsed.query,
29171
+ topK: parsed.topK
29172
+ });
29057
29173
  const knowledgeBases = await getKnowledgeBases();
29058
29174
  const bound = knowledgeBases.some((info) => info.knowledgeBaseId === parsed.knowledgeBaseId);
29059
29175
  if (!bound) {
29060
- return {
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",
29061
29179
  hits: [],
29062
- error: `knowledgeBaseId \u672A\u7ED1\u5B9A: ${parsed.knowledgeBaseId}\u3002\u8BF7\u5148\u8C03\u7528 knowledge_list \u67E5\u770B\u53EF\u7528\u77E5\u8BC6\u5E93\u3002`
29063
- };
29180
+ error
29181
+ });
29182
+ return { hits: [], error };
29064
29183
  }
29065
29184
  try {
29066
29185
  const result = await searchPort.search({
@@ -29069,10 +29188,20 @@ function createKnowledgeTools(resources, searchPort, agentId) {
29069
29188
  agentId,
29070
29189
  topK: parsed.topK
29071
29190
  }, signal);
29191
+ recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_OUTPUT, {
29192
+ status: result.hits.length ? "matched" : "no_hits",
29193
+ hits: result.hits
29194
+ });
29072
29195
  return { hits: result.hits };
29073
29196
  } catch (e) {
29074
29197
  const msg = e instanceof Error ? e.message : String(e);
29075
- return { hits: [], error: `\u77E5\u8BC6\u5E93\u68C0\u7D22\u5931\u8D25: ${msg}` };
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 };
29076
29205
  }
29077
29206
  }
29078
29207
  async function getKnowledgeBases() {
@@ -29099,7 +29228,7 @@ var NoopRuntimeObservation = class {
29099
29228
  startOperation(_operation) {
29100
29229
  return this;
29101
29230
  }
29102
- record(_name, _attributes) {
29231
+ record(_name, _attributes, _body) {
29103
29232
  }
29104
29233
  finish(_outcome, _attributes) {
29105
29234
  }
@@ -29182,7 +29311,7 @@ var RuntimeObservation = class _RuntimeObservation {
29182
29311
  find(key) {
29183
29312
  return this.associations.get(key);
29184
29313
  }
29185
- record(name, attributes) {
29314
+ record(name, attributes, body) {
29186
29315
  if (this.abandoned)
29187
29316
  return;
29188
29317
  try {
@@ -29190,7 +29319,7 @@ var RuntimeObservation = class _RuntimeObservation {
29190
29319
  this.resultAttributes = {
29191
29320
  [ETelemetryAttribute.LINKQUE_TOOL_FAILURE_STAGE]: attributes[ETelemetryAttribute.LINKQUE_TOOL_FAILURE_STAGE]
29192
29321
  };
29193
- this.sink.record(name, attributes);
29322
+ this.sink.record(name, attributes, body);
29194
29323
  } catch {
29195
29324
  }
29196
29325
  }
@@ -35782,7 +35911,14 @@ var RemoteGatewayMcpServerProvider = class {
35782
35911
  if (!this.debugLog)
35783
35912
  return;
35784
35913
  try {
35785
- this.debugLog(`[mcp-client] ${JSON.stringify({ serverName, resourceId: resource.resourceId, requestId, method, phase, payload: this.invocationContext.current()?.auth ? { redacted: true } : payload })}`, EDebugLogScope.MCP);
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);
35786
35922
  } catch (error) {
35787
35923
  warnLogFailure("remoteGatewayMcpServer.log", error);
35788
35924
  }
@@ -35802,6 +35938,8 @@ var RemoteGatewayMcpServerProvider = class {
35802
35938
  callTool: (params, resultSchema, requestOptions) => request("tools/call", params, () => client.callTool(params, resultSchema, requestOptions))
35803
35939
  };
35804
35940
  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);
35805
35943
  const plan = createArgsMappingPlan(name, args, argsMappingRules);
35806
35944
  if (plan.requiresUserId) {
35807
35945
  if (config.signEndpoint !== void 0 && config.signEndpoint !== DEFAULT_SIGN_ENDPOINT && !config.verifyTokenEndpoint?.trim())
@@ -35824,15 +35962,18 @@ var RemoteGatewayMcpServerProvider = class {
35824
35962
  };
35825
35963
  }
35826
35964
  const mapped = resolveArgsMappingPlan(plan, invocation.auth);
35965
+ recordMcpContentSection(observation, ETelemetryContentSection.MCP_INPUT, mapped, options?.toolSchema?.inputSchema);
35827
35966
  invocation.signal.throwIfAborted();
35828
35967
  const remaining = Math.max(1, invocation.deadline - performance.now());
35829
35968
  try {
35830
- return await loggedClient.callTool({ name, arguments: mapped }, void 0, {
35969
+ const result = await loggedClient.callTool({ name, arguments: mapped }, void 0, {
35831
35970
  signal: invocation.signal,
35832
35971
  timeout: remaining,
35833
35972
  maxTotalTimeout: remaining,
35834
35973
  resetTimeoutOnProgress: false
35835
35974
  });
35975
+ recordMcpContentSection(observation, ETelemetryContentSection.MCP_OUTPUT, result, options?.toolSchema?.outputSchema);
35976
+ return result;
35836
35977
  } catch (error) {
35837
35978
  invocation.signal.throwIfAborted();
35838
35979
  if (invocation.auth && !(error instanceof McpInvocationError))
@@ -35861,7 +36002,13 @@ async function listToolsFromClient(client, resourceId, callTool) {
35861
36002
  const descriptor = {
35862
36003
  name: tool.name,
35863
36004
  resourceId,
35864
- execute: (args, signal) => callTool(tool.name, args, signal)
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
+ })
35865
36012
  };
35866
36013
  if (tool.description !== void 0)
35867
36014
  descriptor.description = tool.description;
@@ -36895,7 +37042,7 @@ var WebSkillLoader = class {
36895
37042
  return records.filter((record2, idx) => {
36896
37043
  if (record2 !== void 0)
36897
37044
  return true;
36898
- this.debugLog?.(`[skill] \u8DF3\u8FC7\u8D44\u6E90 ${resources[idx]?.resourceId ?? "?"}:SKILL.md \u7F3A description(\u524D\u7F6E\u65E0\u6548),\u6309 spec \u4E0D\u52A0\u8F7D`);
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);
36899
37046
  return false;
36900
37047
  });
36901
37048
  }
@@ -37720,7 +37867,7 @@ var OtelRuntimeTelemetry = class {
37720
37867
  {
37721
37868
  onEmit: (record2, ctx) => {
37722
37869
  const route = ctx?.getValue(this.routeKey);
37723
- this.output(ETelemetrySignal.LOGS, import_otlp_transformer.JsonLogsSerializer.serializeRequest([record2]), route?.route, route?.critical ?? false);
37870
+ this.output(ETelemetrySignal.LOGS, import_otlp_transformer.JsonLogsSerializer.serializeRequest([record2]), route?.route, route?.critical ?? false, route?.localOnly ?? false);
37724
37871
  },
37725
37872
  forceFlush: async () => void 0,
37726
37873
  shutdown: async () => void 0
@@ -37728,12 +37875,13 @@ var OtelRuntimeTelemetry = class {
37728
37875
  ]
37729
37876
  });
37730
37877
  }
37731
- output(signal, encoded, route, critical) {
37878
+ output(signal, encoded, route, critical, localOnly = false) {
37732
37879
  if (!encoded || this.outputActive || this.disposed)
37733
37880
  return;
37734
37881
  this.outputActive = true;
37735
37882
  try {
37736
- this.queue.enqueue(route, signal, encoded, critical);
37883
+ if (!localOnly)
37884
+ this.queue.enqueue(route, signal, encoded, critical);
37737
37885
  if (this.options.localSink) {
37738
37886
  try {
37739
37887
  const payload = JSON.parse(new TextDecoder().decode(encoded));
@@ -37758,7 +37906,6 @@ var OtelRuntimeTelemetry = class {
37758
37906
  return new NoopRuntimeObservation();
37759
37907
  }
37760
37908
  const state = {
37761
- agentId: input.agentId,
37762
37909
  sequence: 0,
37763
37910
  route: auth2 ? this.queue.authorize(auth2) : void 0,
37764
37911
  attributes: sanitizeTelemetryAttributes({
@@ -37814,7 +37961,6 @@ var OtelRuntimeTelemetry = class {
37814
37961
  isRemote: upstream !== null,
37815
37962
  traceState: parentContext.traceState ? createTraceState(parentContext.traceState) : void 0
37816
37963
  });
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;
37818
37964
  const attributes = sanitizeTelemetryAttributes({
37819
37965
  ...state.attributes,
37820
37966
  ...parent?.attributes,
@@ -37832,11 +37978,11 @@ var OtelRuntimeTelemetry = class {
37832
37978
  ETelemetryAttribute.LINKQUE_CONVERSATION_ID
37833
37979
  ].some((attribute) => attribute === key))),
37834
37980
  [ETelemetryAttribute.LINKQUE_OPERATION_ID]: randomUUID5(),
37835
- [ETelemetryAttribute.LINKQUE_OPERATION_NAME]: spanName,
37981
+ [ETelemetryAttribute.LINKQUE_OPERATION_NAME]: spec.name,
37836
37982
  [ETelemetryAttribute.LINKQUE_OPERATION_PARENT_ID]: spec.detached ? "" : parent?.operationId ?? "",
37837
37983
  [ETelemetryAttribute.LINKQUE_SPAN_PARENT_ID]: spec.detached ? "" : parentContext?.spanId ?? ""
37838
37984
  });
37839
- const span = this.tracerProvider.getTracer(ETelemetryMetadata.SCOPE_NAME, ETelemetryVersion.V1_0).startSpan(spanName.slice(0, 256), {
37985
+ const span = this.tracerProvider.getTracer(ETelemetryMetadata.SCOPE_NAME, ETelemetryVersion.V1_0).startSpan(spec.name, {
37840
37986
  kind: spec.name === ETelemetryOperationName.MODEL_ATTEMPT ? SpanKind.CLIENT : SpanKind.INTERNAL,
37841
37987
  attributes,
37842
37988
  links: spec.links.filter((link) => validContext(link.context)).slice(0, 16).map((link) => ({
@@ -37864,7 +38010,7 @@ var OtelRuntimeTelemetry = class {
37864
38010
  operation.record(`${spec.eventPrefix}.${ETelemetryEventPhase.STARTED}`, {});
37865
38011
  return operation;
37866
38012
  }
37867
- emit(operation, name, attributes, critical) {
38013
+ emit(operation, name, attributes, critical, body) {
37868
38014
  if (this.disposed || this.queue.isExporting)
37869
38015
  return;
37870
38016
  const contextAttributes = operation.attributes;
@@ -37891,18 +38037,24 @@ var OtelRuntimeTelemetry = class {
37891
38037
  Math.floor(now / 1e3),
37892
38038
  now % 1e3 * 1e6
37893
38039
  ];
37894
- if (operation.span.isRecording())
38040
+ const localOnly = name === ETelemetryEventName.DEBUG_CONTENT_RECORDED;
38041
+ if (!localOnly && operation.span.isRecording())
37895
38042
  operation.span.addEvent(
37896
38043
  name,
37897
38044
  // 复用已投影的属性;Span 已持有上下文,事件只保留本次事实及去重字段。
37898
38045
  Object.fromEntries(Object.entries(record2).filter(([key]) => Object.hasOwn(attributes, key) || key === ETelemetryAttribute.HARNESS_RECORD_ID || key === ETelemetryAttribute.HARNESS_EVENT_SEQUENCE)),
37899
38046
  time
37900
38047
  );
37901
- const ctx = trace.setSpan(ROOT_CONTEXT, operation.span).setValue(this.routeKey, { route: operation.state.route, critical });
38048
+ const ctx = trace.setSpan(ROOT_CONTEXT, operation.span).setValue(this.routeKey, {
38049
+ route: operation.state.route,
38050
+ critical,
38051
+ localOnly
38052
+ });
37902
38053
  this.loggerProvider.getLogger(ETelemetryMetadata.SCOPE_NAME, ETelemetryVersion.V1_0).emit({
37903
38054
  eventName: name,
37904
38055
  timestamp: time,
37905
38056
  observedTimestamp: time,
38057
+ ...body !== void 0 ? { body } : {},
37906
38058
  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,
37907
38059
  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],
37908
38060
  attributes: record2,
@@ -37973,10 +38125,11 @@ var OtelObservation = class {
37973
38125
  return new NoopRuntimeObservation();
37974
38126
  return this.owner.createOperation(this.state, spec, this);
37975
38127
  }
37976
- record(name, attributes) {
38128
+ record(name, attributes, body) {
37977
38129
  if (this.lost || !/^(harness|linkque)\.[a-z0-9_.]{1,128}$/.test(name))
37978
38130
  return;
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}`));
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);
37980
38133
  }
37981
38134
  finish(outcome, attributes) {
37982
38135
  if (this.ended)
@@ -38022,6 +38175,8 @@ function validContext(value) {
38022
38175
  export {
38023
38176
  EModelRequestSource,
38024
38177
  EDebugLogScope,
38178
+ isDebugLoggingEnabled,
38179
+ createRuntimeDebugLog,
38025
38180
  EModelProvider,
38026
38181
  EResourceType,
38027
38182
  EResourceProviderType,
@@ -38065,6 +38220,7 @@ export {
38065
38220
  ETelemetryAttribute,
38066
38221
  ETelemetryEventPrefix,
38067
38222
  ETelemetryEventName,
38223
+ ETelemetryContentSection,
38068
38224
  ETelemetryOperationName,
38069
38225
  ETelemetryOutcome,
38070
38226
  ETelemetryLossReason,
@@ -38100,6 +38256,8 @@ export {
38100
38256
  summarizeBody,
38101
38257
  formatHttpLogLine,
38102
38258
  LinkquegwEventHookExecutor,
38259
+ recordContentSection,
38260
+ ACTIVATE_SKILL_TOOL_NAME,
38103
38261
  parseSkillFile,
38104
38262
  buildSkillCatalog,
38105
38263
  createActivateSkillTool,
@@ -40,14 +40,15 @@ import {
40
40
  resolveRunStorage,
41
41
  toAgentRunMessages,
42
42
  withIsoTimestamp
43
- } from "../../chunk-CUMXO6KK.js";
43
+ } from "../../chunk-SAQYWJAA.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-XL6BPKTI.js";
49
+ } from "../../chunk-OMFQ2KRJ.js";
50
50
  import {
51
+ ACTIVATE_SKILL_TOOL_NAME,
51
52
  CANCEL_CONVERSATION_RUN_OPERATION,
52
53
  CONVERSATION_HISTORY_VERSION,
53
54
  CardActionDiagnostics,
@@ -74,6 +75,7 @@ import {
74
75
  ETelemetryCancelSource,
75
76
  ETelemetryCommitStatus,
76
77
  ETelemetryCompleteness,
78
+ ETelemetryContentSection,
77
79
  ETelemetryCoverage,
78
80
  ETelemetryErrorType,
79
81
  ETelemetryEventName,
@@ -119,6 +121,7 @@ import {
119
121
  createCardPresentationToolName,
120
122
  createKnowledgeTools,
121
123
  createPresentationDescription,
124
+ createRuntimeDebugLog,
122
125
  createWebSearchTool,
123
126
  encodeConversationSseEvent,
124
127
  executeA2UICardResolver,
@@ -149,6 +152,7 @@ import {
149
152
  projectPresentationReceiptForModel,
150
153
  readJsonPointer,
151
154
  readStructuredContent,
155
+ recordContentSection,
152
156
  redactHeaders,
153
157
  resolvePhoneAuthorizationDependency,
154
158
  resolveWebSearchResource,
@@ -158,7 +162,7 @@ import {
158
162
  summarizeBody,
159
163
  warnLogFailure,
160
164
  wrapToolWithHooks
161
- } from "../../chunk-OHRCYI66.js";
165
+ } from "../../chunk-Y36JLYIE.js";
162
166
  import "../../chunk-EAODRPW4.js";
163
167
  import "../../chunk-XUFLSZM4.js";
164
168
  import "../../chunk-GAYNLDWK.js";
@@ -7945,6 +7949,7 @@ import { randomUUID as randomUUID7 } from "node:crypto";
7945
7949
 
7946
7950
  // ../linkque-agent-runtime/dist/esm/core/telemetry/toolObservation.js
7947
7951
  import { randomUUID } from "node:crypto";
7952
+ var isSkillTool = (tool) => (tool.modelName ?? tool.name) === ACTIVATE_SKILL_TOOL_NAME;
7948
7953
  function toolResultOutcome(result) {
7949
7954
  try {
7950
7955
  if (!(result && typeof result === "object")) {
@@ -7978,8 +7983,19 @@ function observeTool(tool, observation) {
7978
7983
  detached: false,
7979
7984
  links: []
7980
7985
  });
7986
+ const captureBody = !isSkillTool(tool);
7981
7987
  try {
7982
- const result = await tool.execute(args, signal, context);
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
+ }
7983
7999
  operation.finish(toolResultOutcome(result), {
7984
8000
  [ETelemetryAttribute.HARNESS_TOOL_RESULT_STATUS]: toolResultOutcome(result)
7985
8001
  });
@@ -41941,11 +41957,36 @@ var AgentRuntime = class _AgentRuntime {
41941
41957
  }
41942
41958
  }, (observation) => this.runObservedAdvance(request, auth, options, observation), options.signal);
41943
41959
  }
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
+ }
41944
41984
  async *runObservedAdvance(request, auth, options, observation) {
41945
41985
  observation.record(ETelemetryEventName.TELEMETRY_COVERAGE, {
41946
41986
  [ETelemetryAttribute.LINKQUE_TELEMETRY_COVERAGE]: this.agentLoop instanceof PiAgentLoop ? ETelemetryCoverage.PI_MODEL_TOOL_HOOK : ETelemetryCoverage.CORE_ONLY,
41947
41987
  [ETelemetryAttribute.HARNESS_TELEMETRY_COMPLETENESS]: this.agentLoop instanceof PiAgentLoop ? ETelemetryCompleteness.COMPLETE : ETelemetryCompleteness.PARTIAL
41948
41988
  });
41989
+ this.recordCurrentQuery(observation, request);
41949
41990
  const cleanup = [];
41950
41991
  let termination = ETelemetryStreamTermination.CANCEL;
41951
41992
  let failed = false;
@@ -43058,10 +43099,10 @@ function resolveLinkqueEndpoints(env, envSelector) {
43058
43099
  }
43059
43100
  function createAppBaseRuntime(protocol, env = process.env, ports = {}, logCtx) {
43060
43101
  const log = (...a) => logCtx?.log?.("[runtime-factory]", ...a);
43061
- const debugLog = logCtx?.log ? (line, scope) => {
43102
+ const debugLog = logCtx?.log ? createRuntimeDebugLog(new AppbaseRuntimeConfigProvider(env).get("LOG_LEVEL"), (line, scope) => {
43062
43103
  const prefix = scope ? `[${scope}] ` : "";
43063
43104
  logCtx.log?.(prefix + line);
43064
- } : void 0;
43105
+ }) : void 0;
43065
43106
  const runtimePorts = {};
43066
43107
  if (ports.telemetry)
43067
43108
  runtimePorts.telemetry = ports.telemetry;
@@ -3,11 +3,11 @@ import {
3
3
  runClientCapability,
4
4
  runClientCapabilityCleanup,
5
5
  runClientCapabilityResult
6
- } from "../../chunk-CUMXO6KK.js";
6
+ } from "../../chunk-SAQYWJAA.js";
7
7
  import "../../chunk-IWOFD643.js";
8
8
  import "../../chunk-PXCGFBV5.js";
9
9
  import "../../chunk-ETG6PNHQ.js";
10
- import "../../chunk-OHRCYI66.js";
10
+ import "../../chunk-Y36JLYIE.js";
11
11
  import "../../chunk-EAODRPW4.js";
12
12
  import "../../chunk-XUFLSZM4.js";
13
13
  import "../../chunk-GAYNLDWK.js";