linkque-cli-v2 1.4.4 → 1.4.5

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  EModelProvider
3
- } from "./chunk-OHRCYI66.js";
3
+ } from "./chunk-CLYLJ5MD.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-CLYLJ5MD.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);
@@ -40,15 +40,17 @@ import {
40
40
  resolveRunStorage,
41
41
  toAgentRunMessages,
42
42
  withIsoTimestamp
43
- } from "../../chunk-CUMXO6KK.js";
43
+ } from "../../chunk-S75HFRLD.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-NFVKWQGM.js";
50
50
  import {
51
+ ACTIVATE_SKILL_TOOL_NAME,
51
52
  CANCEL_CONVERSATION_RUN_OPERATION,
53
+ CONTENT_VALUE_MAX_LENGTH,
52
54
  CONVERSATION_HISTORY_VERSION,
53
55
  CardActionDiagnostics,
54
56
  CardMappingError,
@@ -74,6 +76,7 @@ import {
74
76
  ETelemetryCancelSource,
75
77
  ETelemetryCommitStatus,
76
78
  ETelemetryCompleteness,
79
+ ETelemetryContentSection,
77
80
  ETelemetryCoverage,
78
81
  ETelemetryErrorType,
79
82
  ETelemetryEventName,
@@ -119,6 +122,7 @@ import {
119
122
  createCardPresentationToolName,
120
123
  createKnowledgeTools,
121
124
  createPresentationDescription,
125
+ createRuntimeDebugLog,
122
126
  createWebSearchTool,
123
127
  encodeConversationSseEvent,
124
128
  executeA2UICardResolver,
@@ -149,6 +153,7 @@ import {
149
153
  projectPresentationReceiptForModel,
150
154
  readJsonPointer,
151
155
  readStructuredContent,
156
+ recordContentSection,
152
157
  redactHeaders,
153
158
  resolvePhoneAuthorizationDependency,
154
159
  resolveWebSearchResource,
@@ -158,7 +163,7 @@ import {
158
163
  summarizeBody,
159
164
  warnLogFailure,
160
165
  wrapToolWithHooks
161
- } from "../../chunk-OHRCYI66.js";
166
+ } from "../../chunk-CLYLJ5MD.js";
162
167
  import "../../chunk-EAODRPW4.js";
163
168
  import "../../chunk-XUFLSZM4.js";
164
169
  import "../../chunk-GAYNLDWK.js";
@@ -7945,15 +7950,16 @@ import { randomUUID as randomUUID7 } from "node:crypto";
7945
7950
 
7946
7951
  // ../linkque-agent-runtime/dist/esm/core/telemetry/toolObservation.js
7947
7952
  import { randomUUID } from "node:crypto";
7953
+ var isSkillTool = (tool) => (tool.modelName ?? tool.name) === ACTIVATE_SKILL_TOOL_NAME;
7948
7954
  function toolResultOutcome(result) {
7949
7955
  try {
7950
7956
  if (!(result && typeof result === "object")) {
7951
7957
  return ETelemetryOutcome.UNKNOWN;
7952
7958
  }
7953
7959
  const record2 = result;
7954
- if (record2.isError === true || record2.ok === false || record2.success === false)
7960
+ if (record2.isError === true)
7955
7961
  return ETelemetryOutcome.ERROR;
7956
- if (record2.isError === false || record2.ok === true || record2.success === true || record2.type === "linkque.presentation-tool-result")
7962
+ if (record2.isError === false || record2.type === "linkque.presentation-tool-result")
7957
7963
  return ETelemetryOutcome.SUCCESS;
7958
7964
  } catch {
7959
7965
  }
@@ -7978,8 +7984,19 @@ function observeTool(tool, observation) {
7978
7984
  detached: false,
7979
7985
  links: []
7980
7986
  });
7987
+ const captureBody = !isSkillTool(tool);
7981
7988
  try {
7982
- const result = await tool.execute(args, signal, context);
7989
+ if (captureBody) {
7990
+ recordContentSection(operation, ETelemetryContentSection.TOOL_INPUT, args);
7991
+ }
7992
+ const execContext = {
7993
+ ...context ?? { toolCallId: "", emit: () => void 0 },
7994
+ observation: operation
7995
+ };
7996
+ const result = await tool.execute(args, signal, execContext);
7997
+ if (captureBody) {
7998
+ recordContentSection(operation, ETelemetryContentSection.TOOL_OUTPUT, result);
7999
+ }
7983
8000
  operation.finish(toolResultOutcome(result), {
7984
8001
  [ETelemetryAttribute.HARNESS_TOOL_RESULT_STATUS]: toolResultOutcome(result)
7985
8002
  });
@@ -8003,6 +8020,44 @@ import { randomUUID as randomUUID2 } from "node:crypto";
8003
8020
  var PiTelemetry = class {
8004
8021
  root;
8005
8022
  iterationIndex = 0;
8023
+ replyText = "";
8024
+ replyBytes = 0;
8025
+ replyIndex = 0;
8026
+ replyTruncated = false;
8027
+ maxReplyBytes = 512 * 1024;
8028
+ /** 正文分块独立落盘;每条最坏 JSON 编码也低于日志单行 1 MiB 上限。 */
8029
+ recordReplyChunk(final, complete) {
8030
+ this.root.find(ETelemetryAssociation.MODEL)?.record(ETelemetryEventName.CONTENT_RECORDED, {}, {
8031
+ section: ETelemetryContentSection.MODEL_OUTPUT,
8032
+ value: this.replyText,
8033
+ chunkIndex: this.replyIndex++,
8034
+ final,
8035
+ availability: final && complete && !this.replyTruncated ? "available" : "partial"
8036
+ });
8037
+ this.replyText = "";
8038
+ }
8039
+ flushReply(complete) {
8040
+ if (this.replyBytes)
8041
+ this.recordReplyChunk(true, complete);
8042
+ this.replyBytes = 0;
8043
+ this.replyIndex = 0;
8044
+ this.replyTruncated = false;
8045
+ }
8046
+ appendReply(text2) {
8047
+ if (this.replyTruncated)
8048
+ return;
8049
+ for (const character of text2) {
8050
+ const bytes = Buffer.byteLength(character, "utf8");
8051
+ if (this.replyBytes + bytes > this.maxReplyBytes) {
8052
+ this.replyTruncated = true;
8053
+ break;
8054
+ }
8055
+ this.replyText += character;
8056
+ this.replyBytes += bytes;
8057
+ if (this.replyText.length >= 16 * 1024)
8058
+ this.recordReplyChunk(false, false);
8059
+ }
8060
+ }
8006
8061
  proposed = /* @__PURE__ */ new Map();
8007
8062
  loop;
8008
8063
  lastProvider = null;
@@ -8104,6 +8159,7 @@ var PiTelemetry = class {
8104
8159
  }
8105
8160
  case "message_end":
8106
8161
  if (event.message.role === "assistant") {
8162
+ this.flushReply(event.message.stopReason !== "error" && event.message.stopReason !== "aborted");
8107
8163
  const failed = event.message.stopReason === "error" || event.message.stopReason === "aborted";
8108
8164
  this.root.find(ETelemetryAssociation.MODEL)?.finish(event.message.stopReason === "aborted" ? ETelemetryOutcome.CANCELLED : failed ? ETelemetryOutcome.ERROR : ETelemetryOutcome.SUCCESS, {
8109
8165
  [ETelemetryAttribute.GEN_AI_RESPONSE_FINISH_REASONS]: [
@@ -8118,6 +8174,8 @@ var PiTelemetry = class {
8118
8174
  break;
8119
8175
  case "message_update": {
8120
8176
  const update = event.assistantMessageEvent;
8177
+ if (update.type === "text_delta")
8178
+ this.appendReply(update.delta);
8121
8179
  if (update.type === "text_delta" && update.delta && !this.publicTextSeen) {
8122
8180
  this.publicTextSeen = true;
8123
8181
  this.loop.record(ETelemetryEventName.LOOP_FIRST_PUBLIC_TEXT, {
@@ -8148,6 +8206,7 @@ var PiTelemetry = class {
8148
8206
  this.terminal = ETelemetryStreamTermination.ERROR;
8149
8207
  }
8150
8208
  close(cancelled) {
8209
+ this.flushReply(false);
8151
8210
  this.proposed.clear();
8152
8211
  this.loop.finish(this.terminal === ETelemetryStreamTermination.ERROR ? ETelemetryOutcome.ERROR : cancelled || this.terminal === ETelemetryStreamTermination.CANCEL ? ETelemetryOutcome.CANCELLED : this.terminal === ETelemetryStreamTermination.COMPLETE ? ETelemetryOutcome.SUCCESS : ETelemetryOutcome.UNKNOWN, {
8153
8212
  [ETelemetryAttribute.LINKQUE_STREAM_TERMINATION]: this.terminal === ETelemetryStreamTermination.ERROR ? ETelemetryStreamTermination.ERROR : cancelled ? ETelemetryStreamTermination.CANCEL : this.terminal
@@ -41941,11 +42000,38 @@ var AgentRuntime = class _AgentRuntime {
41941
42000
  }
41942
42001
  }, (observation) => this.runObservedAdvance(request, auth, options, observation), options.signal);
41943
42002
  }
42003
+ /**
42004
+ * 记录本次用户输入(RFC §4.1):取进入 Runtime 的本次新消息中最后一条 user message
42005
+ * 的 content,作为 `linkque.content.recorded` 的 body 走 record 链路落入
42006
+ * OTLP logs(body 含 section/value/availability)。不以模型 messages 上下文为输入;
42007
+ * 无 user 文本(卡片交互等)时按可用性如实标记,不伪造自然语言 Query。
42008
+ */
42009
+ recordCurrentQuery(observation, request) {
42010
+ let lastUser;
42011
+ for (const message of request.messages) {
42012
+ if (message.role === "user")
42013
+ lastUser = message;
42014
+ }
42015
+ const content = lastUser?.content;
42016
+ const text2 = typeof content === "string" && content ? content : void 0;
42017
+ const value = text2?.slice(0, CONTENT_VALUE_MAX_LENGTH);
42018
+ const truncated = text2 !== void 0 && text2.length > CONTENT_VALUE_MAX_LENGTH;
42019
+ const card = content && typeof content === "object" && "type" in content && content.type === "a2ui.event" ? content : void 0;
42020
+ const displayText = card && "displayText" in card && typeof card.displayText === "string" && card.displayText ? card.displayText : void 0;
42021
+ const body = {
42022
+ section: ETelemetryContentSection.QUERY_INPUT,
42023
+ ...value !== void 0 ? { value } : {},
42024
+ ...card ? { inputType: "card", ...displayText ? { displayText } : {} } : {},
42025
+ availability: text2 !== void 0 || card ? "available" : "not_recorded"
42026
+ };
42027
+ observation.record(ETelemetryEventName.CONTENT_RECORDED, { [ETelemetryAttribute.LINKQUE_CONTENT_VALUE_TRUNCATED]: truncated }, body);
42028
+ }
41944
42029
  async *runObservedAdvance(request, auth, options, observation) {
41945
42030
  observation.record(ETelemetryEventName.TELEMETRY_COVERAGE, {
41946
42031
  [ETelemetryAttribute.LINKQUE_TELEMETRY_COVERAGE]: this.agentLoop instanceof PiAgentLoop ? ETelemetryCoverage.PI_MODEL_TOOL_HOOK : ETelemetryCoverage.CORE_ONLY,
41947
42032
  [ETelemetryAttribute.HARNESS_TELEMETRY_COMPLETENESS]: this.agentLoop instanceof PiAgentLoop ? ETelemetryCompleteness.COMPLETE : ETelemetryCompleteness.PARTIAL
41948
42033
  });
42034
+ this.recordCurrentQuery(observation, request);
41949
42035
  const cleanup = [];
41950
42036
  let termination = ETelemetryStreamTermination.CANCEL;
41951
42037
  let failed = false;
@@ -43058,10 +43144,10 @@ function resolveLinkqueEndpoints(env, envSelector) {
43058
43144
  }
43059
43145
  function createAppBaseRuntime(protocol, env = process.env, ports = {}, logCtx) {
43060
43146
  const log = (...a) => logCtx?.log?.("[runtime-factory]", ...a);
43061
- const debugLog = logCtx?.log ? (line, scope) => {
43147
+ const debugLog = logCtx?.log ? createRuntimeDebugLog(new AppbaseRuntimeConfigProvider(env).get("LOG_LEVEL"), (line, scope) => {
43062
43148
  const prefix = scope ? `[${scope}] ` : "";
43063
43149
  logCtx.log?.(prefix + line);
43064
- } : void 0;
43150
+ }) : void 0;
43065
43151
  const runtimePorts = {};
43066
43152
  if (ports.telemetry)
43067
43153
  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-S75HFRLD.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-CLYLJ5MD.js";
11
11
  import "../../chunk-EAODRPW4.js";
12
12
  import "../../chunk-XUFLSZM4.js";
13
13
  import "../../chunk-GAYNLDWK.js";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  getBakedProtocol,
3
3
  setBakedProtocol
4
- } from "../chunk-XL6BPKTI.js";
5
- import "../chunk-OHRCYI66.js";
4
+ } from "../chunk-NFVKWQGM.js";
5
+ import "../chunk-CLYLJ5MD.js";
6
6
  import "../chunk-EAODRPW4.js";
7
7
  import "../chunk-XUFLSZM4.js";
8
8
  import "../chunk-GAYNLDWK.js";
@@ -1 +1 @@
1
- {"name":"@alipay/linkque-agent-appwrite-integrate","version":"1.0.2-beta.0","type":"module"}
1
+ {"name":"@alipay/linkque-agent-appwrite-integrate","version":"1.4.5","type":"module"}