linkque-cli-v2 1.4.1 → 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/linkquejs.js +1162 -324
- package/package.json +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-XL6BPKTI.js → chunk-OMFQ2KRJ.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-CUMXO6KK.js → chunk-SAQYWJAA.js} +4 -3
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-OHRCYI66.js → chunk-Y36JLYIE.js} +194 -36
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js +569 -216
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/clientCapability.js +2 -2
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/protocol.js +2 -2
- package/vendor/linkque-agent-appwrite-integrate/package.json +1 -1
- package/worker.js +284 -53
package/worker.js
CHANGED
|
@@ -45,6 +45,7 @@ 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";
|
|
48
49
|
EDebugLogScope2["HTTP"] = "HTTP";
|
|
49
50
|
EDebugLogScope2["HOOK"] = "HOOK";
|
|
50
51
|
})(EDebugLogScope || (EDebugLogScope = {}));
|
|
@@ -4361,13 +4362,14 @@ var require_fast_uri = __commonJS({
|
|
|
4361
4362
|
if (!malformedIPLiteral) {
|
|
4362
4363
|
malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP2);
|
|
4363
4364
|
}
|
|
4364
|
-
if (
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
parsed.host = reescapeHostDelimiters(host, isIP2);
|
|
4369
|
-
}
|
|
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());
|
|
4370
4369
|
}
|
|
4370
|
+
parsed.host = reescapeHostDelimiters(host, isIP2);
|
|
4371
|
+
}
|
|
4372
|
+
if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
|
|
4371
4373
|
if (parsed.path) {
|
|
4372
4374
|
parsed.path = normalizePathEncoding(parsed.path);
|
|
4373
4375
|
}
|
|
@@ -12015,6 +12017,10 @@ var init_mcpProxyTool = __esm({
|
|
|
12015
12017
|
context: context2
|
|
12016
12018
|
});
|
|
12017
12019
|
return entry.server.callTool(tool.name, args, sig, {
|
|
12020
|
+
toolSchema: {
|
|
12021
|
+
inputSchema: tool.inputSchema,
|
|
12022
|
+
outputSchema: tool.outputSchema
|
|
12023
|
+
},
|
|
12018
12024
|
...headers ? { headers } : {},
|
|
12019
12025
|
...context2 ? { context: context2 } : {}
|
|
12020
12026
|
});
|
|
@@ -12262,6 +12268,10 @@ ${formatSchema(tool.inputSchema)}`);
|
|
|
12262
12268
|
context: context2
|
|
12263
12269
|
});
|
|
12264
12270
|
const result = await entry.server.callTool(tool.name, args, signal, {
|
|
12271
|
+
toolSchema: {
|
|
12272
|
+
inputSchema: tool.inputSchema,
|
|
12273
|
+
outputSchema: tool.outputSchema
|
|
12274
|
+
},
|
|
12265
12275
|
...headers ? { headers } : {},
|
|
12266
12276
|
...context2 ? { context: context2 } : {}
|
|
12267
12277
|
});
|
|
@@ -12627,7 +12637,7 @@ var init_hookRegistry = __esm({
|
|
|
12627
12637
|
});
|
|
12628
12638
|
|
|
12629
12639
|
// ../linkque-agent-protocol/dist/esm/telemetry/telemetryEnums.js
|
|
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;
|
|
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;
|
|
12631
12641
|
var init_telemetryEnums = __esm({
|
|
12632
12642
|
"../linkque-agent-protocol/dist/esm/telemetry/telemetryEnums.js"() {
|
|
12633
12643
|
"use strict";
|
|
@@ -12786,7 +12796,20 @@ var init_telemetryEnums = __esm({
|
|
|
12786
12796
|
ETelemetryEventName2["HISTORY_APPEND_FINISHED"] = "linkque.history.append.finished";
|
|
12787
12797
|
ETelemetryEventName2["HOOK_DRAIN_STARTED"] = "linkque.hook.drain.started";
|
|
12788
12798
|
ETelemetryEventName2["HOOK_DRAIN_FINISHED"] = "linkque.hook.drain.finished";
|
|
12799
|
+
ETelemetryEventName2["DEBUG_CONTENT_RECORDED"] = "linkque.debug.content.recorded";
|
|
12789
12800
|
})(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 = {}));
|
|
12790
12813
|
(function(ETelemetryOperationName2) {
|
|
12791
12814
|
ETelemetryOperationName2["OPERATION"] = "linkque.operation";
|
|
12792
12815
|
ETelemetryOperationName2["TOOL_INVOKE"] = "harness.tool.invoke";
|
|
@@ -14184,6 +14207,43 @@ var init_linkquegwEventHookExecutor = __esm({
|
|
|
14184
14207
|
}
|
|
14185
14208
|
});
|
|
14186
14209
|
|
|
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
|
+
|
|
14187
14247
|
// ../linkque-agent-runtime/dist/esm/core/skillTools.js
|
|
14188
14248
|
function parseSkillFile(raw, fallbackName) {
|
|
14189
14249
|
const parsed = splitFrontmatter(raw);
|
|
@@ -14252,18 +14312,45 @@ function createActivateSkillTool(records) {
|
|
|
14252
14312
|
required: ["name"],
|
|
14253
14313
|
additionalProperties: false
|
|
14254
14314
|
},
|
|
14255
|
-
execute: async (args) => {
|
|
14315
|
+
execute: async (args, _signal, context2) => {
|
|
14256
14316
|
const name = extractName(args);
|
|
14257
|
-
|
|
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
|
+
});
|
|
14258
14328
|
return "\u6FC0\u6D3B\u6280\u80FD\u5931\u8D25:\u7F3A\u5C11 name \u53C2\u6570\u3002";
|
|
14329
|
+
}
|
|
14259
14330
|
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
|
+
});
|
|
14260
14337
|
return `\u6FC0\u6D3B\u6280\u80FD\u5931\u8D25:\u672A\u627E\u5230\u6280\u80FD "${name}"\u3002\u53EF\u7528:${[...bodyByName.keys()].join(", ")}`;
|
|
14261
14338
|
}
|
|
14262
14339
|
if (activated.has(name)) {
|
|
14340
|
+
recordContentSection(obs, ETelemetryContentSection.SKILL_OUTPUT, {
|
|
14341
|
+
name,
|
|
14342
|
+
status: "already_loaded",
|
|
14343
|
+
durationMs: Date.now() - startedAt
|
|
14344
|
+
});
|
|
14263
14345
|
return `\u6280\u80FD "${name}" \u5DF2\u5728\u672C\u8F6E\u52A0\u8F7D,\u65E0\u9700\u91CD\u590D\u6FC0\u6D3B\u3002`;
|
|
14264
14346
|
}
|
|
14265
14347
|
activated.add(name);
|
|
14266
14348
|
const body = bodyByName.get(name) ?? "";
|
|
14349
|
+
recordContentSection(obs, ETelemetryContentSection.SKILL_OUTPUT, {
|
|
14350
|
+
name,
|
|
14351
|
+
status: "loaded",
|
|
14352
|
+
durationMs: Date.now() - startedAt
|
|
14353
|
+
});
|
|
14267
14354
|
return `<skill name="${escapeXml(name)}">
|
|
14268
14355
|
${body}
|
|
14269
14356
|
</skill>`;
|
|
@@ -14321,6 +14408,8 @@ var ACTIVATE_SKILL_TOOL_NAME, AVAILABLE_SKILLS_OPEN, AVAILABLE_SKILLS_CLOSE;
|
|
|
14321
14408
|
var init_skillTools = __esm({
|
|
14322
14409
|
"../linkque-agent-runtime/dist/esm/core/skillTools.js"() {
|
|
14323
14410
|
"use strict";
|
|
14411
|
+
init_telemetry();
|
|
14412
|
+
init_contentRecording();
|
|
14324
14413
|
ACTIVATE_SKILL_TOOL_NAME = "activate_skill";
|
|
14325
14414
|
AVAILABLE_SKILLS_OPEN = "<available_skills>";
|
|
14326
14415
|
AVAILABLE_SKILLS_CLOSE = "</available_skills>";
|
|
@@ -14548,7 +14637,7 @@ function createKnowledgeTools(resources, searchPort, agentId) {
|
|
|
14548
14637
|
additionalProperties: false
|
|
14549
14638
|
},
|
|
14550
14639
|
annotations: { readOnlyHint: true },
|
|
14551
|
-
execute: () => listKnowledge()
|
|
14640
|
+
execute: (_args, _signal, context2) => listKnowledge(context2)
|
|
14552
14641
|
},
|
|
14553
14642
|
{
|
|
14554
14643
|
name: KNOWLEDGE_RECALL_TOOL_NAME,
|
|
@@ -14575,24 +14664,48 @@ function createKnowledgeTools(resources, searchPort, agentId) {
|
|
|
14575
14664
|
additionalProperties: false
|
|
14576
14665
|
},
|
|
14577
14666
|
annotations: { readOnlyHint: true },
|
|
14578
|
-
execute: (args, signal) => recallKnowledge(args, signal)
|
|
14667
|
+
execute: (args, signal, context2) => recallKnowledge(args, signal, context2)
|
|
14579
14668
|
}
|
|
14580
14669
|
];
|
|
14581
|
-
async function listKnowledge() {
|
|
14582
|
-
|
|
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;
|
|
14583
14679
|
}
|
|
14584
|
-
async function recallKnowledge(args, signal) {
|
|
14680
|
+
async function recallKnowledge(args, signal, context2) {
|
|
14585
14681
|
const parsed = parseRecallArgs(args);
|
|
14682
|
+
const obs = context2?.observation;
|
|
14586
14683
|
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
|
+
});
|
|
14587
14692
|
return { hits: [], error: parsed.error };
|
|
14588
14693
|
}
|
|
14694
|
+
recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_INPUT, {
|
|
14695
|
+
knowledgeBaseId: parsed.knowledgeBaseId,
|
|
14696
|
+
query: parsed.query,
|
|
14697
|
+
topK: parsed.topK
|
|
14698
|
+
});
|
|
14589
14699
|
const knowledgeBases = await getKnowledgeBases();
|
|
14590
14700
|
const bound = knowledgeBases.some((info) => info.knowledgeBaseId === parsed.knowledgeBaseId);
|
|
14591
14701
|
if (!bound) {
|
|
14592
|
-
|
|
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",
|
|
14593
14705
|
hits: [],
|
|
14594
|
-
error:
|
|
14595
|
-
};
|
|
14706
|
+
error: error40
|
|
14707
|
+
});
|
|
14708
|
+
return { hits: [], error: error40 };
|
|
14596
14709
|
}
|
|
14597
14710
|
try {
|
|
14598
14711
|
const result = await searchPort.search({
|
|
@@ -14601,10 +14714,20 @@ function createKnowledgeTools(resources, searchPort, agentId) {
|
|
|
14601
14714
|
agentId,
|
|
14602
14715
|
topK: parsed.topK
|
|
14603
14716
|
}, signal);
|
|
14717
|
+
recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_OUTPUT, {
|
|
14718
|
+
status: result.hits.length ? "matched" : "no_hits",
|
|
14719
|
+
hits: result.hits
|
|
14720
|
+
});
|
|
14604
14721
|
return { hits: result.hits };
|
|
14605
14722
|
} catch (e2) {
|
|
14606
14723
|
const msg = e2 instanceof Error ? e2.message : String(e2);
|
|
14607
|
-
|
|
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 };
|
|
14608
14731
|
}
|
|
14609
14732
|
}
|
|
14610
14733
|
async function getKnowledgeBases() {
|
|
@@ -14618,6 +14741,8 @@ var init_createKnowledgeTools = __esm({
|
|
|
14618
14741
|
"../linkque-agent-runtime/dist/esm/core/createKnowledgeTools.js"() {
|
|
14619
14742
|
"use strict";
|
|
14620
14743
|
init_knowledgeTools();
|
|
14744
|
+
init_telemetry();
|
|
14745
|
+
init_contentRecording();
|
|
14621
14746
|
}
|
|
14622
14747
|
});
|
|
14623
14748
|
|
|
@@ -14648,7 +14773,7 @@ var init_noopRuntimeTelemetry = __esm({
|
|
|
14648
14773
|
startOperation(_operation) {
|
|
14649
14774
|
return this;
|
|
14650
14775
|
}
|
|
14651
|
-
record(_name, _attributes) {
|
|
14776
|
+
record(_name, _attributes, _body) {
|
|
14652
14777
|
}
|
|
14653
14778
|
finish(_outcome, _attributes) {
|
|
14654
14779
|
}
|
|
@@ -14746,7 +14871,7 @@ var init_runtimeObservation = __esm({
|
|
|
14746
14871
|
find(key) {
|
|
14747
14872
|
return this.associations.get(key);
|
|
14748
14873
|
}
|
|
14749
|
-
record(name, attributes) {
|
|
14874
|
+
record(name, attributes, body) {
|
|
14750
14875
|
if (this.abandoned)
|
|
14751
14876
|
return;
|
|
14752
14877
|
try {
|
|
@@ -14754,7 +14879,7 @@ var init_runtimeObservation = __esm({
|
|
|
14754
14879
|
this.resultAttributes = {
|
|
14755
14880
|
[ETelemetryAttribute.LINKQUE_TOOL_FAILURE_STAGE]: attributes[ETelemetryAttribute.LINKQUE_TOOL_FAILURE_STAGE]
|
|
14756
14881
|
};
|
|
14757
|
-
this.sink.record(name, attributes);
|
|
14882
|
+
this.sink.record(name, attributes, body);
|
|
14758
14883
|
} catch {
|
|
14759
14884
|
}
|
|
14760
14885
|
}
|
|
@@ -49081,8 +49206,19 @@ function observeTool(tool, observation) {
|
|
|
49081
49206
|
detached: false,
|
|
49082
49207
|
links: []
|
|
49083
49208
|
});
|
|
49209
|
+
const captureBody = !isSkillTool(tool);
|
|
49084
49210
|
try {
|
|
49085
|
-
|
|
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
|
+
}
|
|
49086
49222
|
operation.finish(toolResultOutcome(result), {
|
|
49087
49223
|
[ETelemetryAttribute.HARNESS_TOOL_RESULT_STATUS]: toolResultOutcome(result)
|
|
49088
49224
|
});
|
|
@@ -49100,13 +49236,16 @@ function observeTool(tool, observation) {
|
|
|
49100
49236
|
}
|
|
49101
49237
|
};
|
|
49102
49238
|
}
|
|
49103
|
-
var import_node_crypto6;
|
|
49239
|
+
var import_node_crypto6, isSkillTool;
|
|
49104
49240
|
var init_toolObservation = __esm({
|
|
49105
49241
|
"../linkque-agent-runtime/dist/esm/core/telemetry/toolObservation.js"() {
|
|
49106
49242
|
"use strict";
|
|
49107
49243
|
init_telemetry();
|
|
49108
49244
|
init_telemetryEnums2();
|
|
49245
|
+
init_skillTools();
|
|
49109
49246
|
import_node_crypto6 = require("node:crypto");
|
|
49247
|
+
init_contentRecording();
|
|
49248
|
+
isSkillTool = (tool) => (tool.modelName ?? tool.name) === ACTIVATE_SKILL_TOOL_NAME;
|
|
49110
49249
|
}
|
|
49111
49250
|
});
|
|
49112
49251
|
|
|
@@ -207422,11 +207561,36 @@ var init_agentRuntime = __esm({
|
|
|
207422
207561
|
}
|
|
207423
207562
|
}, (observation) => this.runObservedAdvance(request, auth2, options, observation), options.signal);
|
|
207424
207563
|
}
|
|
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
|
+
}
|
|
207425
207588
|
async *runObservedAdvance(request, auth2, options, observation) {
|
|
207426
207589
|
observation.record(ETelemetryEventName.TELEMETRY_COVERAGE, {
|
|
207427
207590
|
[ETelemetryAttribute.LINKQUE_TELEMETRY_COVERAGE]: this.agentLoop instanceof PiAgentLoop ? ETelemetryCoverage.PI_MODEL_TOOL_HOOK : ETelemetryCoverage.CORE_ONLY,
|
|
207428
207591
|
[ETelemetryAttribute.HARNESS_TELEMETRY_COMPLETENESS]: this.agentLoop instanceof PiAgentLoop ? ETelemetryCompleteness.COMPLETE : ETelemetryCompleteness.PARTIAL
|
|
207429
207592
|
});
|
|
207593
|
+
this.recordCurrentQuery(observation, request);
|
|
207430
207594
|
const cleanup = [];
|
|
207431
207595
|
let termination = ETelemetryStreamTermination.CANCEL;
|
|
207432
207596
|
let failed = false;
|
|
@@ -207743,6 +207907,12 @@ var init_agentRuntime = __esm({
|
|
|
207743
207907
|
writing.finish(ETelemetryOutcome.SUCCESS, {
|
|
207744
207908
|
[ETelemetryAttribute.HARNESS_STATE_COMMIT_STATUS]: ETelemetryCommitStatus.COMMITTED
|
|
207745
207909
|
});
|
|
207910
|
+
if (this.followUpQuestionGenerationEnabled && options.onFollowUpQuestionSnapshot) {
|
|
207911
|
+
try {
|
|
207912
|
+
options.onFollowUpQuestionSnapshot(completedTurns.flatMap((turn) => (turn.role === "user" || turn.role === "assistant") && typeof turn.content === "string" ? [{ role: turn.role, content: turn.content }] : []));
|
|
207913
|
+
} catch {
|
|
207914
|
+
}
|
|
207915
|
+
}
|
|
207746
207916
|
} catch (error40) {
|
|
207747
207917
|
writing.finish(ETelemetryOutcome.ERROR, {
|
|
207748
207918
|
[ETelemetryAttribute.HARNESS_STATE_COMMIT_STATUS]: ETelemetryCommitStatus.FAILED
|
|
@@ -208525,6 +208695,22 @@ var EModelRequestSource;
|
|
|
208525
208695
|
|
|
208526
208696
|
// ../linkque-agent-runtime/dist/esm/core/index.js
|
|
208527
208697
|
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
|
|
208528
208714
|
init_esm();
|
|
208529
208715
|
init_cardTools();
|
|
208530
208716
|
init_mcpNaming();
|
|
@@ -214519,6 +214705,10 @@ init_esm();
|
|
|
214519
214705
|
|
|
214520
214706
|
// ../linkque-agent-runtime/dist/esm/impl/mcp/alipay/remoteGatewayMcpServer.js
|
|
214521
214707
|
var import_node_async_hooks2 = require("node:async_hooks");
|
|
214708
|
+
init_telemetry();
|
|
214709
|
+
init_logFailure();
|
|
214710
|
+
init_contentRecording();
|
|
214711
|
+
init_types();
|
|
214522
214712
|
|
|
214523
214713
|
// ../linkque-agent-runtime/dist/esm/impl/mcp/alipay/linkquegwTokenVerifier.js
|
|
214524
214714
|
init_config();
|
|
@@ -214565,8 +214755,6 @@ var LinkquegwTokenVerifier = class {
|
|
|
214565
214755
|
};
|
|
214566
214756
|
|
|
214567
214757
|
// ../linkque-agent-runtime/dist/esm/impl/mcp/alipay/remoteGatewayMcpServer.js
|
|
214568
|
-
init_types();
|
|
214569
|
-
init_logFailure();
|
|
214570
214758
|
var defaultCreateSigner = (config2, getAuthorizationHeader, debugLog) => new RemoteSignatureSigner({
|
|
214571
214759
|
agentId: config2.agentId,
|
|
214572
214760
|
signEndpoint: config2.signEndpoint,
|
|
@@ -214617,7 +214805,14 @@ var RemoteGatewayMcpServerProvider = class {
|
|
|
214617
214805
|
if (!this.debugLog)
|
|
214618
214806
|
return;
|
|
214619
214807
|
try {
|
|
214620
|
-
this.debugLog(`[mcp-client] ${JSON.stringify({
|
|
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);
|
|
214621
214816
|
} catch (error40) {
|
|
214622
214817
|
warnLogFailure("remoteGatewayMcpServer.log", error40);
|
|
214623
214818
|
}
|
|
@@ -214637,6 +214832,8 @@ var RemoteGatewayMcpServerProvider = class {
|
|
|
214637
214832
|
callTool: (params, resultSchema, requestOptions) => request("tools/call", params, () => client.callTool(params, resultSchema, requestOptions))
|
|
214638
214833
|
};
|
|
214639
214834
|
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);
|
|
214640
214837
|
const plan = createArgsMappingPlan(name, args, argsMappingRules);
|
|
214641
214838
|
if (plan.requiresUserId) {
|
|
214642
214839
|
if (config2.signEndpoint !== void 0 && config2.signEndpoint !== DEFAULT_SIGN_ENDPOINT && !config2.verifyTokenEndpoint?.trim())
|
|
@@ -214659,15 +214856,18 @@ var RemoteGatewayMcpServerProvider = class {
|
|
|
214659
214856
|
};
|
|
214660
214857
|
}
|
|
214661
214858
|
const mapped = resolveArgsMappingPlan(plan, invocation.auth);
|
|
214859
|
+
recordMcpContentSection(observation, ETelemetryContentSection.MCP_INPUT, mapped, options?.toolSchema?.inputSchema);
|
|
214662
214860
|
invocation.signal.throwIfAborted();
|
|
214663
214861
|
const remaining = Math.max(1, invocation.deadline - performance.now());
|
|
214664
214862
|
try {
|
|
214665
|
-
|
|
214863
|
+
const result = await loggedClient.callTool({ name, arguments: mapped }, void 0, {
|
|
214666
214864
|
signal: invocation.signal,
|
|
214667
214865
|
timeout: remaining,
|
|
214668
214866
|
maxTotalTimeout: remaining,
|
|
214669
214867
|
resetTimeoutOnProgress: false
|
|
214670
214868
|
});
|
|
214869
|
+
recordMcpContentSection(observation, ETelemetryContentSection.MCP_OUTPUT, result, options?.toolSchema?.outputSchema);
|
|
214870
|
+
return result;
|
|
214671
214871
|
} catch (error40) {
|
|
214672
214872
|
invocation.signal.throwIfAborted();
|
|
214673
214873
|
if (invocation.auth && !(error40 instanceof McpInvocationError))
|
|
@@ -214696,7 +214896,13 @@ async function listToolsFromClient(client, resourceId, callTool) {
|
|
|
214696
214896
|
const descriptor = {
|
|
214697
214897
|
name: tool.name,
|
|
214698
214898
|
resourceId,
|
|
214699
|
-
execute: (args, signal) => callTool(tool.name, args, signal
|
|
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
|
+
})
|
|
214700
214906
|
};
|
|
214701
214907
|
if (tool.description !== void 0)
|
|
214702
214908
|
descriptor.description = tool.description;
|
|
@@ -215047,6 +215253,8 @@ function parseResponse(body, query, topK) {
|
|
|
215047
215253
|
}
|
|
215048
215254
|
|
|
215049
215255
|
// ../linkque-agent-runtime/dist/esm/impl/mcp/localHttpMcpServerProvider.js
|
|
215256
|
+
init_telemetry();
|
|
215257
|
+
init_contentRecording();
|
|
215050
215258
|
init_httpLoggingFetch();
|
|
215051
215259
|
var LocalHttpMcpServerProvider = class {
|
|
215052
215260
|
baseUrl;
|
|
@@ -215075,7 +215283,7 @@ var LocalHttpMcpServerProvider = class {
|
|
|
215075
215283
|
}
|
|
215076
215284
|
return body.tools.map((value) => this.createDescriptor(resource.resourceId, value));
|
|
215077
215285
|
},
|
|
215078
|
-
callTool: (name, args, signal) => this.callTool(resource.resourceId, name, args, signal)
|
|
215286
|
+
callTool: (name, args, signal, options) => this.callTool(resource.resourceId, name, args, signal, options)
|
|
215079
215287
|
};
|
|
215080
215288
|
}
|
|
215081
215289
|
createDescriptor(resourceId, value) {
|
|
@@ -215089,17 +215297,28 @@ var LocalHttpMcpServerProvider = class {
|
|
|
215089
215297
|
...isRecord2(value.inputSchema) ? { inputSchema: value.inputSchema } : {},
|
|
215090
215298
|
...isRecord2(value.outputSchema) ? { outputSchema: value.outputSchema } : {},
|
|
215091
215299
|
...isRecord2(value.annotations) ? { annotations: value.annotations } : {},
|
|
215092
|
-
execute: (args, signal) => this.callTool(resourceId, value.name, args, signal
|
|
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
|
+
})
|
|
215093
215307
|
};
|
|
215094
215308
|
}
|
|
215095
|
-
async callTool(resourceId, toolName, args, signal) {
|
|
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);
|
|
215096
215313
|
const response = await this.fetchImpl(this.resourceUrl(resourceId, `tools/${encodeURIComponent(toolName)}/call`), {
|
|
215097
215314
|
method: "POST",
|
|
215098
215315
|
headers: { "content-type": "application/json" },
|
|
215099
215316
|
body: JSON.stringify({ arguments: args }),
|
|
215100
215317
|
signal
|
|
215101
215318
|
});
|
|
215102
|
-
|
|
215319
|
+
const result = await readJsonResponse(response);
|
|
215320
|
+
recordMcpContentSection(observation, ETelemetryContentSection.MCP_OUTPUT, result, options?.toolSchema?.outputSchema);
|
|
215321
|
+
return result;
|
|
215103
215322
|
}
|
|
215104
215323
|
resourceUrl(resourceId, suffix) {
|
|
215105
215324
|
return new URL(`resources/${encodeURIComponent(resourceId)}/${suffix}`, ensureTrailingSlash(this.baseUrl));
|
|
@@ -215778,6 +215997,7 @@ function unzip(data, opts, cb) {
|
|
|
215778
215997
|
}
|
|
215779
215998
|
|
|
215780
215999
|
// ../linkque-agent-runtime/dist/esm/impl/webSkillLoader.js
|
|
216000
|
+
init_types();
|
|
215781
216001
|
init_skillTools();
|
|
215782
216002
|
init_httpLoggingFetch();
|
|
215783
216003
|
var ESkillUrlScheme;
|
|
@@ -215815,7 +216035,7 @@ var WebSkillLoader = class {
|
|
|
215815
216035
|
return records.filter((record4, idx) => {
|
|
215816
216036
|
if (record4 !== void 0)
|
|
215817
216037
|
return true;
|
|
215818
|
-
this.debugLog?.(`[skill] \u8DF3\u8FC7\u8D44\u6E90 ${resources[idx]?.resourceId ?? "?"}:SKILL.md \u7F3A description(\u524D\u7F6E\u65E0\u6548),\u6309 spec \u4E0D\u52A0\u8F7D
|
|
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);
|
|
215819
216039
|
return false;
|
|
215820
216040
|
});
|
|
215821
216041
|
}
|
|
@@ -216476,7 +216696,7 @@ var OtelRuntimeTelemetry = class {
|
|
|
216476
216696
|
{
|
|
216477
216697
|
onEmit: (record4, ctx) => {
|
|
216478
216698
|
const route = ctx?.getValue(this.routeKey);
|
|
216479
|
-
this.output(ETelemetrySignal.LOGS, import_otlp_transformer.JsonLogsSerializer.serializeRequest([record4]), route?.route, route?.critical ?? false);
|
|
216699
|
+
this.output(ETelemetrySignal.LOGS, import_otlp_transformer.JsonLogsSerializer.serializeRequest([record4]), route?.route, route?.critical ?? false, route?.localOnly ?? false);
|
|
216480
216700
|
},
|
|
216481
216701
|
forceFlush: async () => void 0,
|
|
216482
216702
|
shutdown: async () => void 0
|
|
@@ -216484,12 +216704,13 @@ var OtelRuntimeTelemetry = class {
|
|
|
216484
216704
|
]
|
|
216485
216705
|
});
|
|
216486
216706
|
}
|
|
216487
|
-
output(signal, encoded, route, critical) {
|
|
216707
|
+
output(signal, encoded, route, critical, localOnly = false) {
|
|
216488
216708
|
if (!encoded || this.outputActive || this.disposed)
|
|
216489
216709
|
return;
|
|
216490
216710
|
this.outputActive = true;
|
|
216491
216711
|
try {
|
|
216492
|
-
|
|
216712
|
+
if (!localOnly)
|
|
216713
|
+
this.queue.enqueue(route, signal, encoded, critical);
|
|
216493
216714
|
if (this.options.localSink) {
|
|
216494
216715
|
try {
|
|
216495
216716
|
const payload = JSON.parse(new TextDecoder().decode(encoded));
|
|
@@ -216514,7 +216735,6 @@ var OtelRuntimeTelemetry = class {
|
|
|
216514
216735
|
return new NoopRuntimeObservation();
|
|
216515
216736
|
}
|
|
216516
216737
|
const state2 = {
|
|
216517
|
-
agentId: input.agentId,
|
|
216518
216738
|
sequence: 0,
|
|
216519
216739
|
route: auth2 ? this.queue.authorize(auth2) : void 0,
|
|
216520
216740
|
attributes: sanitizeTelemetryAttributes({
|
|
@@ -216570,7 +216790,6 @@ var OtelRuntimeTelemetry = class {
|
|
|
216570
216790
|
isRemote: upstream !== null,
|
|
216571
216791
|
traceState: parentContext.traceState ? createTraceState(parentContext.traceState) : void 0
|
|
216572
216792
|
});
|
|
216573
|
-
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;
|
|
216574
216793
|
const attributes = sanitizeTelemetryAttributes({
|
|
216575
216794
|
...state2.attributes,
|
|
216576
216795
|
...parent?.attributes,
|
|
@@ -216588,11 +216807,11 @@ var OtelRuntimeTelemetry = class {
|
|
|
216588
216807
|
ETelemetryAttribute.LINKQUE_CONVERSATION_ID
|
|
216589
216808
|
].some((attribute) => attribute === key))),
|
|
216590
216809
|
[ETelemetryAttribute.LINKQUE_OPERATION_ID]: (0, import_node_crypto5.randomUUID)(),
|
|
216591
|
-
[ETelemetryAttribute.LINKQUE_OPERATION_NAME]:
|
|
216810
|
+
[ETelemetryAttribute.LINKQUE_OPERATION_NAME]: spec.name,
|
|
216592
216811
|
[ETelemetryAttribute.LINKQUE_OPERATION_PARENT_ID]: spec.detached ? "" : parent?.operationId ?? "",
|
|
216593
216812
|
[ETelemetryAttribute.LINKQUE_SPAN_PARENT_ID]: spec.detached ? "" : parentContext?.spanId ?? ""
|
|
216594
216813
|
});
|
|
216595
|
-
const span = this.tracerProvider.getTracer(ETelemetryMetadata.SCOPE_NAME, ETelemetryVersion.V1_0).startSpan(
|
|
216814
|
+
const span = this.tracerProvider.getTracer(ETelemetryMetadata.SCOPE_NAME, ETelemetryVersion.V1_0).startSpan(spec.name, {
|
|
216596
216815
|
kind: spec.name === ETelemetryOperationName.MODEL_ATTEMPT ? SpanKind.CLIENT : SpanKind.INTERNAL,
|
|
216597
216816
|
attributes,
|
|
216598
216817
|
links: spec.links.filter((link) => validContext(link.context)).slice(0, 16).map((link) => ({
|
|
@@ -216620,7 +216839,7 @@ var OtelRuntimeTelemetry = class {
|
|
|
216620
216839
|
operation.record(`${spec.eventPrefix}.${ETelemetryEventPhase.STARTED}`, {});
|
|
216621
216840
|
return operation;
|
|
216622
216841
|
}
|
|
216623
|
-
emit(operation, name, attributes, critical) {
|
|
216842
|
+
emit(operation, name, attributes, critical, body) {
|
|
216624
216843
|
if (this.disposed || this.queue.isExporting)
|
|
216625
216844
|
return;
|
|
216626
216845
|
const contextAttributes = operation.attributes;
|
|
@@ -216647,18 +216866,24 @@ var OtelRuntimeTelemetry = class {
|
|
|
216647
216866
|
Math.floor(now / 1e3),
|
|
216648
216867
|
now % 1e3 * 1e6
|
|
216649
216868
|
];
|
|
216650
|
-
|
|
216869
|
+
const localOnly = name === ETelemetryEventName.DEBUG_CONTENT_RECORDED;
|
|
216870
|
+
if (!localOnly && operation.span.isRecording())
|
|
216651
216871
|
operation.span.addEvent(
|
|
216652
216872
|
name,
|
|
216653
216873
|
// 复用已投影的属性;Span 已持有上下文,事件只保留本次事实及去重字段。
|
|
216654
216874
|
Object.fromEntries(Object.entries(record4).filter(([key]) => Object.hasOwn(attributes, key) || key === ETelemetryAttribute.HARNESS_RECORD_ID || key === ETelemetryAttribute.HARNESS_EVENT_SEQUENCE)),
|
|
216655
216875
|
time3
|
|
216656
216876
|
);
|
|
216657
|
-
const ctx = trace.setSpan(ROOT_CONTEXT, operation.span).setValue(this.routeKey, {
|
|
216877
|
+
const ctx = trace.setSpan(ROOT_CONTEXT, operation.span).setValue(this.routeKey, {
|
|
216878
|
+
route: operation.state.route,
|
|
216879
|
+
critical,
|
|
216880
|
+
localOnly
|
|
216881
|
+
});
|
|
216658
216882
|
this.loggerProvider.getLogger(ETelemetryMetadata.SCOPE_NAME, ETelemetryVersion.V1_0).emit({
|
|
216659
216883
|
eventName: name,
|
|
216660
216884
|
timestamp: time3,
|
|
216661
216885
|
observedTimestamp: time3,
|
|
216886
|
+
...body !== void 0 ? { body } : {},
|
|
216662
216887
|
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,
|
|
216663
216888
|
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],
|
|
216664
216889
|
attributes: record4,
|
|
@@ -216729,10 +216954,11 @@ var OtelObservation = class {
|
|
|
216729
216954
|
return new NoopRuntimeObservation();
|
|
216730
216955
|
return this.owner.createOperation(this.state, spec, this);
|
|
216731
216956
|
}
|
|
216732
|
-
record(name, attributes) {
|
|
216957
|
+
record(name, attributes, body) {
|
|
216733
216958
|
if (this.lost || !/^(harness|linkque)\.[a-z0-9_.]{1,128}$/.test(name))
|
|
216734
216959
|
return;
|
|
216735
|
-
|
|
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);
|
|
216736
216962
|
}
|
|
216737
216963
|
finish(outcome, attributes) {
|
|
216738
216964
|
if (this.ended)
|
|
@@ -216972,6 +217198,7 @@ var OtlpFileSink = class {
|
|
|
216972
217198
|
// src/commands/agentdev/sandboxIntegrate/sandboxRuntimeConfigProvider.ts
|
|
216973
217199
|
var SANDBOX_RUNTIME_CONFIG_DEFAULTS = Object.freeze({
|
|
216974
217200
|
...RUNTIME_CONFIG_DEFAULTS,
|
|
217201
|
+
LOG_LEVEL: "DEBUG",
|
|
216975
217202
|
LINKQUE_MCP_SIGN_ENDPOINT: RUNTIME_CONFIG_DEFAULTS.LINKQUEGW_MCP_SIGN_ENDPOINT,
|
|
216976
217203
|
LINKQUE_OPEN_MCP_BASE_URL: "https://opengw.alipay.com",
|
|
216977
217204
|
LINKQUEGW_TELEMETRY_LOGS_ENDPOINT: `${LINKQUE_ENDPOINT_PROD}/api/telemetry/v1/logs`,
|
|
@@ -217429,6 +217656,7 @@ var fileSize = async (filePath) => {
|
|
|
217429
217656
|
};
|
|
217430
217657
|
var maskSecret = (raw) => raw ? "<set>" : "<unset>";
|
|
217431
217658
|
var AGENT_ENV_SNAPSHOT = [
|
|
217659
|
+
["LOG_LEVEL", false],
|
|
217432
217660
|
["LINKQUE_AGENT_API_KEY", true],
|
|
217433
217661
|
["LINKQUE_AGENT_ACCESS_KEY", true],
|
|
217434
217662
|
["LINKQUE_USER_TOKEN", true],
|
|
@@ -217665,11 +217893,15 @@ var main = async () => {
|
|
|
217665
217893
|
`[${(/* @__PURE__ */ new Date()).toISOString()}] agent worker loading agent runtime
|
|
217666
217894
|
`
|
|
217667
217895
|
);
|
|
217668
|
-
const
|
|
217669
|
-
|
|
217670
|
-
|
|
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}
|
|
217671
217902
|
`);
|
|
217672
|
-
|
|
217903
|
+
}
|
|
217904
|
+
);
|
|
217673
217905
|
agentDevTelemetry = await createAgentDevTelemetry(
|
|
217674
217906
|
input.agentId,
|
|
217675
217907
|
input.logPath,
|
|
@@ -217683,7 +217915,6 @@ var main = async () => {
|
|
|
217683
217915
|
executeHomeData2 = executeHomeData;
|
|
217684
217916
|
executeCardAction2 = executeCardAction;
|
|
217685
217917
|
executeFunctionActionMcp2 = executeFunctionActionMcp;
|
|
217686
|
-
const config2 = new SandboxRuntimeConfigProvider();
|
|
217687
217918
|
const localMcpUrl = config2.get("LINKQUE_AGENT_MCP_FIXTURE_URL");
|
|
217688
217919
|
const gatewayAuthorization = resolveSandboxGatewayAuthorization(process.env);
|
|
217689
217920
|
const remoteAuthorizationHeader = gatewayAuthorization ? async () => gatewayAuthorization : void 0;
|
|
@@ -217758,9 +217989,9 @@ var main = async () => {
|
|
|
217758
217989
|
// opengw 响应头 alipay-trace-id 下沉到 agent.log(同 SSE 会话级复用,
|
|
217759
217990
|
// 每会话首个 POST 上报一次有效值),供 MCP 调用链路归因排查。
|
|
217760
217991
|
onTraceId: (info) => {
|
|
217761
|
-
|
|
217762
|
-
`[
|
|
217763
|
-
|
|
217992
|
+
debugLog(
|
|
217993
|
+
`[mcp-trace] ${info.httpMethod} ${info.requestUrl} alipay-trace-id=${info.traceId}`,
|
|
217994
|
+
EDebugLogScope.MCP
|
|
217764
217995
|
);
|
|
217765
217996
|
},
|
|
217766
217997
|
// HTTP 出站日志下沉(scope=http):tag=mcp-sign(签名服务)+ mcp-call(SSE GET/POST 工具调用)→ agent.log。
|