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/package.json
CHANGED
package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-CUMXO6KK.js → chunk-SAQYWJAA.js}
RENAMED
|
@@ -20,8 +20,9 @@ import {
|
|
|
20
20
|
McpPhoneAuthorizationFailedError,
|
|
21
21
|
McpPhoneAuthorizationRequiredError,
|
|
22
22
|
RUNTIME_CONFIG_DEFAULTS,
|
|
23
|
-
RuntimeConfigProvider
|
|
24
|
-
|
|
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")
|
|
15297
|
+
return isDebugLoggingEnabled(new AppbaseRuntimeConfigProvider(env).get("LOG_LEVEL"));
|
|
15297
15298
|
}
|
|
15298
15299
|
function whichSource(env, candidates) {
|
|
15299
15300
|
const config = new AppbaseRuntimeConfigProvider(env);
|
package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-OHRCYI66.js → chunk-Y36JLYIE.js}
RENAMED
|
@@ -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 (
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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({
|
|
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
|
-
|
|
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
|
-
|
|
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]:
|
|
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(
|
|
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
|
-
|
|
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, {
|
|
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
|
-
|
|
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,
|