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.
- package/linkquejs.js +1291 -354
- package/package.json +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-OHRCYI66.js → chunk-CLYLJ5MD.js} +591 -393
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-XL6BPKTI.js → chunk-NFVKWQGM.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-CUMXO6KK.js → chunk-S75HFRLD.js} +4 -3
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js +94 -8
- 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 +691 -381
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
|
}
|
|
@@ -11886,6 +11888,371 @@ var init_mcpAggregator = __esm({
|
|
|
11886
11888
|
}
|
|
11887
11889
|
});
|
|
11888
11890
|
|
|
11891
|
+
// ../linkque-agent-protocol/dist/esm/telemetry/telemetryEnums.js
|
|
11892
|
+
var CONTENT_VALUE_MAX_LENGTH, 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;
|
|
11893
|
+
var init_telemetryEnums = __esm({
|
|
11894
|
+
"../linkque-agent-protocol/dist/esm/telemetry/telemetryEnums.js"() {
|
|
11895
|
+
"use strict";
|
|
11896
|
+
CONTENT_VALUE_MAX_LENGTH = 16 * 1024;
|
|
11897
|
+
(function(ETelemetryAttribute2) {
|
|
11898
|
+
ETelemetryAttribute2["HARNESS_TELEMETRY_SCHEMA_VERSION"] = "harness.telemetry.schema.version";
|
|
11899
|
+
ETelemetryAttribute2["LINKQUE_TELEMETRY_SCHEMA_VERSION"] = "linkque.telemetry.schema.version";
|
|
11900
|
+
ETelemetryAttribute2["LINKQUE_TELEMETRY_ADAPTER_VERSION"] = "linkque.telemetry.adapter.version";
|
|
11901
|
+
ETelemetryAttribute2["HARNESS_TELEMETRY_SOURCE"] = "harness.telemetry.source";
|
|
11902
|
+
ETelemetryAttribute2["HARNESS_TELEMETRY_EVIDENCE"] = "harness.telemetry.evidence";
|
|
11903
|
+
ETelemetryAttribute2["HARNESS_TELEMETRY_COMPLETENESS"] = "harness.telemetry.completeness";
|
|
11904
|
+
ETelemetryAttribute2["LINKQUE_RUNTIME_KIND"] = "linkque.runtime.kind";
|
|
11905
|
+
ETelemetryAttribute2["LINKQUE_RUN_ID"] = "linkque.run.id";
|
|
11906
|
+
ETelemetryAttribute2["LINKQUE_AGENT_ID"] = "linkque.agent.id";
|
|
11907
|
+
ETelemetryAttribute2["HARNESS_SESSION_ID"] = "harness.session.id";
|
|
11908
|
+
ETelemetryAttribute2["LINKQUE_CONVERSATION_ID"] = "linkque.conversation.id";
|
|
11909
|
+
ETelemetryAttribute2["LINKQUE_REQUEST_ID"] = "linkque.request.id";
|
|
11910
|
+
ETelemetryAttribute2["LINKQUE_TURN_ID"] = "linkque.turn.id";
|
|
11911
|
+
ETelemetryAttribute2["LINKQUE_ACCOUNT_ID"] = "linkque.account.id";
|
|
11912
|
+
ETelemetryAttribute2["LINKQUE_CHANNEL"] = "linkque.channel";
|
|
11913
|
+
ETelemetryAttribute2["LINKQUE_USER_KEY"] = "linkque.user.key";
|
|
11914
|
+
ETelemetryAttribute2["HARNESS_ADVANCE_ID"] = "harness.advance.id";
|
|
11915
|
+
ETelemetryAttribute2["HARNESS_CALL_ID"] = "harness.call.id";
|
|
11916
|
+
ETelemetryAttribute2["HARNESS_INVOCATION_ID"] = "harness.invocation.id";
|
|
11917
|
+
ETelemetryAttribute2["HARNESS_ATTEMPT_ID"] = "harness.attempt.id";
|
|
11918
|
+
ETelemetryAttribute2["HARNESS_ATTEMPT_VISIBILITY"] = "harness.attempt.visibility";
|
|
11919
|
+
ETelemetryAttribute2["HARNESS_ADVANCE_OUTCOME"] = "harness.advance.outcome";
|
|
11920
|
+
ETelemetryAttribute2["HARNESS_OPERATION_OUTCOME"] = "harness.operation.outcome";
|
|
11921
|
+
ETelemetryAttribute2["HARNESS_REMOTE_COMPLETION"] = "harness.remote.completion";
|
|
11922
|
+
ETelemetryAttribute2["HARNESS_STATE_COMMIT_STATUS"] = "harness.state.commit.status";
|
|
11923
|
+
ETelemetryAttribute2["LINKQUE_OPERATION_ID"] = "linkque.operation.id";
|
|
11924
|
+
ETelemetryAttribute2["LINKQUE_OPERATION_NAME"] = "linkque.operation.name";
|
|
11925
|
+
ETelemetryAttribute2["LINKQUE_OPERATION_PARENT_ID"] = "linkque.operation.parent_id";
|
|
11926
|
+
ETelemetryAttribute2["LINKQUE_SPAN_PARENT_ID"] = "linkque.span.parent_id";
|
|
11927
|
+
ETelemetryAttribute2["HARNESS_RECORD_ID"] = "harness.record.id";
|
|
11928
|
+
ETelemetryAttribute2["HARNESS_EVENT_SEQUENCE"] = "harness.event.sequence";
|
|
11929
|
+
ETelemetryAttribute2["ERROR_TYPE"] = "error.type";
|
|
11930
|
+
ETelemetryAttribute2["LINKQUE_STREAM_TERMINATION"] = "linkque.stream.termination";
|
|
11931
|
+
ETelemetryAttribute2["LINKQUE_STREAM_CANCEL_SOURCE"] = "linkque.stream.cancel_source";
|
|
11932
|
+
ETelemetryAttribute2["LINKQUE_TERMINAL_EVIDENCE"] = "linkque.terminal.evidence";
|
|
11933
|
+
ETelemetryAttribute2["LINKQUE_RUNTIME_CLEANUP_OUTCOME"] = "linkque.runtime.cleanup_outcome";
|
|
11934
|
+
ETelemetryAttribute2["LINKQUE_OBSERVATION_BOUNDARY"] = "linkque.observation.boundary";
|
|
11935
|
+
ETelemetryAttribute2["LINKQUE_LOOP_ITERATION_ID"] = "linkque.loop.iteration.id";
|
|
11936
|
+
ETelemetryAttribute2["LINKQUE_LOOP_ITERATION_INDEX"] = "linkque.loop.iteration.index";
|
|
11937
|
+
ETelemetryAttribute2["LINKQUE_STREAM_TERMINAL_SOURCE"] = "linkque.stream.terminal_source";
|
|
11938
|
+
ETelemetryAttribute2["LINKQUE_STREAM_PUBLIC_TEXT_DELTA_COUNT"] = "linkque.stream.public_text_delta_count";
|
|
11939
|
+
ETelemetryAttribute2["LINKQUE_STREAM_THINKING_DELTA_COUNT"] = "linkque.stream.thinking_delta_count";
|
|
11940
|
+
ETelemetryAttribute2["LINKQUE_MODEL_FIRST_CHUNK_MS"] = "linkque.model.first_chunk_ms";
|
|
11941
|
+
ETelemetryAttribute2["LINKQUE_MODEL_FIRST_TEXT_MS"] = "linkque.model.first_text_ms";
|
|
11942
|
+
ETelemetryAttribute2["LINKQUE_LOOP_FIRST_PUBLIC_TEXT_MS"] = "linkque.loop.first_public_text_ms";
|
|
11943
|
+
ETelemetryAttribute2["LINKQUE_MODEL_CHUNK_COUNT"] = "linkque.model.chunk_count";
|
|
11944
|
+
ETelemetryAttribute2["LINKQUE_MODEL_TEXT_CHARS"] = "linkque.model.text_chars";
|
|
11945
|
+
ETelemetryAttribute2["LINKQUE_MODEL_THINKING_CHARS"] = "linkque.model.thinking_chars";
|
|
11946
|
+
ETelemetryAttribute2["GEN_AI_OPERATION_NAME"] = "gen_ai.operation.name";
|
|
11947
|
+
ETelemetryAttribute2["GEN_AI_AGENT_NAME"] = "gen_ai.agent.name";
|
|
11948
|
+
ETelemetryAttribute2["GEN_AI_PROVIDER_NAME"] = "gen_ai.provider.name";
|
|
11949
|
+
ETelemetryAttribute2["GEN_AI_REQUEST_MODEL"] = "gen_ai.request.model";
|
|
11950
|
+
ETelemetryAttribute2["GEN_AI_RESPONSE_MODEL"] = "gen_ai.response.model";
|
|
11951
|
+
ETelemetryAttribute2["GEN_AI_RESPONSE_ID"] = "gen_ai.response.id";
|
|
11952
|
+
ETelemetryAttribute2["LINKQUE_CONTENT_VALUE_TRUNCATED"] = "linkque.content.value.truncated";
|
|
11953
|
+
ETelemetryAttribute2["GEN_AI_RESPONSE_FINISH_REASONS"] = "gen_ai.response.finish_reasons";
|
|
11954
|
+
ETelemetryAttribute2["GEN_AI_USAGE_INPUT_TOKENS"] = "gen_ai.usage.input_tokens";
|
|
11955
|
+
ETelemetryAttribute2["GEN_AI_USAGE_OUTPUT_TOKENS"] = "gen_ai.usage.output_tokens";
|
|
11956
|
+
ETelemetryAttribute2["GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS"] = "gen_ai.usage.cache_read.input_tokens";
|
|
11957
|
+
ETelemetryAttribute2["GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS"] = "gen_ai.usage.cache_creation.input_tokens";
|
|
11958
|
+
ETelemetryAttribute2["GEN_AI_USAGE_REASONING_OUTPUT_TOKENS"] = "gen_ai.usage.reasoning.output_tokens";
|
|
11959
|
+
ETelemetryAttribute2["HARNESS_USAGE_SOURCE"] = "harness.usage.source";
|
|
11960
|
+
ETelemetryAttribute2["HARNESS_USAGE_ATTEMPT_COVERAGE"] = "harness.usage.attempt_coverage";
|
|
11961
|
+
ETelemetryAttribute2["HARNESS_MODEL_PURPOSE"] = "harness.model.purpose";
|
|
11962
|
+
ETelemetryAttribute2["HARNESS_MODEL_INVOCATION_COUNT"] = "harness.model.invocation_count";
|
|
11963
|
+
ETelemetryAttribute2["GEN_AI_TOOL_NAME"] = "gen_ai.tool.name";
|
|
11964
|
+
ETelemetryAttribute2["GEN_AI_TOOL_CALL_ID"] = "gen_ai.tool.call.id";
|
|
11965
|
+
ETelemetryAttribute2["HARNESS_TOOL_RESULT_STATUS"] = "harness.tool.result.status";
|
|
11966
|
+
ETelemetryAttribute2["LINKQUE_TOOL_FAILURE_STAGE"] = "linkque.tool.failure_stage";
|
|
11967
|
+
ETelemetryAttribute2["HARNESS_HOOK_NAME"] = "harness.hook.name";
|
|
11968
|
+
ETelemetryAttribute2["LINKQUE_HOOK_STAGE"] = "linkque.hook.stage";
|
|
11969
|
+
ETelemetryAttribute2["LINKQUE_HOOK_RESOURCE_ID"] = "linkque.hook.resource_id";
|
|
11970
|
+
ETelemetryAttribute2["LINKQUE_HOOK_EVENT_ID"] = "linkque.hook.event_id";
|
|
11971
|
+
ETelemetryAttribute2["LINKQUE_HOOK_MATCHED_COUNT"] = "linkque.hook.matched_count";
|
|
11972
|
+
ETelemetryAttribute2["LINKQUE_HOOK_PENDING_COUNT"] = "linkque.hook.pending_count";
|
|
11973
|
+
ETelemetryAttribute2["LINKQUE_HOOK_SCHEDULED_COUNT"] = "linkque.hook.scheduled_count";
|
|
11974
|
+
ETelemetryAttribute2["LINKQUE_HOOK_HAS_SIDE_EFFECTS"] = "linkque.hook.has_side_effects";
|
|
11975
|
+
ETelemetryAttribute2["LINKQUE_HOOK_MODE"] = "linkque.hook.mode";
|
|
11976
|
+
ETelemetryAttribute2["LINKQUE_HOOK_TIMEOUT_MS"] = "linkque.hook.timeout_ms";
|
|
11977
|
+
ETelemetryAttribute2["LINKQUE_HOOK_RESULT"] = "linkque.hook.result";
|
|
11978
|
+
ETelemetryAttribute2["HARNESS_MIDDLEWARE_NAME"] = "harness.middleware.name";
|
|
11979
|
+
ETelemetryAttribute2["HARNESS_MIDDLEWARE_INVOCATION_ID"] = "harness.middleware.invocation.id";
|
|
11980
|
+
ETelemetryAttribute2["LINKQUE_HOOK_EXECUTOR_SETTLED"] = "linkque.hook.executor_settled";
|
|
11981
|
+
ETelemetryAttribute2["LINKQUE_HISTORY_MESSAGE_COUNT"] = "linkque.history.message_count";
|
|
11982
|
+
ETelemetryAttribute2["LINKQUE_TELEMETRY_COVERAGE"] = "linkque.telemetry.coverage";
|
|
11983
|
+
ETelemetryAttribute2["LINKQUE_TELEMETRY_LOSS_REASON"] = "linkque.telemetry.loss_reason";
|
|
11984
|
+
ETelemetryAttribute2["LINKQUE_OPERATION_DURATION_MS"] = "linkque.operation.duration_ms";
|
|
11985
|
+
ETelemetryAttribute2["HTTP_RESPONSE_STATUS_CODE"] = "http.response.status_code";
|
|
11986
|
+
ETelemetryAttribute2["SERVICE_NAME"] = "service.name";
|
|
11987
|
+
ETelemetryAttribute2["SERVICE_NAMESPACE"] = "service.namespace";
|
|
11988
|
+
ETelemetryAttribute2["SERVICE_VERSION"] = "service.version";
|
|
11989
|
+
ETelemetryAttribute2["SERVICE_INSTANCE_ID"] = "service.instance.id";
|
|
11990
|
+
ETelemetryAttribute2["DEPLOYMENT_ENVIRONMENT_NAME"] = "deployment.environment.name";
|
|
11991
|
+
ETelemetryAttribute2["LINKQUE_LINK_RELATION"] = "linkque.link.relation";
|
|
11992
|
+
})(ETelemetryAttribute || (ETelemetryAttribute = {}));
|
|
11993
|
+
(function(ETelemetryEventPrefix2) {
|
|
11994
|
+
ETelemetryEventPrefix2["OPERATION"] = "linkque.operation";
|
|
11995
|
+
ETelemetryEventPrefix2["ADVANCE"] = "harness.advance";
|
|
11996
|
+
ETelemetryEventPrefix2["MODEL_INVOKE"] = "harness.model.invoke";
|
|
11997
|
+
ETelemetryEventPrefix2["MODEL_ATTEMPT"] = "harness.model.attempt";
|
|
11998
|
+
ETelemetryEventPrefix2["TOOL_INVOKE"] = "harness.tool.invoke";
|
|
11999
|
+
ETelemetryEventPrefix2["TOOL_ATTEMPT"] = "harness.tool.attempt";
|
|
12000
|
+
ETelemetryEventPrefix2["HOOK_CHAIN"] = "harness.hook.chain";
|
|
12001
|
+
ETelemetryEventPrefix2["MIDDLEWARE"] = "harness.middleware";
|
|
12002
|
+
ETelemetryEventPrefix2["LOOP"] = "linkque.loop";
|
|
12003
|
+
ETelemetryEventPrefix2["LOOP_ITERATION"] = "linkque.loop.iteration";
|
|
12004
|
+
ETelemetryEventPrefix2["HISTORY_APPEND"] = "linkque.history.append";
|
|
12005
|
+
ETelemetryEventPrefix2["HOOK_DRAIN"] = "linkque.hook.drain";
|
|
12006
|
+
})(ETelemetryEventPrefix || (ETelemetryEventPrefix = {}));
|
|
12007
|
+
(function(ETelemetryEventPhase2) {
|
|
12008
|
+
ETelemetryEventPhase2["STARTED"] = "started";
|
|
12009
|
+
ETelemetryEventPhase2["FINISHED"] = "finished";
|
|
12010
|
+
ETelemetryEventPhase2["OBSERVATION_LOST"] = "observation_lost";
|
|
12011
|
+
})(ETelemetryEventPhase || (ETelemetryEventPhase = {}));
|
|
12012
|
+
(function(ETelemetryEventName2) {
|
|
12013
|
+
ETelemetryEventName2["TOOL_EXECUTION_FAILED"] = "linkque.tool.execution.failed";
|
|
12014
|
+
ETelemetryEventName2["TELEMETRY_COVERAGE"] = "linkque.telemetry.coverage";
|
|
12015
|
+
ETelemetryEventName2["HOOK_MATCHED"] = "linkque.hook.matched";
|
|
12016
|
+
ETelemetryEventName2["HOOK_SCHEDULED"] = "linkque.hook.scheduled";
|
|
12017
|
+
ETelemetryEventName2["HOOK_CANCEL_REQUESTED"] = "linkque.hook.cancel_requested";
|
|
12018
|
+
ETelemetryEventName2["HOOK_TIMEOUT_REQUESTED"] = "linkque.hook.timeout_requested";
|
|
12019
|
+
ETelemetryEventName2["HOOK_EXECUTOR_SETTLED"] = "linkque.hook.executor_settled";
|
|
12020
|
+
ETelemetryEventName2["HOOK_WAIT_FINISHED"] = "linkque.hook.wait_finished";
|
|
12021
|
+
ETelemetryEventName2["LOOP_FIRST_PUBLIC_TEXT"] = "linkque.loop.first_public_text";
|
|
12022
|
+
ETelemetryEventName2["STREAM_TERMINAL_OBSERVED"] = "linkque.stream.terminal_observed";
|
|
12023
|
+
ETelemetryEventName2["MODEL_FIRST_CHUNK"] = "harness.model.first_chunk";
|
|
12024
|
+
ETelemetryEventName2["MODEL_FIRST_TEXT"] = "harness.model.first_text";
|
|
12025
|
+
ETelemetryEventName2["MODEL_USAGE_RECORDED"] = "linkque.model.usage.recorded";
|
|
12026
|
+
ETelemetryEventName2["MODEL_RESPONSE_HEADERS"] = "linkque.model.response_headers";
|
|
12027
|
+
ETelemetryEventName2["OPERATION_OBSERVATION_LOST"] = "linkque.operation.observation_lost";
|
|
12028
|
+
ETelemetryEventName2["RUNTIME_UNCAUGHT_ERROR"] = "linkque.runtime.uncaught_error";
|
|
12029
|
+
ETelemetryEventName2["OPERATION_STARTED"] = "linkque.operation.started";
|
|
12030
|
+
ETelemetryEventName2["OPERATION_FINISHED"] = "linkque.operation.finished";
|
|
12031
|
+
ETelemetryEventName2["ADVANCE_STARTED"] = "harness.advance.started";
|
|
12032
|
+
ETelemetryEventName2["ADVANCE_FINISHED"] = "harness.advance.finished";
|
|
12033
|
+
ETelemetryEventName2["MODEL_INVOKE_STARTED"] = "harness.model.invoke.started";
|
|
12034
|
+
ETelemetryEventName2["MODEL_INVOKE_FINISHED"] = "harness.model.invoke.finished";
|
|
12035
|
+
ETelemetryEventName2["MODEL_ATTEMPT_STARTED"] = "harness.model.attempt.started";
|
|
12036
|
+
ETelemetryEventName2["MODEL_ATTEMPT_FINISHED"] = "harness.model.attempt.finished";
|
|
12037
|
+
ETelemetryEventName2["TOOL_INVOKE_STARTED"] = "harness.tool.invoke.started";
|
|
12038
|
+
ETelemetryEventName2["TOOL_INVOKE_FINISHED"] = "harness.tool.invoke.finished";
|
|
12039
|
+
ETelemetryEventName2["TOOL_ATTEMPT_STARTED"] = "harness.tool.attempt.started";
|
|
12040
|
+
ETelemetryEventName2["TOOL_ATTEMPT_FINISHED"] = "harness.tool.attempt.finished";
|
|
12041
|
+
ETelemetryEventName2["HOOK_CHAIN_STARTED"] = "harness.hook.chain.started";
|
|
12042
|
+
ETelemetryEventName2["HOOK_CHAIN_FINISHED"] = "harness.hook.chain.finished";
|
|
12043
|
+
ETelemetryEventName2["MIDDLEWARE_STARTED"] = "harness.middleware.started";
|
|
12044
|
+
ETelemetryEventName2["MIDDLEWARE_FINISHED"] = "harness.middleware.finished";
|
|
12045
|
+
ETelemetryEventName2["LOOP_STARTED"] = "linkque.loop.started";
|
|
12046
|
+
ETelemetryEventName2["LOOP_FINISHED"] = "linkque.loop.finished";
|
|
12047
|
+
ETelemetryEventName2["LOOP_ITERATION_STARTED"] = "linkque.loop.iteration.started";
|
|
12048
|
+
ETelemetryEventName2["LOOP_ITERATION_FINISHED"] = "linkque.loop.iteration.finished";
|
|
12049
|
+
ETelemetryEventName2["HISTORY_APPEND_STARTED"] = "linkque.history.append.started";
|
|
12050
|
+
ETelemetryEventName2["HISTORY_APPEND_FINISHED"] = "linkque.history.append.finished";
|
|
12051
|
+
ETelemetryEventName2["HOOK_DRAIN_STARTED"] = "linkque.hook.drain.started";
|
|
12052
|
+
ETelemetryEventName2["HOOK_DRAIN_FINISHED"] = "linkque.hook.drain.finished";
|
|
12053
|
+
ETelemetryEventName2["CONTENT_RECORDED"] = "linkque.content.recorded";
|
|
12054
|
+
})(ETelemetryEventName || (ETelemetryEventName = {}));
|
|
12055
|
+
(function(ETelemetryContentSection2) {
|
|
12056
|
+
ETelemetryContentSection2["QUERY_INPUT"] = "query.input";
|
|
12057
|
+
ETelemetryContentSection2["MODEL_OUTPUT"] = "model.output";
|
|
12058
|
+
ETelemetryContentSection2["MCP_ACTION_OUTPUT"] = "mcp_action.output";
|
|
12059
|
+
ETelemetryContentSection2["TOOL_INPUT"] = "tool.input";
|
|
12060
|
+
ETelemetryContentSection2["TOOL_OUTPUT"] = "tool.output";
|
|
12061
|
+
ETelemetryContentSection2["MCP_REQUESTED_INPUT"] = "mcp.requested_input";
|
|
12062
|
+
ETelemetryContentSection2["MCP_INPUT"] = "mcp.input";
|
|
12063
|
+
ETelemetryContentSection2["MCP_OUTPUT"] = "mcp.output";
|
|
12064
|
+
ETelemetryContentSection2["SKILL_INPUT"] = "skill.input";
|
|
12065
|
+
ETelemetryContentSection2["SKILL_OUTPUT"] = "skill.output";
|
|
12066
|
+
ETelemetryContentSection2["KNOWLEDGE_INPUT"] = "knowledge.input";
|
|
12067
|
+
ETelemetryContentSection2["KNOWLEDGE_OUTPUT"] = "knowledge.output";
|
|
12068
|
+
})(ETelemetryContentSection || (ETelemetryContentSection = {}));
|
|
12069
|
+
(function(ETelemetryOperationName2) {
|
|
12070
|
+
ETelemetryOperationName2["OPERATION"] = "linkque.operation";
|
|
12071
|
+
ETelemetryOperationName2["TOOL_INVOKE"] = "harness.tool.invoke";
|
|
12072
|
+
ETelemetryOperationName2["ADVANCE"] = "harness.advance";
|
|
12073
|
+
ETelemetryOperationName2["MODEL_INVOKE"] = "harness.model.invoke";
|
|
12074
|
+
ETelemetryOperationName2["MODEL_ATTEMPT"] = "harness.model.attempt";
|
|
12075
|
+
ETelemetryOperationName2["TOOL_ATTEMPT"] = "harness.tool.attempt";
|
|
12076
|
+
ETelemetryOperationName2["HOOK_CHAIN"] = "harness.hook.chain";
|
|
12077
|
+
ETelemetryOperationName2["MIDDLEWARE"] = "harness.middleware";
|
|
12078
|
+
ETelemetryOperationName2["LOOP"] = "linkque.agent.loop";
|
|
12079
|
+
ETelemetryOperationName2["ITERATION"] = "linkque.agent.iteration";
|
|
12080
|
+
ETelemetryOperationName2["SESSION_LOAD"] = "harness.session.load";
|
|
12081
|
+
ETelemetryOperationName2["HISTORY_APPEND"] = "linkque.history.append";
|
|
12082
|
+
ETelemetryOperationName2["CLEANUP"] = "linkque.runtime.cleanup";
|
|
12083
|
+
ETelemetryOperationName2["HOOK_DRAIN"] = "linkque.hook.drain";
|
|
12084
|
+
})(ETelemetryOperationName || (ETelemetryOperationName = {}));
|
|
12085
|
+
(function(ETelemetryOutcome2) {
|
|
12086
|
+
ETelemetryOutcome2["SUCCESS"] = "success";
|
|
12087
|
+
ETelemetryOutcome2["ERROR"] = "error";
|
|
12088
|
+
ETelemetryOutcome2["CANCELLED"] = "cancelled";
|
|
12089
|
+
ETelemetryOutcome2["TIMEOUT"] = "timeout";
|
|
12090
|
+
ETelemetryOutcome2["REJECTED"] = "rejected";
|
|
12091
|
+
ETelemetryOutcome2["UNKNOWN"] = "unknown";
|
|
12092
|
+
})(ETelemetryOutcome || (ETelemetryOutcome = {}));
|
|
12093
|
+
(function(ETelemetrySignal2) {
|
|
12094
|
+
ETelemetrySignal2["LOGS"] = "logs";
|
|
12095
|
+
ETelemetrySignal2["TRACES"] = "traces";
|
|
12096
|
+
})(ETelemetrySignal || (ETelemetrySignal = {}));
|
|
12097
|
+
(function(ETelemetryLossReason2) {
|
|
12098
|
+
ETelemetryLossReason2["UNCAUGHT_ERROR"] = "uncaught_error";
|
|
12099
|
+
ETelemetryLossReason2["ACTIVE_LIMIT"] = "active_limit";
|
|
12100
|
+
ETelemetryLossReason2["ACTIVE_EXPIRED"] = "active_expired";
|
|
12101
|
+
ETelemetryLossReason2["SHUTDOWN"] = "shutdown";
|
|
12102
|
+
})(ETelemetryLossReason || (ETelemetryLossReason = {}));
|
|
12103
|
+
(function(ETelemetryAdvanceOutcome2) {
|
|
12104
|
+
ETelemetryAdvanceOutcome2["FAILED"] = "failed";
|
|
12105
|
+
ETelemetryAdvanceOutcome2["COMPLETED"] = "completed";
|
|
12106
|
+
ETelemetryAdvanceOutcome2["UNKNOWN"] = "unknown";
|
|
12107
|
+
})(ETelemetryAdvanceOutcome || (ETelemetryAdvanceOutcome = {}));
|
|
12108
|
+
(function(ETelemetryStreamTermination2) {
|
|
12109
|
+
ETelemetryStreamTermination2["CANCEL"] = "cancel";
|
|
12110
|
+
ETelemetryStreamTermination2["ERROR"] = "error";
|
|
12111
|
+
ETelemetryStreamTermination2["COMPLETE"] = "complete";
|
|
12112
|
+
ETelemetryStreamTermination2["EXHAUSTED"] = "exhausted";
|
|
12113
|
+
})(ETelemetryStreamTermination || (ETelemetryStreamTermination = {}));
|
|
12114
|
+
(function(ETelemetryCancelSource2) {
|
|
12115
|
+
ETelemetryCancelSource2["HOST_SIGNAL"] = "host_signal";
|
|
12116
|
+
ETelemetryCancelSource2["CONSUMER_RETURN"] = "consumer_return";
|
|
12117
|
+
})(ETelemetryCancelSource || (ETelemetryCancelSource = {}));
|
|
12118
|
+
(function(ETelemetryObservationBoundary2) {
|
|
12119
|
+
ETelemetryObservationBoundary2["LOCAL_WAIT"] = "local_wait";
|
|
12120
|
+
ETelemetryObservationBoundary2["EXECUTOR_SETTLED"] = "executor_settled";
|
|
12121
|
+
ETelemetryObservationBoundary2["GENERATOR_WITH_SETUP_AND_CLEANUP"] = "generator_with_setup_and_cleanup";
|
|
12122
|
+
})(ETelemetryObservationBoundary || (ETelemetryObservationBoundary = {}));
|
|
12123
|
+
(function(ETelemetryRemoteCompletion2) {
|
|
12124
|
+
ETelemetryRemoteCompletion2["UNKNOWN"] = "unknown";
|
|
12125
|
+
ETelemetryRemoteCompletion2["NOT_DISPATCHED"] = "not_dispatched";
|
|
12126
|
+
ETelemetryRemoteCompletion2["CONFIRMED"] = "confirmed";
|
|
12127
|
+
})(ETelemetryRemoteCompletion || (ETelemetryRemoteCompletion = {}));
|
|
12128
|
+
(function(ETelemetryCommitStatus2) {
|
|
12129
|
+
ETelemetryCommitStatus2["COMMITTED"] = "committed";
|
|
12130
|
+
ETelemetryCommitStatus2["FAILED"] = "failed";
|
|
12131
|
+
})(ETelemetryCommitStatus || (ETelemetryCommitStatus = {}));
|
|
12132
|
+
(function(ETelemetryHookMode2) {
|
|
12133
|
+
ETelemetryHookMode2["AWAITED"] = "awaited";
|
|
12134
|
+
ETelemetryHookMode2["DETACHED"] = "detached";
|
|
12135
|
+
})(ETelemetryHookMode || (ETelemetryHookMode = {}));
|
|
12136
|
+
(function(ETelemetryHookResult2) {
|
|
12137
|
+
ETelemetryHookResult2["OK"] = "ok";
|
|
12138
|
+
ETelemetryHookResult2["TIMEOUT"] = "timeout";
|
|
12139
|
+
ETelemetryHookResult2["SKIPPED"] = "skipped";
|
|
12140
|
+
ETelemetryHookResult2["SUCCESS"] = "success";
|
|
12141
|
+
ETelemetryHookResult2["ERROR"] = "error";
|
|
12142
|
+
})(ETelemetryHookResult || (ETelemetryHookResult = {}));
|
|
12143
|
+
(function(ETelemetrySource2) {
|
|
12144
|
+
ETelemetrySource2["KERNEL"] = "kernel";
|
|
12145
|
+
ETelemetrySource2["PROVIDER"] = "provider";
|
|
12146
|
+
})(ETelemetrySource || (ETelemetrySource = {}));
|
|
12147
|
+
(function(ETelemetryEvidence2) {
|
|
12148
|
+
ETelemetryEvidence2["OBSERVED"] = "observed";
|
|
12149
|
+
})(ETelemetryEvidence || (ETelemetryEvidence = {}));
|
|
12150
|
+
(function(ETelemetryCompleteness2) {
|
|
12151
|
+
ETelemetryCompleteness2["COMPLETE"] = "complete";
|
|
12152
|
+
ETelemetryCompleteness2["PARTIAL"] = "partial";
|
|
12153
|
+
})(ETelemetryCompleteness || (ETelemetryCompleteness = {}));
|
|
12154
|
+
(function(ETelemetryCoverage2) {
|
|
12155
|
+
ETelemetryCoverage2["PI_MODEL_TOOL_HOOK"] = "pi_model_tool_hook";
|
|
12156
|
+
ETelemetryCoverage2["CORE_ONLY"] = "core_only";
|
|
12157
|
+
})(ETelemetryCoverage || (ETelemetryCoverage = {}));
|
|
12158
|
+
(function(ETelemetryUsageSource2) {
|
|
12159
|
+
ETelemetryUsageSource2["UNKNOWN"] = "unknown";
|
|
12160
|
+
ETelemetryUsageSource2["PROVIDER_NORMALIZED"] = "provider_normalized";
|
|
12161
|
+
})(ETelemetryUsageSource || (ETelemetryUsageSource = {}));
|
|
12162
|
+
(function(ETelemetryAttemptVisibility2) {
|
|
12163
|
+
ETelemetryAttemptVisibility2["PROVIDER_INVOCATION"] = "provider_invocation";
|
|
12164
|
+
ETelemetryAttemptVisibility2["TOOL_PROVIDER_INVOCATION"] = "tool_provider_invocation";
|
|
12165
|
+
})(ETelemetryAttemptVisibility || (ETelemetryAttemptVisibility = {}));
|
|
12166
|
+
(function(ETelemetryLinkRelation2) {
|
|
12167
|
+
ETelemetryLinkRelation2["GENERATED_BY"] = "generated_by";
|
|
12168
|
+
ETelemetryLinkRelation2["SCHEDULED_BY"] = "scheduled_by";
|
|
12169
|
+
})(ETelemetryLinkRelation || (ETelemetryLinkRelation = {}));
|
|
12170
|
+
(function(ETelemetryToolFailureStage2) {
|
|
12171
|
+
ETelemetryToolFailureStage2["BEFORE_HOOK"] = "before_hook";
|
|
12172
|
+
ETelemetryToolFailureStage2["EXECUTION"] = "execution";
|
|
12173
|
+
ETelemetryToolFailureStage2["AFTER_HOOK"] = "after_hook";
|
|
12174
|
+
})(ETelemetryToolFailureStage || (ETelemetryToolFailureStage = {}));
|
|
12175
|
+
(function(ETelemetryTerminalEvidence2) {
|
|
12176
|
+
ETelemetryTerminalEvidence2["EXPLICIT_DONE_HISTORY_COMMITTED"] = "explicit_done_history_committed";
|
|
12177
|
+
ETelemetryTerminalEvidence2["EXPLICIT_DONE"] = "explicit_done";
|
|
12178
|
+
ETelemetryTerminalEvidence2["STREAM_ERROR"] = "stream_error";
|
|
12179
|
+
ETelemetryTerminalEvidence2["CONSUMER_CANCEL"] = "consumer_cancel";
|
|
12180
|
+
ETelemetryTerminalEvidence2["NATURAL_EXHAUSTION"] = "natural_exhaustion";
|
|
12181
|
+
})(ETelemetryTerminalEvidence || (ETelemetryTerminalEvidence = {}));
|
|
12182
|
+
(function(ETelemetryTerminalSource2) {
|
|
12183
|
+
ETelemetryTerminalSource2["NATIVE_AGENT_END"] = "native_agent_end";
|
|
12184
|
+
ETelemetryTerminalSource2["PROMPT_RESOLVED_FALLBACK"] = "prompt_resolved_fallback";
|
|
12185
|
+
})(ETelemetryTerminalSource || (ETelemetryTerminalSource = {}));
|
|
12186
|
+
(function(ETelemetryModelPurpose2) {
|
|
12187
|
+
ETelemetryModelPurpose2["AGENT_LOOP"] = "agent_loop";
|
|
12188
|
+
})(ETelemetryModelPurpose || (ETelemetryModelPurpose = {}));
|
|
12189
|
+
(function(ETelemetryErrorType2) {
|
|
12190
|
+
ETelemetryErrorType2["PROVIDER_STREAM_ERROR"] = "ProviderStreamError";
|
|
12191
|
+
ETelemetryErrorType2["TOOL_EXECUTION_ERROR"] = "ToolExecutionError";
|
|
12192
|
+
ETelemetryErrorType2["HOOK_DISPATCH_ERROR"] = "HookDispatchError";
|
|
12193
|
+
ETelemetryErrorType2["HOOK_DRAIN_ERROR"] = "HookDrainError";
|
|
12194
|
+
})(ETelemetryErrorType || (ETelemetryErrorType = {}));
|
|
12195
|
+
(function(ETelemetrySpanKind2) {
|
|
12196
|
+
ETelemetrySpanKind2["INTERNAL"] = "internal";
|
|
12197
|
+
ETelemetrySpanKind2["CLIENT"] = "client";
|
|
12198
|
+
})(ETelemetrySpanKind || (ETelemetrySpanKind = {}));
|
|
12199
|
+
(function(ETelemetryGenAiOperation2) {
|
|
12200
|
+
ETelemetryGenAiOperation2["CHAT"] = "chat";
|
|
12201
|
+
ETelemetryGenAiOperation2["EXECUTE_TOOL"] = "execute_tool";
|
|
12202
|
+
ETelemetryGenAiOperation2["INVOKE_AGENT"] = "invoke_agent";
|
|
12203
|
+
})(ETelemetryGenAiOperation || (ETelemetryGenAiOperation = {}));
|
|
12204
|
+
(function(ETelemetryVersion2) {
|
|
12205
|
+
ETelemetryVersion2["V0_2"] = "0.2";
|
|
12206
|
+
ETelemetryVersion2["V1_0"] = "1.0";
|
|
12207
|
+
})(ETelemetryVersion || (ETelemetryVersion = {}));
|
|
12208
|
+
}
|
|
12209
|
+
});
|
|
12210
|
+
|
|
12211
|
+
// ../linkque-agent-protocol/dist/esm/telemetry.js
|
|
12212
|
+
var init_telemetry = __esm({
|
|
12213
|
+
"../linkque-agent-protocol/dist/esm/telemetry.js"() {
|
|
12214
|
+
"use strict";
|
|
12215
|
+
init_telemetryEnums();
|
|
12216
|
+
}
|
|
12217
|
+
});
|
|
12218
|
+
|
|
12219
|
+
// ../linkque-agent-runtime/dist/esm/core/telemetry/contentRecording.js
|
|
12220
|
+
function recordContentSection(observation, section, value, availability = "available") {
|
|
12221
|
+
observation?.record(ETelemetryEventName.CONTENT_RECORDED, {}, { section, value, availability });
|
|
12222
|
+
}
|
|
12223
|
+
function recordMcpContentSection(observation, section, value, schema) {
|
|
12224
|
+
if (!observation)
|
|
12225
|
+
return;
|
|
12226
|
+
const fieldTitles = {};
|
|
12227
|
+
const visit = (node, path9) => {
|
|
12228
|
+
if (!node || typeof node !== "object" || Array.isArray(node))
|
|
12229
|
+
return;
|
|
12230
|
+
const definition = node;
|
|
12231
|
+
if (path9 && typeof definition.title === "string" && definition.title.trim())
|
|
12232
|
+
fieldTitles[path9] = definition.title;
|
|
12233
|
+
const properties = definition.properties;
|
|
12234
|
+
if (properties && typeof properties === "object" && !Array.isArray(properties)) {
|
|
12235
|
+
for (const [key, child] of Object.entries(properties))
|
|
12236
|
+
visit(child, `${path9}/${key.replaceAll("~", "~0").replaceAll("/", "~1")}`);
|
|
12237
|
+
}
|
|
12238
|
+
if (definition.items)
|
|
12239
|
+
visit(definition.items, `${path9}/*`);
|
|
12240
|
+
};
|
|
12241
|
+
visit(schema, section === ETelemetryContentSection.MCP_OUTPUT ? "/structuredContent" : "");
|
|
12242
|
+
observation.record(ETelemetryEventName.CONTENT_RECORDED, {}, {
|
|
12243
|
+
section,
|
|
12244
|
+
value,
|
|
12245
|
+
availability: "available",
|
|
12246
|
+
...Object.keys(fieldTitles).length ? { fieldTitles } : {}
|
|
12247
|
+
});
|
|
12248
|
+
}
|
|
12249
|
+
var init_contentRecording = __esm({
|
|
12250
|
+
"../linkque-agent-runtime/dist/esm/core/telemetry/contentRecording.js"() {
|
|
12251
|
+
"use strict";
|
|
12252
|
+
init_telemetry();
|
|
12253
|
+
}
|
|
12254
|
+
});
|
|
12255
|
+
|
|
11889
12256
|
// ../linkque-agent-runtime/dist/esm/core/mcpProxyTool.js
|
|
11890
12257
|
function resourceIdsForTool(spec, toolName) {
|
|
11891
12258
|
if (!spec.allToolResourceIds && !spec.resourceIdsByTool)
|
|
@@ -11955,6 +12322,8 @@ var MCP_PROXY_TOOL_NAME, McpProxyTool, MCP_BATCH_SEARCH_MAX_ITEMS, MCP_PROXY_DES
|
|
|
11955
12322
|
var init_mcpProxyTool = __esm({
|
|
11956
12323
|
"../linkque-agent-runtime/dist/esm/core/mcpProxyTool.js"() {
|
|
11957
12324
|
"use strict";
|
|
12325
|
+
init_telemetry();
|
|
12326
|
+
init_contentRecording();
|
|
11958
12327
|
init_esm();
|
|
11959
12328
|
init_types();
|
|
11960
12329
|
MCP_PROXY_TOOL_NAME = "mcp";
|
|
@@ -12015,6 +12384,10 @@ var init_mcpProxyTool = __esm({
|
|
|
12015
12384
|
context: context2
|
|
12016
12385
|
});
|
|
12017
12386
|
return entry.server.callTool(tool.name, args, sig, {
|
|
12387
|
+
toolSchema: {
|
|
12388
|
+
inputSchema: tool.inputSchema,
|
|
12389
|
+
outputSchema: tool.outputSchema
|
|
12390
|
+
},
|
|
12018
12391
|
...headers ? { headers } : {},
|
|
12019
12392
|
...context2 ? { context: context2 } : {}
|
|
12020
12393
|
});
|
|
@@ -12108,25 +12481,35 @@ var init_mcpProxyTool = __esm({
|
|
|
12108
12481
|
async dispatch(args, signal, context2) {
|
|
12109
12482
|
const params = parseProxyArgs(args);
|
|
12110
12483
|
if (params.connect !== void 0) {
|
|
12111
|
-
return this.executeConnect(params.connect, signal);
|
|
12484
|
+
return this.executeConnect(params.connect, signal, context2);
|
|
12112
12485
|
}
|
|
12113
12486
|
if (params.describe !== void 0) {
|
|
12114
|
-
return this.executeDescribe(params.describe, params.server, signal);
|
|
12487
|
+
return this.executeDescribe(params.describe, params.server, signal, context2);
|
|
12115
12488
|
}
|
|
12116
12489
|
if (params.searches !== void 0) {
|
|
12117
|
-
return this.executeBatchSearch(params.searches, params.server);
|
|
12490
|
+
return this.executeBatchSearch(params.searches, params.server, context2);
|
|
12118
12491
|
}
|
|
12119
12492
|
if (params.search !== void 0) {
|
|
12120
|
-
|
|
12493
|
+
const result = await this.executeSearch(params.search, params.server);
|
|
12494
|
+
this.recordAction(context2, "search", result.tools.length ? "matched" : "no_hits", { query: result.query, tools: result.tools });
|
|
12495
|
+
return result.text;
|
|
12121
12496
|
}
|
|
12122
12497
|
if (params.tool !== void 0) {
|
|
12123
12498
|
return this.executeCall(params.tool, params.args, params.server, signal, context2);
|
|
12124
12499
|
}
|
|
12125
12500
|
if (params.server !== void 0) {
|
|
12126
|
-
return this.executeList(params.server, signal);
|
|
12501
|
+
return this.executeList(params.server, signal, context2);
|
|
12127
12502
|
}
|
|
12128
12503
|
return this.executeStatus();
|
|
12129
12504
|
}
|
|
12505
|
+
/** 保留代理动作事实,不改变供模型消费的原始返回值。 */
|
|
12506
|
+
recordAction(context2, action, status, data = {}) {
|
|
12507
|
+
recordContentSection(context2?.observation, ETelemetryContentSection.MCP_ACTION_OUTPUT, {
|
|
12508
|
+
action,
|
|
12509
|
+
status,
|
|
12510
|
+
...data
|
|
12511
|
+
});
|
|
12512
|
+
}
|
|
12130
12513
|
/** `mcp({})` / `mcp({ status: true })`:列各 server 连接状态 + 工具数。 */
|
|
12131
12514
|
executeStatus() {
|
|
12132
12515
|
const lines = [];
|
|
@@ -12154,35 +12537,43 @@ var init_mcpProxyTool = __esm({
|
|
|
12154
12537
|
${lines.join("\n")}${hint}`.trim();
|
|
12155
12538
|
}
|
|
12156
12539
|
/** `mcp({ connect: "server" })`:显式连接并刷元数据,返回该 server 工具列表。 */
|
|
12157
|
-
async executeConnect(server, signal) {
|
|
12540
|
+
async executeConnect(server, signal, context2) {
|
|
12158
12541
|
const spec = this.findSpec(server);
|
|
12159
|
-
if (!spec)
|
|
12542
|
+
if (!spec) {
|
|
12543
|
+
this.recordAction(context2, "connect", "not_found", { server });
|
|
12160
12544
|
return `Server "${server}" not found. Use mcp({}) to see available servers.`;
|
|
12545
|
+
}
|
|
12161
12546
|
this.entries.delete(spec.serverName);
|
|
12162
12547
|
const entry = await this.ensureEntry(spec.serverName, signal);
|
|
12163
12548
|
if (!entry) {
|
|
12549
|
+
this.recordAction(context2, "connect", "failed", { server: spec.serverName });
|
|
12164
12550
|
const failed = this.entries.get(spec.serverName);
|
|
12165
12551
|
const detail = failed?.error ? `: ${failed.error}` : "";
|
|
12166
12552
|
return `Failed to connect to "${spec.serverName}"${detail}.`;
|
|
12167
12553
|
}
|
|
12554
|
+
this.recordAction(context2, "connect", "matched", { server: spec.serverName, tools: entry.tools.map((tool) => ({ name: tool.name, description: tool.description })) });
|
|
12168
12555
|
return this.formatToolList(spec.serverName, entry.tools);
|
|
12169
12556
|
}
|
|
12170
12557
|
/** `mcp({ server: "name" })`:列该 server 工具名 + 截断 description。 */
|
|
12171
|
-
async executeList(server, signal) {
|
|
12558
|
+
async executeList(server, signal, context2) {
|
|
12172
12559
|
const spec = this.findSpec(server);
|
|
12173
|
-
if (!spec)
|
|
12560
|
+
if (!spec) {
|
|
12561
|
+
this.recordAction(context2, "list", "not_found", { server });
|
|
12174
12562
|
return `Server "${server}" not found. Use mcp({}) to see available servers.`;
|
|
12563
|
+
}
|
|
12175
12564
|
const entry = await this.ensureEntry(spec.serverName, signal);
|
|
12176
12565
|
if (!entry) {
|
|
12566
|
+
this.recordAction(context2, "list", "failed", { server: spec.serverName });
|
|
12177
12567
|
return `Server "${spec.serverName}" is not connected. Use mcp({ connect: "${spec.serverName}" }) to retry.`;
|
|
12178
12568
|
}
|
|
12569
|
+
this.recordAction(context2, "list", "matched", { server: spec.serverName, tools: entry.tools.map((tool) => ({ name: tool.name, description: tool.description })) });
|
|
12179
12570
|
return this.formatToolList(spec.serverName, entry.tools);
|
|
12180
12571
|
}
|
|
12181
12572
|
/** `mcp({ search: "query" })`:空格分词 OR 子串匹配 name/description(跨所有 server)。 */
|
|
12182
12573
|
async executeSearch(query, serverHint) {
|
|
12183
12574
|
const terms = query.trim().split(/\s+/u).filter((t2) => t2.length > 0);
|
|
12184
12575
|
if (terms.length === 0)
|
|
12185
|
-
return "Search query cannot be empty.";
|
|
12576
|
+
return { query, text: "Search query cannot be empty.", tools: [] };
|
|
12186
12577
|
const pattern = new RegExp(terms.map(escapeRegExp).join("|"), "iu");
|
|
12187
12578
|
const specs = serverHint ? this.specsMatching(serverHint) : this.specs;
|
|
12188
12579
|
await Promise.all(specs.map((s2) => this.ensureEntry(s2.serverName)));
|
|
@@ -12197,8 +12588,9 @@ ${lines.join("\n")}${hint}`.trim();
|
|
|
12197
12588
|
}
|
|
12198
12589
|
}
|
|
12199
12590
|
}
|
|
12591
|
+
const tools = matches.map(({ server, tool }) => ({ server, name: tool.name, description: tool.description, inputSchema: tool.inputSchema }));
|
|
12200
12592
|
if (matches.length === 0) {
|
|
12201
|
-
return serverHint ? `No tools matching "${query}" in "${serverHint}"` : `No tools matching "${query}"
|
|
12593
|
+
return { query, tools, text: serverHint ? `No tools matching "${query}" in "${serverHint}"` : `No tools matching "${query}"` };
|
|
12202
12594
|
}
|
|
12203
12595
|
const lines = [`Found ${matches.length} tool(s) matching "${query}":`, ""];
|
|
12204
12596
|
for (const { server, tool } of matches) {
|
|
@@ -12210,10 +12602,10 @@ ${formatSchema(tool.inputSchema, " ")}`);
|
|
|
12210
12602
|
}
|
|
12211
12603
|
lines.push("");
|
|
12212
12604
|
}
|
|
12213
|
-
return lines.join("\n").trim();
|
|
12605
|
+
return { query, tools, text: lines.join("\n").trim() };
|
|
12214
12606
|
}
|
|
12215
12607
|
/** `mcp({ searches: [...] })`:一次连接元数据并按 query 分组执行多组搜索。 */
|
|
12216
|
-
async executeBatchSearch(queries, serverHint) {
|
|
12608
|
+
async executeBatchSearch(queries, serverHint, context2) {
|
|
12217
12609
|
const normalized = [
|
|
12218
12610
|
...new Set(queries.map((query) => query.trim()).filter(Boolean))
|
|
12219
12611
|
].slice(0, MCP_BATCH_SEARCH_MAX_ITEMS);
|
|
@@ -12223,16 +12615,19 @@ ${formatSchema(tool.inputSchema, " ")}`);
|
|
|
12223
12615
|
const specs = serverHint ? this.specsMatching(serverHint) : this.specs;
|
|
12224
12616
|
await Promise.all(specs.map((spec) => this.ensureEntry(spec.serverName)));
|
|
12225
12617
|
const results = await Promise.all(normalized.map((query) => this.executeSearch(query, serverHint)));
|
|
12618
|
+
this.recordAction(context2, "search", results.some((result) => result.tools.length) ? "matched" : "no_hits", { results: results.map(({ query, tools }) => ({ query, tools })) });
|
|
12226
12619
|
return results.map((result, index2) => `Query ${index2 + 1}: "${normalized[index2]}"
|
|
12227
|
-
${result}`).join("\n\n");
|
|
12620
|
+
${result.text}`).join("\n\n");
|
|
12228
12621
|
}
|
|
12229
12622
|
/** `mcp({ describe: "tool" })`:输出工具所属 server + 参数 schema。 */
|
|
12230
|
-
async executeDescribe(toolName, serverHint, signal) {
|
|
12623
|
+
async executeDescribe(toolName, serverHint, signal, context2) {
|
|
12231
12624
|
const found = await this.findTool(toolName, serverHint, signal);
|
|
12232
12625
|
if (!found) {
|
|
12626
|
+
this.recordAction(context2, "describe", "not_found", { name: toolName });
|
|
12233
12627
|
return `Tool "${toolName}" not found. Use mcp({ search: "..." }) to search.`;
|
|
12234
12628
|
}
|
|
12235
12629
|
const { server, tool } = found;
|
|
12630
|
+
this.recordAction(context2, "describe", "matched", { server, name: tool.name, inputSchema: tool.inputSchema });
|
|
12236
12631
|
const lines = [
|
|
12237
12632
|
`${tool.name}`,
|
|
12238
12633
|
`Server: ${server}`,
|
|
@@ -12251,6 +12646,7 @@ ${formatSchema(tool.inputSchema)}`);
|
|
|
12251
12646
|
async executeCall(toolName, args, serverHint, signal, context2) {
|
|
12252
12647
|
const found = await this.findTool(toolName, serverHint, signal);
|
|
12253
12648
|
if (!found) {
|
|
12649
|
+
this.recordAction(context2, "call", "not_found", { name: toolName });
|
|
12254
12650
|
return `Tool "${toolName}" not found. Use mcp({ search: "..." }) to search.`;
|
|
12255
12651
|
}
|
|
12256
12652
|
const { entry, tool, spec } = found;
|
|
@@ -12262,11 +12658,17 @@ ${formatSchema(tool.inputSchema)}`);
|
|
|
12262
12658
|
context: context2
|
|
12263
12659
|
});
|
|
12264
12660
|
const result = await entry.server.callTool(tool.name, args, signal, {
|
|
12661
|
+
toolSchema: {
|
|
12662
|
+
inputSchema: tool.inputSchema,
|
|
12663
|
+
outputSchema: tool.outputSchema
|
|
12664
|
+
},
|
|
12265
12665
|
...headers ? { headers } : {},
|
|
12266
12666
|
...context2 ? { context: context2 } : {}
|
|
12267
12667
|
});
|
|
12668
|
+
this.recordAction(context2, "call", result && typeof result === "object" && "isError" in result && result.isError === true ? "failed" : "completed", { name: tool.name, server: spec.serverName });
|
|
12268
12669
|
return serializeToolResult(result);
|
|
12269
12670
|
} catch (error40) {
|
|
12671
|
+
this.recordAction(context2, "call", signal?.aborted ? "cancelled" : "failed", { name: tool.name, server: spec.serverName });
|
|
12270
12672
|
const message = error40 instanceof Error ? error40.message : String(error40);
|
|
12271
12673
|
return `Tool "${toolName}" call failed: ${message}`;
|
|
12272
12674
|
}
|
|
@@ -12626,317 +13028,6 @@ var init_hookRegistry = __esm({
|
|
|
12626
13028
|
}
|
|
12627
13029
|
});
|
|
12628
13030
|
|
|
12629
|
-
// ../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;
|
|
12631
|
-
var init_telemetryEnums = __esm({
|
|
12632
|
-
"../linkque-agent-protocol/dist/esm/telemetry/telemetryEnums.js"() {
|
|
12633
|
-
"use strict";
|
|
12634
|
-
(function(ETelemetryAttribute2) {
|
|
12635
|
-
ETelemetryAttribute2["HARNESS_TELEMETRY_SCHEMA_VERSION"] = "harness.telemetry.schema.version";
|
|
12636
|
-
ETelemetryAttribute2["LINKQUE_TELEMETRY_SCHEMA_VERSION"] = "linkque.telemetry.schema.version";
|
|
12637
|
-
ETelemetryAttribute2["LINKQUE_TELEMETRY_ADAPTER_VERSION"] = "linkque.telemetry.adapter.version";
|
|
12638
|
-
ETelemetryAttribute2["HARNESS_TELEMETRY_SOURCE"] = "harness.telemetry.source";
|
|
12639
|
-
ETelemetryAttribute2["HARNESS_TELEMETRY_EVIDENCE"] = "harness.telemetry.evidence";
|
|
12640
|
-
ETelemetryAttribute2["HARNESS_TELEMETRY_COMPLETENESS"] = "harness.telemetry.completeness";
|
|
12641
|
-
ETelemetryAttribute2["LINKQUE_RUNTIME_KIND"] = "linkque.runtime.kind";
|
|
12642
|
-
ETelemetryAttribute2["LINKQUE_RUN_ID"] = "linkque.run.id";
|
|
12643
|
-
ETelemetryAttribute2["LINKQUE_AGENT_ID"] = "linkque.agent.id";
|
|
12644
|
-
ETelemetryAttribute2["HARNESS_SESSION_ID"] = "harness.session.id";
|
|
12645
|
-
ETelemetryAttribute2["LINKQUE_CONVERSATION_ID"] = "linkque.conversation.id";
|
|
12646
|
-
ETelemetryAttribute2["LINKQUE_REQUEST_ID"] = "linkque.request.id";
|
|
12647
|
-
ETelemetryAttribute2["LINKQUE_TURN_ID"] = "linkque.turn.id";
|
|
12648
|
-
ETelemetryAttribute2["LINKQUE_ACCOUNT_ID"] = "linkque.account.id";
|
|
12649
|
-
ETelemetryAttribute2["LINKQUE_CHANNEL"] = "linkque.channel";
|
|
12650
|
-
ETelemetryAttribute2["LINKQUE_USER_KEY"] = "linkque.user.key";
|
|
12651
|
-
ETelemetryAttribute2["HARNESS_ADVANCE_ID"] = "harness.advance.id";
|
|
12652
|
-
ETelemetryAttribute2["HARNESS_CALL_ID"] = "harness.call.id";
|
|
12653
|
-
ETelemetryAttribute2["HARNESS_INVOCATION_ID"] = "harness.invocation.id";
|
|
12654
|
-
ETelemetryAttribute2["HARNESS_ATTEMPT_ID"] = "harness.attempt.id";
|
|
12655
|
-
ETelemetryAttribute2["HARNESS_ATTEMPT_VISIBILITY"] = "harness.attempt.visibility";
|
|
12656
|
-
ETelemetryAttribute2["HARNESS_ADVANCE_OUTCOME"] = "harness.advance.outcome";
|
|
12657
|
-
ETelemetryAttribute2["HARNESS_OPERATION_OUTCOME"] = "harness.operation.outcome";
|
|
12658
|
-
ETelemetryAttribute2["HARNESS_REMOTE_COMPLETION"] = "harness.remote.completion";
|
|
12659
|
-
ETelemetryAttribute2["HARNESS_STATE_COMMIT_STATUS"] = "harness.state.commit.status";
|
|
12660
|
-
ETelemetryAttribute2["LINKQUE_OPERATION_ID"] = "linkque.operation.id";
|
|
12661
|
-
ETelemetryAttribute2["LINKQUE_OPERATION_NAME"] = "linkque.operation.name";
|
|
12662
|
-
ETelemetryAttribute2["LINKQUE_OPERATION_PARENT_ID"] = "linkque.operation.parent_id";
|
|
12663
|
-
ETelemetryAttribute2["LINKQUE_SPAN_PARENT_ID"] = "linkque.span.parent_id";
|
|
12664
|
-
ETelemetryAttribute2["HARNESS_RECORD_ID"] = "harness.record.id";
|
|
12665
|
-
ETelemetryAttribute2["HARNESS_EVENT_SEQUENCE"] = "harness.event.sequence";
|
|
12666
|
-
ETelemetryAttribute2["ERROR_TYPE"] = "error.type";
|
|
12667
|
-
ETelemetryAttribute2["LINKQUE_STREAM_TERMINATION"] = "linkque.stream.termination";
|
|
12668
|
-
ETelemetryAttribute2["LINKQUE_STREAM_CANCEL_SOURCE"] = "linkque.stream.cancel_source";
|
|
12669
|
-
ETelemetryAttribute2["LINKQUE_TERMINAL_EVIDENCE"] = "linkque.terminal.evidence";
|
|
12670
|
-
ETelemetryAttribute2["LINKQUE_RUNTIME_CLEANUP_OUTCOME"] = "linkque.runtime.cleanup_outcome";
|
|
12671
|
-
ETelemetryAttribute2["LINKQUE_OBSERVATION_BOUNDARY"] = "linkque.observation.boundary";
|
|
12672
|
-
ETelemetryAttribute2["LINKQUE_LOOP_ITERATION_ID"] = "linkque.loop.iteration.id";
|
|
12673
|
-
ETelemetryAttribute2["LINKQUE_LOOP_ITERATION_INDEX"] = "linkque.loop.iteration.index";
|
|
12674
|
-
ETelemetryAttribute2["LINKQUE_STREAM_TERMINAL_SOURCE"] = "linkque.stream.terminal_source";
|
|
12675
|
-
ETelemetryAttribute2["LINKQUE_STREAM_PUBLIC_TEXT_DELTA_COUNT"] = "linkque.stream.public_text_delta_count";
|
|
12676
|
-
ETelemetryAttribute2["LINKQUE_STREAM_THINKING_DELTA_COUNT"] = "linkque.stream.thinking_delta_count";
|
|
12677
|
-
ETelemetryAttribute2["LINKQUE_MODEL_FIRST_CHUNK_MS"] = "linkque.model.first_chunk_ms";
|
|
12678
|
-
ETelemetryAttribute2["LINKQUE_MODEL_FIRST_TEXT_MS"] = "linkque.model.first_text_ms";
|
|
12679
|
-
ETelemetryAttribute2["LINKQUE_LOOP_FIRST_PUBLIC_TEXT_MS"] = "linkque.loop.first_public_text_ms";
|
|
12680
|
-
ETelemetryAttribute2["LINKQUE_MODEL_CHUNK_COUNT"] = "linkque.model.chunk_count";
|
|
12681
|
-
ETelemetryAttribute2["LINKQUE_MODEL_TEXT_CHARS"] = "linkque.model.text_chars";
|
|
12682
|
-
ETelemetryAttribute2["LINKQUE_MODEL_THINKING_CHARS"] = "linkque.model.thinking_chars";
|
|
12683
|
-
ETelemetryAttribute2["GEN_AI_OPERATION_NAME"] = "gen_ai.operation.name";
|
|
12684
|
-
ETelemetryAttribute2["GEN_AI_AGENT_NAME"] = "gen_ai.agent.name";
|
|
12685
|
-
ETelemetryAttribute2["GEN_AI_PROVIDER_NAME"] = "gen_ai.provider.name";
|
|
12686
|
-
ETelemetryAttribute2["GEN_AI_REQUEST_MODEL"] = "gen_ai.request.model";
|
|
12687
|
-
ETelemetryAttribute2["GEN_AI_RESPONSE_MODEL"] = "gen_ai.response.model";
|
|
12688
|
-
ETelemetryAttribute2["GEN_AI_RESPONSE_ID"] = "gen_ai.response.id";
|
|
12689
|
-
ETelemetryAttribute2["GEN_AI_RESPONSE_FINISH_REASONS"] = "gen_ai.response.finish_reasons";
|
|
12690
|
-
ETelemetryAttribute2["GEN_AI_USAGE_INPUT_TOKENS"] = "gen_ai.usage.input_tokens";
|
|
12691
|
-
ETelemetryAttribute2["GEN_AI_USAGE_OUTPUT_TOKENS"] = "gen_ai.usage.output_tokens";
|
|
12692
|
-
ETelemetryAttribute2["GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS"] = "gen_ai.usage.cache_read.input_tokens";
|
|
12693
|
-
ETelemetryAttribute2["GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS"] = "gen_ai.usage.cache_creation.input_tokens";
|
|
12694
|
-
ETelemetryAttribute2["GEN_AI_USAGE_REASONING_OUTPUT_TOKENS"] = "gen_ai.usage.reasoning.output_tokens";
|
|
12695
|
-
ETelemetryAttribute2["HARNESS_USAGE_SOURCE"] = "harness.usage.source";
|
|
12696
|
-
ETelemetryAttribute2["HARNESS_USAGE_ATTEMPT_COVERAGE"] = "harness.usage.attempt_coverage";
|
|
12697
|
-
ETelemetryAttribute2["HARNESS_MODEL_PURPOSE"] = "harness.model.purpose";
|
|
12698
|
-
ETelemetryAttribute2["HARNESS_MODEL_INVOCATION_COUNT"] = "harness.model.invocation_count";
|
|
12699
|
-
ETelemetryAttribute2["GEN_AI_TOOL_NAME"] = "gen_ai.tool.name";
|
|
12700
|
-
ETelemetryAttribute2["GEN_AI_TOOL_CALL_ID"] = "gen_ai.tool.call.id";
|
|
12701
|
-
ETelemetryAttribute2["HARNESS_TOOL_RESULT_STATUS"] = "harness.tool.result.status";
|
|
12702
|
-
ETelemetryAttribute2["LINKQUE_TOOL_FAILURE_STAGE"] = "linkque.tool.failure_stage";
|
|
12703
|
-
ETelemetryAttribute2["HARNESS_HOOK_NAME"] = "harness.hook.name";
|
|
12704
|
-
ETelemetryAttribute2["LINKQUE_HOOK_STAGE"] = "linkque.hook.stage";
|
|
12705
|
-
ETelemetryAttribute2["LINKQUE_HOOK_RESOURCE_ID"] = "linkque.hook.resource_id";
|
|
12706
|
-
ETelemetryAttribute2["LINKQUE_HOOK_EVENT_ID"] = "linkque.hook.event_id";
|
|
12707
|
-
ETelemetryAttribute2["LINKQUE_HOOK_MATCHED_COUNT"] = "linkque.hook.matched_count";
|
|
12708
|
-
ETelemetryAttribute2["LINKQUE_HOOK_PENDING_COUNT"] = "linkque.hook.pending_count";
|
|
12709
|
-
ETelemetryAttribute2["LINKQUE_HOOK_SCHEDULED_COUNT"] = "linkque.hook.scheduled_count";
|
|
12710
|
-
ETelemetryAttribute2["LINKQUE_HOOK_HAS_SIDE_EFFECTS"] = "linkque.hook.has_side_effects";
|
|
12711
|
-
ETelemetryAttribute2["LINKQUE_HOOK_MODE"] = "linkque.hook.mode";
|
|
12712
|
-
ETelemetryAttribute2["LINKQUE_HOOK_TIMEOUT_MS"] = "linkque.hook.timeout_ms";
|
|
12713
|
-
ETelemetryAttribute2["LINKQUE_HOOK_RESULT"] = "linkque.hook.result";
|
|
12714
|
-
ETelemetryAttribute2["HARNESS_MIDDLEWARE_NAME"] = "harness.middleware.name";
|
|
12715
|
-
ETelemetryAttribute2["HARNESS_MIDDLEWARE_INVOCATION_ID"] = "harness.middleware.invocation.id";
|
|
12716
|
-
ETelemetryAttribute2["LINKQUE_HOOK_EXECUTOR_SETTLED"] = "linkque.hook.executor_settled";
|
|
12717
|
-
ETelemetryAttribute2["LINKQUE_HISTORY_MESSAGE_COUNT"] = "linkque.history.message_count";
|
|
12718
|
-
ETelemetryAttribute2["LINKQUE_TELEMETRY_COVERAGE"] = "linkque.telemetry.coverage";
|
|
12719
|
-
ETelemetryAttribute2["LINKQUE_TELEMETRY_LOSS_REASON"] = "linkque.telemetry.loss_reason";
|
|
12720
|
-
ETelemetryAttribute2["LINKQUE_OPERATION_DURATION_MS"] = "linkque.operation.duration_ms";
|
|
12721
|
-
ETelemetryAttribute2["HTTP_RESPONSE_STATUS_CODE"] = "http.response.status_code";
|
|
12722
|
-
ETelemetryAttribute2["SERVICE_NAME"] = "service.name";
|
|
12723
|
-
ETelemetryAttribute2["SERVICE_NAMESPACE"] = "service.namespace";
|
|
12724
|
-
ETelemetryAttribute2["SERVICE_VERSION"] = "service.version";
|
|
12725
|
-
ETelemetryAttribute2["SERVICE_INSTANCE_ID"] = "service.instance.id";
|
|
12726
|
-
ETelemetryAttribute2["DEPLOYMENT_ENVIRONMENT_NAME"] = "deployment.environment.name";
|
|
12727
|
-
ETelemetryAttribute2["LINKQUE_LINK_RELATION"] = "linkque.link.relation";
|
|
12728
|
-
})(ETelemetryAttribute || (ETelemetryAttribute = {}));
|
|
12729
|
-
(function(ETelemetryEventPrefix2) {
|
|
12730
|
-
ETelemetryEventPrefix2["OPERATION"] = "linkque.operation";
|
|
12731
|
-
ETelemetryEventPrefix2["ADVANCE"] = "harness.advance";
|
|
12732
|
-
ETelemetryEventPrefix2["MODEL_INVOKE"] = "harness.model.invoke";
|
|
12733
|
-
ETelemetryEventPrefix2["MODEL_ATTEMPT"] = "harness.model.attempt";
|
|
12734
|
-
ETelemetryEventPrefix2["TOOL_INVOKE"] = "harness.tool.invoke";
|
|
12735
|
-
ETelemetryEventPrefix2["TOOL_ATTEMPT"] = "harness.tool.attempt";
|
|
12736
|
-
ETelemetryEventPrefix2["HOOK_CHAIN"] = "harness.hook.chain";
|
|
12737
|
-
ETelemetryEventPrefix2["MIDDLEWARE"] = "harness.middleware";
|
|
12738
|
-
ETelemetryEventPrefix2["LOOP"] = "linkque.loop";
|
|
12739
|
-
ETelemetryEventPrefix2["LOOP_ITERATION"] = "linkque.loop.iteration";
|
|
12740
|
-
ETelemetryEventPrefix2["HISTORY_APPEND"] = "linkque.history.append";
|
|
12741
|
-
ETelemetryEventPrefix2["HOOK_DRAIN"] = "linkque.hook.drain";
|
|
12742
|
-
})(ETelemetryEventPrefix || (ETelemetryEventPrefix = {}));
|
|
12743
|
-
(function(ETelemetryEventPhase2) {
|
|
12744
|
-
ETelemetryEventPhase2["STARTED"] = "started";
|
|
12745
|
-
ETelemetryEventPhase2["FINISHED"] = "finished";
|
|
12746
|
-
ETelemetryEventPhase2["OBSERVATION_LOST"] = "observation_lost";
|
|
12747
|
-
})(ETelemetryEventPhase || (ETelemetryEventPhase = {}));
|
|
12748
|
-
(function(ETelemetryEventName2) {
|
|
12749
|
-
ETelemetryEventName2["TOOL_EXECUTION_FAILED"] = "linkque.tool.execution.failed";
|
|
12750
|
-
ETelemetryEventName2["TELEMETRY_COVERAGE"] = "linkque.telemetry.coverage";
|
|
12751
|
-
ETelemetryEventName2["HOOK_MATCHED"] = "linkque.hook.matched";
|
|
12752
|
-
ETelemetryEventName2["HOOK_SCHEDULED"] = "linkque.hook.scheduled";
|
|
12753
|
-
ETelemetryEventName2["HOOK_CANCEL_REQUESTED"] = "linkque.hook.cancel_requested";
|
|
12754
|
-
ETelemetryEventName2["HOOK_TIMEOUT_REQUESTED"] = "linkque.hook.timeout_requested";
|
|
12755
|
-
ETelemetryEventName2["HOOK_EXECUTOR_SETTLED"] = "linkque.hook.executor_settled";
|
|
12756
|
-
ETelemetryEventName2["HOOK_WAIT_FINISHED"] = "linkque.hook.wait_finished";
|
|
12757
|
-
ETelemetryEventName2["LOOP_FIRST_PUBLIC_TEXT"] = "linkque.loop.first_public_text";
|
|
12758
|
-
ETelemetryEventName2["STREAM_TERMINAL_OBSERVED"] = "linkque.stream.terminal_observed";
|
|
12759
|
-
ETelemetryEventName2["MODEL_FIRST_CHUNK"] = "harness.model.first_chunk";
|
|
12760
|
-
ETelemetryEventName2["MODEL_FIRST_TEXT"] = "harness.model.first_text";
|
|
12761
|
-
ETelemetryEventName2["MODEL_USAGE_RECORDED"] = "linkque.model.usage.recorded";
|
|
12762
|
-
ETelemetryEventName2["MODEL_RESPONSE_HEADERS"] = "linkque.model.response_headers";
|
|
12763
|
-
ETelemetryEventName2["OPERATION_OBSERVATION_LOST"] = "linkque.operation.observation_lost";
|
|
12764
|
-
ETelemetryEventName2["RUNTIME_UNCAUGHT_ERROR"] = "linkque.runtime.uncaught_error";
|
|
12765
|
-
ETelemetryEventName2["OPERATION_STARTED"] = "linkque.operation.started";
|
|
12766
|
-
ETelemetryEventName2["OPERATION_FINISHED"] = "linkque.operation.finished";
|
|
12767
|
-
ETelemetryEventName2["ADVANCE_STARTED"] = "harness.advance.started";
|
|
12768
|
-
ETelemetryEventName2["ADVANCE_FINISHED"] = "harness.advance.finished";
|
|
12769
|
-
ETelemetryEventName2["MODEL_INVOKE_STARTED"] = "harness.model.invoke.started";
|
|
12770
|
-
ETelemetryEventName2["MODEL_INVOKE_FINISHED"] = "harness.model.invoke.finished";
|
|
12771
|
-
ETelemetryEventName2["MODEL_ATTEMPT_STARTED"] = "harness.model.attempt.started";
|
|
12772
|
-
ETelemetryEventName2["MODEL_ATTEMPT_FINISHED"] = "harness.model.attempt.finished";
|
|
12773
|
-
ETelemetryEventName2["TOOL_INVOKE_STARTED"] = "harness.tool.invoke.started";
|
|
12774
|
-
ETelemetryEventName2["TOOL_INVOKE_FINISHED"] = "harness.tool.invoke.finished";
|
|
12775
|
-
ETelemetryEventName2["TOOL_ATTEMPT_STARTED"] = "harness.tool.attempt.started";
|
|
12776
|
-
ETelemetryEventName2["TOOL_ATTEMPT_FINISHED"] = "harness.tool.attempt.finished";
|
|
12777
|
-
ETelemetryEventName2["HOOK_CHAIN_STARTED"] = "harness.hook.chain.started";
|
|
12778
|
-
ETelemetryEventName2["HOOK_CHAIN_FINISHED"] = "harness.hook.chain.finished";
|
|
12779
|
-
ETelemetryEventName2["MIDDLEWARE_STARTED"] = "harness.middleware.started";
|
|
12780
|
-
ETelemetryEventName2["MIDDLEWARE_FINISHED"] = "harness.middleware.finished";
|
|
12781
|
-
ETelemetryEventName2["LOOP_STARTED"] = "linkque.loop.started";
|
|
12782
|
-
ETelemetryEventName2["LOOP_FINISHED"] = "linkque.loop.finished";
|
|
12783
|
-
ETelemetryEventName2["LOOP_ITERATION_STARTED"] = "linkque.loop.iteration.started";
|
|
12784
|
-
ETelemetryEventName2["LOOP_ITERATION_FINISHED"] = "linkque.loop.iteration.finished";
|
|
12785
|
-
ETelemetryEventName2["HISTORY_APPEND_STARTED"] = "linkque.history.append.started";
|
|
12786
|
-
ETelemetryEventName2["HISTORY_APPEND_FINISHED"] = "linkque.history.append.finished";
|
|
12787
|
-
ETelemetryEventName2["HOOK_DRAIN_STARTED"] = "linkque.hook.drain.started";
|
|
12788
|
-
ETelemetryEventName2["HOOK_DRAIN_FINISHED"] = "linkque.hook.drain.finished";
|
|
12789
|
-
})(ETelemetryEventName || (ETelemetryEventName = {}));
|
|
12790
|
-
(function(ETelemetryOperationName2) {
|
|
12791
|
-
ETelemetryOperationName2["OPERATION"] = "linkque.operation";
|
|
12792
|
-
ETelemetryOperationName2["TOOL_INVOKE"] = "harness.tool.invoke";
|
|
12793
|
-
ETelemetryOperationName2["ADVANCE"] = "harness.advance";
|
|
12794
|
-
ETelemetryOperationName2["MODEL_INVOKE"] = "harness.model.invoke";
|
|
12795
|
-
ETelemetryOperationName2["MODEL_ATTEMPT"] = "harness.model.attempt";
|
|
12796
|
-
ETelemetryOperationName2["TOOL_ATTEMPT"] = "harness.tool.attempt";
|
|
12797
|
-
ETelemetryOperationName2["HOOK_CHAIN"] = "harness.hook.chain";
|
|
12798
|
-
ETelemetryOperationName2["MIDDLEWARE"] = "harness.middleware";
|
|
12799
|
-
ETelemetryOperationName2["LOOP"] = "linkque.agent.loop";
|
|
12800
|
-
ETelemetryOperationName2["ITERATION"] = "linkque.agent.iteration";
|
|
12801
|
-
ETelemetryOperationName2["SESSION_LOAD"] = "harness.session.load";
|
|
12802
|
-
ETelemetryOperationName2["HISTORY_APPEND"] = "linkque.history.append";
|
|
12803
|
-
ETelemetryOperationName2["CLEANUP"] = "linkque.runtime.cleanup";
|
|
12804
|
-
ETelemetryOperationName2["HOOK_DRAIN"] = "linkque.hook.drain";
|
|
12805
|
-
})(ETelemetryOperationName || (ETelemetryOperationName = {}));
|
|
12806
|
-
(function(ETelemetryOutcome2) {
|
|
12807
|
-
ETelemetryOutcome2["SUCCESS"] = "success";
|
|
12808
|
-
ETelemetryOutcome2["ERROR"] = "error";
|
|
12809
|
-
ETelemetryOutcome2["CANCELLED"] = "cancelled";
|
|
12810
|
-
ETelemetryOutcome2["TIMEOUT"] = "timeout";
|
|
12811
|
-
ETelemetryOutcome2["REJECTED"] = "rejected";
|
|
12812
|
-
ETelemetryOutcome2["UNKNOWN"] = "unknown";
|
|
12813
|
-
})(ETelemetryOutcome || (ETelemetryOutcome = {}));
|
|
12814
|
-
(function(ETelemetrySignal2) {
|
|
12815
|
-
ETelemetrySignal2["LOGS"] = "logs";
|
|
12816
|
-
ETelemetrySignal2["TRACES"] = "traces";
|
|
12817
|
-
})(ETelemetrySignal || (ETelemetrySignal = {}));
|
|
12818
|
-
(function(ETelemetryLossReason2) {
|
|
12819
|
-
ETelemetryLossReason2["UNCAUGHT_ERROR"] = "uncaught_error";
|
|
12820
|
-
ETelemetryLossReason2["ACTIVE_LIMIT"] = "active_limit";
|
|
12821
|
-
ETelemetryLossReason2["ACTIVE_EXPIRED"] = "active_expired";
|
|
12822
|
-
ETelemetryLossReason2["SHUTDOWN"] = "shutdown";
|
|
12823
|
-
})(ETelemetryLossReason || (ETelemetryLossReason = {}));
|
|
12824
|
-
(function(ETelemetryAdvanceOutcome2) {
|
|
12825
|
-
ETelemetryAdvanceOutcome2["FAILED"] = "failed";
|
|
12826
|
-
ETelemetryAdvanceOutcome2["COMPLETED"] = "completed";
|
|
12827
|
-
ETelemetryAdvanceOutcome2["UNKNOWN"] = "unknown";
|
|
12828
|
-
})(ETelemetryAdvanceOutcome || (ETelemetryAdvanceOutcome = {}));
|
|
12829
|
-
(function(ETelemetryStreamTermination2) {
|
|
12830
|
-
ETelemetryStreamTermination2["CANCEL"] = "cancel";
|
|
12831
|
-
ETelemetryStreamTermination2["ERROR"] = "error";
|
|
12832
|
-
ETelemetryStreamTermination2["COMPLETE"] = "complete";
|
|
12833
|
-
ETelemetryStreamTermination2["EXHAUSTED"] = "exhausted";
|
|
12834
|
-
})(ETelemetryStreamTermination || (ETelemetryStreamTermination = {}));
|
|
12835
|
-
(function(ETelemetryCancelSource2) {
|
|
12836
|
-
ETelemetryCancelSource2["HOST_SIGNAL"] = "host_signal";
|
|
12837
|
-
ETelemetryCancelSource2["CONSUMER_RETURN"] = "consumer_return";
|
|
12838
|
-
})(ETelemetryCancelSource || (ETelemetryCancelSource = {}));
|
|
12839
|
-
(function(ETelemetryObservationBoundary2) {
|
|
12840
|
-
ETelemetryObservationBoundary2["LOCAL_WAIT"] = "local_wait";
|
|
12841
|
-
ETelemetryObservationBoundary2["EXECUTOR_SETTLED"] = "executor_settled";
|
|
12842
|
-
ETelemetryObservationBoundary2["GENERATOR_WITH_SETUP_AND_CLEANUP"] = "generator_with_setup_and_cleanup";
|
|
12843
|
-
})(ETelemetryObservationBoundary || (ETelemetryObservationBoundary = {}));
|
|
12844
|
-
(function(ETelemetryRemoteCompletion2) {
|
|
12845
|
-
ETelemetryRemoteCompletion2["UNKNOWN"] = "unknown";
|
|
12846
|
-
ETelemetryRemoteCompletion2["NOT_DISPATCHED"] = "not_dispatched";
|
|
12847
|
-
ETelemetryRemoteCompletion2["CONFIRMED"] = "confirmed";
|
|
12848
|
-
})(ETelemetryRemoteCompletion || (ETelemetryRemoteCompletion = {}));
|
|
12849
|
-
(function(ETelemetryCommitStatus2) {
|
|
12850
|
-
ETelemetryCommitStatus2["COMMITTED"] = "committed";
|
|
12851
|
-
ETelemetryCommitStatus2["FAILED"] = "failed";
|
|
12852
|
-
})(ETelemetryCommitStatus || (ETelemetryCommitStatus = {}));
|
|
12853
|
-
(function(ETelemetryHookMode2) {
|
|
12854
|
-
ETelemetryHookMode2["AWAITED"] = "awaited";
|
|
12855
|
-
ETelemetryHookMode2["DETACHED"] = "detached";
|
|
12856
|
-
})(ETelemetryHookMode || (ETelemetryHookMode = {}));
|
|
12857
|
-
(function(ETelemetryHookResult2) {
|
|
12858
|
-
ETelemetryHookResult2["OK"] = "ok";
|
|
12859
|
-
ETelemetryHookResult2["TIMEOUT"] = "timeout";
|
|
12860
|
-
ETelemetryHookResult2["SKIPPED"] = "skipped";
|
|
12861
|
-
ETelemetryHookResult2["SUCCESS"] = "success";
|
|
12862
|
-
ETelemetryHookResult2["ERROR"] = "error";
|
|
12863
|
-
})(ETelemetryHookResult || (ETelemetryHookResult = {}));
|
|
12864
|
-
(function(ETelemetrySource2) {
|
|
12865
|
-
ETelemetrySource2["KERNEL"] = "kernel";
|
|
12866
|
-
ETelemetrySource2["PROVIDER"] = "provider";
|
|
12867
|
-
})(ETelemetrySource || (ETelemetrySource = {}));
|
|
12868
|
-
(function(ETelemetryEvidence2) {
|
|
12869
|
-
ETelemetryEvidence2["OBSERVED"] = "observed";
|
|
12870
|
-
})(ETelemetryEvidence || (ETelemetryEvidence = {}));
|
|
12871
|
-
(function(ETelemetryCompleteness2) {
|
|
12872
|
-
ETelemetryCompleteness2["COMPLETE"] = "complete";
|
|
12873
|
-
ETelemetryCompleteness2["PARTIAL"] = "partial";
|
|
12874
|
-
})(ETelemetryCompleteness || (ETelemetryCompleteness = {}));
|
|
12875
|
-
(function(ETelemetryCoverage2) {
|
|
12876
|
-
ETelemetryCoverage2["PI_MODEL_TOOL_HOOK"] = "pi_model_tool_hook";
|
|
12877
|
-
ETelemetryCoverage2["CORE_ONLY"] = "core_only";
|
|
12878
|
-
})(ETelemetryCoverage || (ETelemetryCoverage = {}));
|
|
12879
|
-
(function(ETelemetryUsageSource2) {
|
|
12880
|
-
ETelemetryUsageSource2["UNKNOWN"] = "unknown";
|
|
12881
|
-
ETelemetryUsageSource2["PROVIDER_NORMALIZED"] = "provider_normalized";
|
|
12882
|
-
})(ETelemetryUsageSource || (ETelemetryUsageSource = {}));
|
|
12883
|
-
(function(ETelemetryAttemptVisibility2) {
|
|
12884
|
-
ETelemetryAttemptVisibility2["PROVIDER_INVOCATION"] = "provider_invocation";
|
|
12885
|
-
ETelemetryAttemptVisibility2["TOOL_PROVIDER_INVOCATION"] = "tool_provider_invocation";
|
|
12886
|
-
})(ETelemetryAttemptVisibility || (ETelemetryAttemptVisibility = {}));
|
|
12887
|
-
(function(ETelemetryLinkRelation2) {
|
|
12888
|
-
ETelemetryLinkRelation2["GENERATED_BY"] = "generated_by";
|
|
12889
|
-
ETelemetryLinkRelation2["SCHEDULED_BY"] = "scheduled_by";
|
|
12890
|
-
})(ETelemetryLinkRelation || (ETelemetryLinkRelation = {}));
|
|
12891
|
-
(function(ETelemetryToolFailureStage2) {
|
|
12892
|
-
ETelemetryToolFailureStage2["BEFORE_HOOK"] = "before_hook";
|
|
12893
|
-
ETelemetryToolFailureStage2["EXECUTION"] = "execution";
|
|
12894
|
-
ETelemetryToolFailureStage2["AFTER_HOOK"] = "after_hook";
|
|
12895
|
-
})(ETelemetryToolFailureStage || (ETelemetryToolFailureStage = {}));
|
|
12896
|
-
(function(ETelemetryTerminalEvidence2) {
|
|
12897
|
-
ETelemetryTerminalEvidence2["EXPLICIT_DONE_HISTORY_COMMITTED"] = "explicit_done_history_committed";
|
|
12898
|
-
ETelemetryTerminalEvidence2["EXPLICIT_DONE"] = "explicit_done";
|
|
12899
|
-
ETelemetryTerminalEvidence2["STREAM_ERROR"] = "stream_error";
|
|
12900
|
-
ETelemetryTerminalEvidence2["CONSUMER_CANCEL"] = "consumer_cancel";
|
|
12901
|
-
ETelemetryTerminalEvidence2["NATURAL_EXHAUSTION"] = "natural_exhaustion";
|
|
12902
|
-
})(ETelemetryTerminalEvidence || (ETelemetryTerminalEvidence = {}));
|
|
12903
|
-
(function(ETelemetryTerminalSource2) {
|
|
12904
|
-
ETelemetryTerminalSource2["NATIVE_AGENT_END"] = "native_agent_end";
|
|
12905
|
-
ETelemetryTerminalSource2["PROMPT_RESOLVED_FALLBACK"] = "prompt_resolved_fallback";
|
|
12906
|
-
})(ETelemetryTerminalSource || (ETelemetryTerminalSource = {}));
|
|
12907
|
-
(function(ETelemetryModelPurpose2) {
|
|
12908
|
-
ETelemetryModelPurpose2["AGENT_LOOP"] = "agent_loop";
|
|
12909
|
-
})(ETelemetryModelPurpose || (ETelemetryModelPurpose = {}));
|
|
12910
|
-
(function(ETelemetryErrorType2) {
|
|
12911
|
-
ETelemetryErrorType2["PROVIDER_STREAM_ERROR"] = "ProviderStreamError";
|
|
12912
|
-
ETelemetryErrorType2["TOOL_EXECUTION_ERROR"] = "ToolExecutionError";
|
|
12913
|
-
ETelemetryErrorType2["HOOK_DISPATCH_ERROR"] = "HookDispatchError";
|
|
12914
|
-
ETelemetryErrorType2["HOOK_DRAIN_ERROR"] = "HookDrainError";
|
|
12915
|
-
})(ETelemetryErrorType || (ETelemetryErrorType = {}));
|
|
12916
|
-
(function(ETelemetrySpanKind2) {
|
|
12917
|
-
ETelemetrySpanKind2["INTERNAL"] = "internal";
|
|
12918
|
-
ETelemetrySpanKind2["CLIENT"] = "client";
|
|
12919
|
-
})(ETelemetrySpanKind || (ETelemetrySpanKind = {}));
|
|
12920
|
-
(function(ETelemetryGenAiOperation2) {
|
|
12921
|
-
ETelemetryGenAiOperation2["CHAT"] = "chat";
|
|
12922
|
-
ETelemetryGenAiOperation2["EXECUTE_TOOL"] = "execute_tool";
|
|
12923
|
-
ETelemetryGenAiOperation2["INVOKE_AGENT"] = "invoke_agent";
|
|
12924
|
-
})(ETelemetryGenAiOperation || (ETelemetryGenAiOperation = {}));
|
|
12925
|
-
(function(ETelemetryVersion2) {
|
|
12926
|
-
ETelemetryVersion2["V0_2"] = "0.2";
|
|
12927
|
-
ETelemetryVersion2["V1_0"] = "1.0";
|
|
12928
|
-
})(ETelemetryVersion || (ETelemetryVersion = {}));
|
|
12929
|
-
}
|
|
12930
|
-
});
|
|
12931
|
-
|
|
12932
|
-
// ../linkque-agent-protocol/dist/esm/telemetry.js
|
|
12933
|
-
var init_telemetry = __esm({
|
|
12934
|
-
"../linkque-agent-protocol/dist/esm/telemetry.js"() {
|
|
12935
|
-
"use strict";
|
|
12936
|
-
init_telemetryEnums();
|
|
12937
|
-
}
|
|
12938
|
-
});
|
|
12939
|
-
|
|
12940
13031
|
// ../linkque-agent-runtime/dist/esm/core/logFailure.js
|
|
12941
13032
|
function warnLogFailure(stage, error40) {
|
|
12942
13033
|
(0, import_node_process.emitWarning)(`[${stage}] errorType=${error40 instanceof Error ? error40.name : typeof error40}`, { code: "LINKQUE_RUNTIME_DIAGNOSTIC_FAILURE" });
|
|
@@ -14252,18 +14343,45 @@ function createActivateSkillTool(records) {
|
|
|
14252
14343
|
required: ["name"],
|
|
14253
14344
|
additionalProperties: false
|
|
14254
14345
|
},
|
|
14255
|
-
execute: async (args) => {
|
|
14346
|
+
execute: async (args, _signal, context2) => {
|
|
14256
14347
|
const name = extractName(args);
|
|
14257
|
-
|
|
14348
|
+
const startedAt = Date.now();
|
|
14349
|
+
const obs = context2?.observation;
|
|
14350
|
+
recordContentSection(obs, ETelemetryContentSection.SKILL_INPUT, {
|
|
14351
|
+
name: name ?? null
|
|
14352
|
+
});
|
|
14353
|
+
if (!name) {
|
|
14354
|
+
recordContentSection(obs, ETelemetryContentSection.SKILL_OUTPUT, {
|
|
14355
|
+
status: "failed",
|
|
14356
|
+
error: "\u7F3A\u5C11 name \u53C2\u6570",
|
|
14357
|
+
durationMs: Date.now() - startedAt
|
|
14358
|
+
});
|
|
14258
14359
|
return "\u6FC0\u6D3B\u6280\u80FD\u5931\u8D25:\u7F3A\u5C11 name \u53C2\u6570\u3002";
|
|
14360
|
+
}
|
|
14259
14361
|
if (!bodyByName.has(name)) {
|
|
14362
|
+
recordContentSection(obs, ETelemetryContentSection.SKILL_OUTPUT, {
|
|
14363
|
+
name,
|
|
14364
|
+
status: "failed",
|
|
14365
|
+
error: `\u672A\u627E\u5230\u6280\u80FD "${name}"`,
|
|
14366
|
+
durationMs: Date.now() - startedAt
|
|
14367
|
+
});
|
|
14260
14368
|
return `\u6FC0\u6D3B\u6280\u80FD\u5931\u8D25:\u672A\u627E\u5230\u6280\u80FD "${name}"\u3002\u53EF\u7528:${[...bodyByName.keys()].join(", ")}`;
|
|
14261
14369
|
}
|
|
14262
14370
|
if (activated.has(name)) {
|
|
14371
|
+
recordContentSection(obs, ETelemetryContentSection.SKILL_OUTPUT, {
|
|
14372
|
+
name,
|
|
14373
|
+
status: "already_loaded",
|
|
14374
|
+
durationMs: Date.now() - startedAt
|
|
14375
|
+
});
|
|
14263
14376
|
return `\u6280\u80FD "${name}" \u5DF2\u5728\u672C\u8F6E\u52A0\u8F7D,\u65E0\u9700\u91CD\u590D\u6FC0\u6D3B\u3002`;
|
|
14264
14377
|
}
|
|
14265
14378
|
activated.add(name);
|
|
14266
14379
|
const body = bodyByName.get(name) ?? "";
|
|
14380
|
+
recordContentSection(obs, ETelemetryContentSection.SKILL_OUTPUT, {
|
|
14381
|
+
name,
|
|
14382
|
+
status: "loaded",
|
|
14383
|
+
durationMs: Date.now() - startedAt
|
|
14384
|
+
});
|
|
14267
14385
|
return `<skill name="${escapeXml(name)}">
|
|
14268
14386
|
${body}
|
|
14269
14387
|
</skill>`;
|
|
@@ -14321,6 +14439,8 @@ var ACTIVATE_SKILL_TOOL_NAME, AVAILABLE_SKILLS_OPEN, AVAILABLE_SKILLS_CLOSE;
|
|
|
14321
14439
|
var init_skillTools = __esm({
|
|
14322
14440
|
"../linkque-agent-runtime/dist/esm/core/skillTools.js"() {
|
|
14323
14441
|
"use strict";
|
|
14442
|
+
init_telemetry();
|
|
14443
|
+
init_contentRecording();
|
|
14324
14444
|
ACTIVATE_SKILL_TOOL_NAME = "activate_skill";
|
|
14325
14445
|
AVAILABLE_SKILLS_OPEN = "<available_skills>";
|
|
14326
14446
|
AVAILABLE_SKILLS_CLOSE = "</available_skills>";
|
|
@@ -14548,7 +14668,7 @@ function createKnowledgeTools(resources, searchPort, agentId) {
|
|
|
14548
14668
|
additionalProperties: false
|
|
14549
14669
|
},
|
|
14550
14670
|
annotations: { readOnlyHint: true },
|
|
14551
|
-
execute: () => listKnowledge()
|
|
14671
|
+
execute: (_args, _signal, context2) => listKnowledge(context2)
|
|
14552
14672
|
},
|
|
14553
14673
|
{
|
|
14554
14674
|
name: KNOWLEDGE_RECALL_TOOL_NAME,
|
|
@@ -14575,24 +14695,48 @@ function createKnowledgeTools(resources, searchPort, agentId) {
|
|
|
14575
14695
|
additionalProperties: false
|
|
14576
14696
|
},
|
|
14577
14697
|
annotations: { readOnlyHint: true },
|
|
14578
|
-
execute: (args, signal) => recallKnowledge(args, signal)
|
|
14698
|
+
execute: (args, signal, context2) => recallKnowledge(args, signal, context2)
|
|
14579
14699
|
}
|
|
14580
14700
|
];
|
|
14581
|
-
async function listKnowledge() {
|
|
14582
|
-
|
|
14701
|
+
async function listKnowledge(context2) {
|
|
14702
|
+
const result = { knowledgeBases: await getKnowledgeBases() };
|
|
14703
|
+
recordContentSection(context2?.observation, ETelemetryContentSection.KNOWLEDGE_OUTPUT, {
|
|
14704
|
+
knowledgeBases: result.knowledgeBases.map((kb) => ({
|
|
14705
|
+
knowledgeBaseId: kb.knowledgeBaseId,
|
|
14706
|
+
knowledgeDesc: kb.knowledgeDesc
|
|
14707
|
+
}))
|
|
14708
|
+
});
|
|
14709
|
+
return result;
|
|
14583
14710
|
}
|
|
14584
|
-
async function recallKnowledge(args, signal) {
|
|
14711
|
+
async function recallKnowledge(args, signal, context2) {
|
|
14585
14712
|
const parsed = parseRecallArgs(args);
|
|
14713
|
+
const obs = context2?.observation;
|
|
14586
14714
|
if ("error" in parsed) {
|
|
14715
|
+
recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_INPUT, {
|
|
14716
|
+
error: parsed.error
|
|
14717
|
+
});
|
|
14718
|
+
recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_OUTPUT, {
|
|
14719
|
+
status: "failed",
|
|
14720
|
+
hits: [],
|
|
14721
|
+
error: parsed.error
|
|
14722
|
+
});
|
|
14587
14723
|
return { hits: [], error: parsed.error };
|
|
14588
14724
|
}
|
|
14725
|
+
recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_INPUT, {
|
|
14726
|
+
knowledgeBaseId: parsed.knowledgeBaseId,
|
|
14727
|
+
query: parsed.query,
|
|
14728
|
+
topK: parsed.topK
|
|
14729
|
+
});
|
|
14589
14730
|
const knowledgeBases = await getKnowledgeBases();
|
|
14590
14731
|
const bound = knowledgeBases.some((info) => info.knowledgeBaseId === parsed.knowledgeBaseId);
|
|
14591
14732
|
if (!bound) {
|
|
14592
|
-
|
|
14733
|
+
const error40 = `knowledgeBaseId \u672A\u7ED1\u5B9A: ${parsed.knowledgeBaseId}\u3002\u8BF7\u5148\u8C03\u7528 knowledge_list \u67E5\u770B\u53EF\u7528\u77E5\u8BC6\u5E93\u3002`;
|
|
14734
|
+
recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_OUTPUT, {
|
|
14735
|
+
status: "failed",
|
|
14593
14736
|
hits: [],
|
|
14594
|
-
error:
|
|
14595
|
-
};
|
|
14737
|
+
error: error40
|
|
14738
|
+
});
|
|
14739
|
+
return { hits: [], error: error40 };
|
|
14596
14740
|
}
|
|
14597
14741
|
try {
|
|
14598
14742
|
const result = await searchPort.search({
|
|
@@ -14601,10 +14745,20 @@ function createKnowledgeTools(resources, searchPort, agentId) {
|
|
|
14601
14745
|
agentId,
|
|
14602
14746
|
topK: parsed.topK
|
|
14603
14747
|
}, signal);
|
|
14748
|
+
recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_OUTPUT, {
|
|
14749
|
+
status: result.hits.length ? "matched" : "no_hits",
|
|
14750
|
+
hits: result.hits
|
|
14751
|
+
});
|
|
14604
14752
|
return { hits: result.hits };
|
|
14605
14753
|
} catch (e2) {
|
|
14606
14754
|
const msg = e2 instanceof Error ? e2.message : String(e2);
|
|
14607
|
-
|
|
14755
|
+
const error40 = `\u77E5\u8BC6\u5E93\u68C0\u7D22\u5931\u8D25: ${msg}`;
|
|
14756
|
+
recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_OUTPUT, {
|
|
14757
|
+
status: "failed",
|
|
14758
|
+
hits: [],
|
|
14759
|
+
error: error40
|
|
14760
|
+
});
|
|
14761
|
+
return { hits: [], error: error40 };
|
|
14608
14762
|
}
|
|
14609
14763
|
}
|
|
14610
14764
|
async function getKnowledgeBases() {
|
|
@@ -14618,6 +14772,8 @@ var init_createKnowledgeTools = __esm({
|
|
|
14618
14772
|
"../linkque-agent-runtime/dist/esm/core/createKnowledgeTools.js"() {
|
|
14619
14773
|
"use strict";
|
|
14620
14774
|
init_knowledgeTools();
|
|
14775
|
+
init_telemetry();
|
|
14776
|
+
init_contentRecording();
|
|
14621
14777
|
}
|
|
14622
14778
|
});
|
|
14623
14779
|
|
|
@@ -14648,7 +14804,7 @@ var init_noopRuntimeTelemetry = __esm({
|
|
|
14648
14804
|
startOperation(_operation) {
|
|
14649
14805
|
return this;
|
|
14650
14806
|
}
|
|
14651
|
-
record(_name, _attributes) {
|
|
14807
|
+
record(_name, _attributes, _body) {
|
|
14652
14808
|
}
|
|
14653
14809
|
finish(_outcome, _attributes) {
|
|
14654
14810
|
}
|
|
@@ -14746,7 +14902,7 @@ var init_runtimeObservation = __esm({
|
|
|
14746
14902
|
find(key) {
|
|
14747
14903
|
return this.associations.get(key);
|
|
14748
14904
|
}
|
|
14749
|
-
record(name, attributes) {
|
|
14905
|
+
record(name, attributes, body) {
|
|
14750
14906
|
if (this.abandoned)
|
|
14751
14907
|
return;
|
|
14752
14908
|
try {
|
|
@@ -14754,7 +14910,7 @@ var init_runtimeObservation = __esm({
|
|
|
14754
14910
|
this.resultAttributes = {
|
|
14755
14911
|
[ETelemetryAttribute.LINKQUE_TOOL_FAILURE_STAGE]: attributes[ETelemetryAttribute.LINKQUE_TOOL_FAILURE_STAGE]
|
|
14756
14912
|
};
|
|
14757
|
-
this.sink.record(name, attributes);
|
|
14913
|
+
this.sink.record(name, attributes, body);
|
|
14758
14914
|
} catch {
|
|
14759
14915
|
}
|
|
14760
14916
|
}
|
|
@@ -49054,9 +49210,9 @@ function toolResultOutcome(result) {
|
|
|
49054
49210
|
return ETelemetryOutcome.UNKNOWN;
|
|
49055
49211
|
}
|
|
49056
49212
|
const record4 = result;
|
|
49057
|
-
if (record4.isError === true
|
|
49213
|
+
if (record4.isError === true)
|
|
49058
49214
|
return ETelemetryOutcome.ERROR;
|
|
49059
|
-
if (record4.isError === false || record4.
|
|
49215
|
+
if (record4.isError === false || record4.type === "linkque.presentation-tool-result")
|
|
49060
49216
|
return ETelemetryOutcome.SUCCESS;
|
|
49061
49217
|
} catch {
|
|
49062
49218
|
}
|
|
@@ -49081,8 +49237,19 @@ function observeTool(tool, observation) {
|
|
|
49081
49237
|
detached: false,
|
|
49082
49238
|
links: []
|
|
49083
49239
|
});
|
|
49240
|
+
const captureBody = !isSkillTool(tool);
|
|
49084
49241
|
try {
|
|
49085
|
-
|
|
49242
|
+
if (captureBody) {
|
|
49243
|
+
recordContentSection(operation, ETelemetryContentSection.TOOL_INPUT, args);
|
|
49244
|
+
}
|
|
49245
|
+
const execContext = {
|
|
49246
|
+
...context2 ?? { toolCallId: "", emit: () => void 0 },
|
|
49247
|
+
observation: operation
|
|
49248
|
+
};
|
|
49249
|
+
const result = await tool.execute(args, signal, execContext);
|
|
49250
|
+
if (captureBody) {
|
|
49251
|
+
recordContentSection(operation, ETelemetryContentSection.TOOL_OUTPUT, result);
|
|
49252
|
+
}
|
|
49086
49253
|
operation.finish(toolResultOutcome(result), {
|
|
49087
49254
|
[ETelemetryAttribute.HARNESS_TOOL_RESULT_STATUS]: toolResultOutcome(result)
|
|
49088
49255
|
});
|
|
@@ -49100,13 +49267,16 @@ function observeTool(tool, observation) {
|
|
|
49100
49267
|
}
|
|
49101
49268
|
};
|
|
49102
49269
|
}
|
|
49103
|
-
var import_node_crypto6;
|
|
49270
|
+
var import_node_crypto6, isSkillTool;
|
|
49104
49271
|
var init_toolObservation = __esm({
|
|
49105
49272
|
"../linkque-agent-runtime/dist/esm/core/telemetry/toolObservation.js"() {
|
|
49106
49273
|
"use strict";
|
|
49107
49274
|
init_telemetry();
|
|
49108
49275
|
init_telemetryEnums2();
|
|
49276
|
+
init_skillTools();
|
|
49109
49277
|
import_node_crypto6 = require("node:crypto");
|
|
49278
|
+
init_contentRecording();
|
|
49279
|
+
isSkillTool = (tool) => (tool.modelName ?? tool.name) === ACTIVATE_SKILL_TOOL_NAME;
|
|
49110
49280
|
}
|
|
49111
49281
|
});
|
|
49112
49282
|
|
|
@@ -49211,6 +49381,44 @@ var init_piTelemetry = __esm({
|
|
|
49211
49381
|
PiTelemetry = class {
|
|
49212
49382
|
root;
|
|
49213
49383
|
iterationIndex = 0;
|
|
49384
|
+
replyText = "";
|
|
49385
|
+
replyBytes = 0;
|
|
49386
|
+
replyIndex = 0;
|
|
49387
|
+
replyTruncated = false;
|
|
49388
|
+
maxReplyBytes = 512 * 1024;
|
|
49389
|
+
/** 正文分块独立落盘;每条最坏 JSON 编码也低于日志单行 1 MiB 上限。 */
|
|
49390
|
+
recordReplyChunk(final, complete) {
|
|
49391
|
+
this.root.find(ETelemetryAssociation.MODEL)?.record(ETelemetryEventName.CONTENT_RECORDED, {}, {
|
|
49392
|
+
section: ETelemetryContentSection.MODEL_OUTPUT,
|
|
49393
|
+
value: this.replyText,
|
|
49394
|
+
chunkIndex: this.replyIndex++,
|
|
49395
|
+
final,
|
|
49396
|
+
availability: final && complete && !this.replyTruncated ? "available" : "partial"
|
|
49397
|
+
});
|
|
49398
|
+
this.replyText = "";
|
|
49399
|
+
}
|
|
49400
|
+
flushReply(complete) {
|
|
49401
|
+
if (this.replyBytes)
|
|
49402
|
+
this.recordReplyChunk(true, complete);
|
|
49403
|
+
this.replyBytes = 0;
|
|
49404
|
+
this.replyIndex = 0;
|
|
49405
|
+
this.replyTruncated = false;
|
|
49406
|
+
}
|
|
49407
|
+
appendReply(text2) {
|
|
49408
|
+
if (this.replyTruncated)
|
|
49409
|
+
return;
|
|
49410
|
+
for (const character of text2) {
|
|
49411
|
+
const bytes2 = Buffer.byteLength(character, "utf8");
|
|
49412
|
+
if (this.replyBytes + bytes2 > this.maxReplyBytes) {
|
|
49413
|
+
this.replyTruncated = true;
|
|
49414
|
+
break;
|
|
49415
|
+
}
|
|
49416
|
+
this.replyText += character;
|
|
49417
|
+
this.replyBytes += bytes2;
|
|
49418
|
+
if (this.replyText.length >= 16 * 1024)
|
|
49419
|
+
this.recordReplyChunk(false, false);
|
|
49420
|
+
}
|
|
49421
|
+
}
|
|
49214
49422
|
proposed = /* @__PURE__ */ new Map();
|
|
49215
49423
|
loop;
|
|
49216
49424
|
lastProvider = null;
|
|
@@ -49312,6 +49520,7 @@ var init_piTelemetry = __esm({
|
|
|
49312
49520
|
}
|
|
49313
49521
|
case "message_end":
|
|
49314
49522
|
if (event.message.role === "assistant") {
|
|
49523
|
+
this.flushReply(event.message.stopReason !== "error" && event.message.stopReason !== "aborted");
|
|
49315
49524
|
const failed = event.message.stopReason === "error" || event.message.stopReason === "aborted";
|
|
49316
49525
|
this.root.find(ETelemetryAssociation.MODEL)?.finish(event.message.stopReason === "aborted" ? ETelemetryOutcome.CANCELLED : failed ? ETelemetryOutcome.ERROR : ETelemetryOutcome.SUCCESS, {
|
|
49317
49526
|
[ETelemetryAttribute.GEN_AI_RESPONSE_FINISH_REASONS]: [
|
|
@@ -49326,6 +49535,8 @@ var init_piTelemetry = __esm({
|
|
|
49326
49535
|
break;
|
|
49327
49536
|
case "message_update": {
|
|
49328
49537
|
const update = event.assistantMessageEvent;
|
|
49538
|
+
if (update.type === "text_delta")
|
|
49539
|
+
this.appendReply(update.delta);
|
|
49329
49540
|
if (update.type === "text_delta" && update.delta && !this.publicTextSeen) {
|
|
49330
49541
|
this.publicTextSeen = true;
|
|
49331
49542
|
this.loop.record(ETelemetryEventName.LOOP_FIRST_PUBLIC_TEXT, {
|
|
@@ -49356,6 +49567,7 @@ var init_piTelemetry = __esm({
|
|
|
49356
49567
|
this.terminal = ETelemetryStreamTermination.ERROR;
|
|
49357
49568
|
}
|
|
49358
49569
|
close(cancelled) {
|
|
49570
|
+
this.flushReply(false);
|
|
49359
49571
|
this.proposed.clear();
|
|
49360
49572
|
this.loop.finish(this.terminal === ETelemetryStreamTermination.ERROR ? ETelemetryOutcome.ERROR : cancelled || this.terminal === ETelemetryStreamTermination.CANCEL ? ETelemetryOutcome.CANCELLED : this.terminal === ETelemetryStreamTermination.COMPLETE ? ETelemetryOutcome.SUCCESS : ETelemetryOutcome.UNKNOWN, {
|
|
49361
49573
|
[ETelemetryAttribute.LINKQUE_STREAM_TERMINATION]: this.terminal === ETelemetryStreamTermination.ERROR ? ETelemetryStreamTermination.ERROR : cancelled ? ETelemetryStreamTermination.CANCEL : this.terminal
|
|
@@ -207422,11 +207634,38 @@ var init_agentRuntime = __esm({
|
|
|
207422
207634
|
}
|
|
207423
207635
|
}, (observation) => this.runObservedAdvance(request, auth2, options, observation), options.signal);
|
|
207424
207636
|
}
|
|
207637
|
+
/**
|
|
207638
|
+
* 记录本次用户输入(RFC §4.1):取进入 Runtime 的本次新消息中最后一条 user message
|
|
207639
|
+
* 的 content,作为 `linkque.content.recorded` 的 body 走 record 链路落入
|
|
207640
|
+
* OTLP logs(body 含 section/value/availability)。不以模型 messages 上下文为输入;
|
|
207641
|
+
* 无 user 文本(卡片交互等)时按可用性如实标记,不伪造自然语言 Query。
|
|
207642
|
+
*/
|
|
207643
|
+
recordCurrentQuery(observation, request) {
|
|
207644
|
+
let lastUser;
|
|
207645
|
+
for (const message of request.messages) {
|
|
207646
|
+
if (message.role === "user")
|
|
207647
|
+
lastUser = message;
|
|
207648
|
+
}
|
|
207649
|
+
const content = lastUser?.content;
|
|
207650
|
+
const text2 = typeof content === "string" && content ? content : void 0;
|
|
207651
|
+
const value = text2?.slice(0, CONTENT_VALUE_MAX_LENGTH);
|
|
207652
|
+
const truncated = text2 !== void 0 && text2.length > CONTENT_VALUE_MAX_LENGTH;
|
|
207653
|
+
const card = content && typeof content === "object" && "type" in content && content.type === "a2ui.event" ? content : void 0;
|
|
207654
|
+
const displayText = card && "displayText" in card && typeof card.displayText === "string" && card.displayText ? card.displayText : void 0;
|
|
207655
|
+
const body = {
|
|
207656
|
+
section: ETelemetryContentSection.QUERY_INPUT,
|
|
207657
|
+
...value !== void 0 ? { value } : {},
|
|
207658
|
+
...card ? { inputType: "card", ...displayText ? { displayText } : {} } : {},
|
|
207659
|
+
availability: text2 !== void 0 || card ? "available" : "not_recorded"
|
|
207660
|
+
};
|
|
207661
|
+
observation.record(ETelemetryEventName.CONTENT_RECORDED, { [ETelemetryAttribute.LINKQUE_CONTENT_VALUE_TRUNCATED]: truncated }, body);
|
|
207662
|
+
}
|
|
207425
207663
|
async *runObservedAdvance(request, auth2, options, observation) {
|
|
207426
207664
|
observation.record(ETelemetryEventName.TELEMETRY_COVERAGE, {
|
|
207427
207665
|
[ETelemetryAttribute.LINKQUE_TELEMETRY_COVERAGE]: this.agentLoop instanceof PiAgentLoop ? ETelemetryCoverage.PI_MODEL_TOOL_HOOK : ETelemetryCoverage.CORE_ONLY,
|
|
207428
207666
|
[ETelemetryAttribute.HARNESS_TELEMETRY_COMPLETENESS]: this.agentLoop instanceof PiAgentLoop ? ETelemetryCompleteness.COMPLETE : ETelemetryCompleteness.PARTIAL
|
|
207429
207667
|
});
|
|
207668
|
+
this.recordCurrentQuery(observation, request);
|
|
207430
207669
|
const cleanup = [];
|
|
207431
207670
|
let termination = ETelemetryStreamTermination.CANCEL;
|
|
207432
207671
|
let failed = false;
|
|
@@ -208531,6 +208770,22 @@ var EModelRequestSource;
|
|
|
208531
208770
|
|
|
208532
208771
|
// ../linkque-agent-runtime/dist/esm/core/index.js
|
|
208533
208772
|
init_types();
|
|
208773
|
+
|
|
208774
|
+
// ../linkque-agent-runtime/dist/esm/core/debugLog.js
|
|
208775
|
+
init_types();
|
|
208776
|
+
function isDebugLoggingEnabled(level) {
|
|
208777
|
+
return level?.trim().toLowerCase() === "debug";
|
|
208778
|
+
}
|
|
208779
|
+
function createRuntimeDebugLog(level, sink) {
|
|
208780
|
+
const debug = isDebugLoggingEnabled(level);
|
|
208781
|
+
return (line, scope) => {
|
|
208782
|
+
if (!debug && (scope === EDebugLogScope.PI_EVENT || scope === EDebugLogScope.HTTP || scope === EDebugLogScope.MCP || scope === EDebugLogScope.SKILL))
|
|
208783
|
+
return;
|
|
208784
|
+
sink(line, scope);
|
|
208785
|
+
};
|
|
208786
|
+
}
|
|
208787
|
+
|
|
208788
|
+
// ../linkque-agent-runtime/dist/esm/core/index.js
|
|
208534
208789
|
init_esm();
|
|
208535
208790
|
init_cardTools();
|
|
208536
208791
|
init_mcpNaming();
|
|
@@ -214525,6 +214780,10 @@ init_esm();
|
|
|
214525
214780
|
|
|
214526
214781
|
// ../linkque-agent-runtime/dist/esm/impl/mcp/alipay/remoteGatewayMcpServer.js
|
|
214527
214782
|
var import_node_async_hooks2 = require("node:async_hooks");
|
|
214783
|
+
init_telemetry();
|
|
214784
|
+
init_logFailure();
|
|
214785
|
+
init_contentRecording();
|
|
214786
|
+
init_types();
|
|
214528
214787
|
|
|
214529
214788
|
// ../linkque-agent-runtime/dist/esm/impl/mcp/alipay/linkquegwTokenVerifier.js
|
|
214530
214789
|
init_config();
|
|
@@ -214571,8 +214830,6 @@ var LinkquegwTokenVerifier = class {
|
|
|
214571
214830
|
};
|
|
214572
214831
|
|
|
214573
214832
|
// ../linkque-agent-runtime/dist/esm/impl/mcp/alipay/remoteGatewayMcpServer.js
|
|
214574
|
-
init_types();
|
|
214575
|
-
init_logFailure();
|
|
214576
214833
|
var defaultCreateSigner = (config2, getAuthorizationHeader, debugLog) => new RemoteSignatureSigner({
|
|
214577
214834
|
agentId: config2.agentId,
|
|
214578
214835
|
signEndpoint: config2.signEndpoint,
|
|
@@ -214623,7 +214880,14 @@ var RemoteGatewayMcpServerProvider = class {
|
|
|
214623
214880
|
if (!this.debugLog)
|
|
214624
214881
|
return;
|
|
214625
214882
|
try {
|
|
214626
|
-
this.debugLog(`[mcp-client] ${JSON.stringify({
|
|
214883
|
+
this.debugLog(`[mcp-client] ${JSON.stringify({
|
|
214884
|
+
serverName,
|
|
214885
|
+
resourceId: resource.resourceId,
|
|
214886
|
+
requestId,
|
|
214887
|
+
method,
|
|
214888
|
+
phase,
|
|
214889
|
+
payload: this.invocationContext.current()?.auth ? { redacted: true } : payload
|
|
214890
|
+
})}`, EDebugLogScope.MCP);
|
|
214627
214891
|
} catch (error40) {
|
|
214628
214892
|
warnLogFailure("remoteGatewayMcpServer.log", error40);
|
|
214629
214893
|
}
|
|
@@ -214643,6 +214907,8 @@ var RemoteGatewayMcpServerProvider = class {
|
|
|
214643
214907
|
callTool: (params, resultSchema, requestOptions) => request("tools/call", params, () => client.callTool(params, resultSchema, requestOptions))
|
|
214644
214908
|
};
|
|
214645
214909
|
const callTool = (name, args, signal, options) => callHeaders.run(options?.headers ?? {}, () => this.invocationContext.run(timeoutMs, signal, async (invocation) => {
|
|
214910
|
+
const observation = options?.context?.observation;
|
|
214911
|
+
recordMcpContentSection(observation, ETelemetryContentSection.MCP_REQUESTED_INPUT, args, options?.toolSchema?.inputSchema);
|
|
214646
214912
|
const plan = createArgsMappingPlan(name, args, argsMappingRules);
|
|
214647
214913
|
if (plan.requiresUserId) {
|
|
214648
214914
|
if (config2.signEndpoint !== void 0 && config2.signEndpoint !== DEFAULT_SIGN_ENDPOINT && !config2.verifyTokenEndpoint?.trim())
|
|
@@ -214665,19 +214931,22 @@ var RemoteGatewayMcpServerProvider = class {
|
|
|
214665
214931
|
};
|
|
214666
214932
|
}
|
|
214667
214933
|
const mapped = resolveArgsMappingPlan(plan, invocation.auth);
|
|
214934
|
+
recordMcpContentSection(observation, ETelemetryContentSection.MCP_INPUT, mapped, options?.toolSchema?.inputSchema);
|
|
214668
214935
|
invocation.signal.throwIfAborted();
|
|
214669
214936
|
const remaining = Math.max(1, invocation.deadline - performance.now());
|
|
214670
214937
|
try {
|
|
214671
|
-
|
|
214938
|
+
const result = await loggedClient.callTool({ name, arguments: mapped }, void 0, {
|
|
214672
214939
|
signal: invocation.signal,
|
|
214673
214940
|
timeout: remaining,
|
|
214674
214941
|
maxTotalTimeout: remaining,
|
|
214675
214942
|
resetTimeoutOnProgress: false
|
|
214676
214943
|
});
|
|
214944
|
+
recordMcpContentSection(observation, ETelemetryContentSection.MCP_OUTPUT, result, options?.toolSchema?.outputSchema);
|
|
214945
|
+
return result;
|
|
214677
214946
|
} catch (error40) {
|
|
214678
214947
|
invocation.signal.throwIfAborted();
|
|
214679
214948
|
if (invocation.auth && !(error40 instanceof McpInvocationError))
|
|
214680
|
-
throw new Error("MCP \u7528\u6237\u5DE5\u5177\u8C03\u7528\u5931\u8D25");
|
|
214949
|
+
throw new Error("MCP \u7528\u6237\u5DE5\u5177\u8C03\u7528\u5931\u8D25", { cause: error40 });
|
|
214681
214950
|
throw error40;
|
|
214682
214951
|
}
|
|
214683
214952
|
}));
|
|
@@ -214702,7 +214971,13 @@ async function listToolsFromClient(client, resourceId, callTool) {
|
|
|
214702
214971
|
const descriptor = {
|
|
214703
214972
|
name: tool.name,
|
|
214704
214973
|
resourceId,
|
|
214705
|
-
execute: (args, signal) => callTool(tool.name, args, signal
|
|
214974
|
+
execute: (args, signal, context2) => callTool(tool.name, args, signal, {
|
|
214975
|
+
context: context2,
|
|
214976
|
+
toolSchema: {
|
|
214977
|
+
inputSchema: tool.inputSchema,
|
|
214978
|
+
outputSchema: tool.outputSchema
|
|
214979
|
+
}
|
|
214980
|
+
})
|
|
214706
214981
|
};
|
|
214707
214982
|
if (tool.description !== void 0)
|
|
214708
214983
|
descriptor.description = tool.description;
|
|
@@ -215053,6 +215328,8 @@ function parseResponse(body, query, topK) {
|
|
|
215053
215328
|
}
|
|
215054
215329
|
|
|
215055
215330
|
// ../linkque-agent-runtime/dist/esm/impl/mcp/localHttpMcpServerProvider.js
|
|
215331
|
+
init_telemetry();
|
|
215332
|
+
init_contentRecording();
|
|
215056
215333
|
init_httpLoggingFetch();
|
|
215057
215334
|
var LocalHttpMcpServerProvider = class {
|
|
215058
215335
|
baseUrl;
|
|
@@ -215081,7 +215358,7 @@ var LocalHttpMcpServerProvider = class {
|
|
|
215081
215358
|
}
|
|
215082
215359
|
return body.tools.map((value) => this.createDescriptor(resource.resourceId, value));
|
|
215083
215360
|
},
|
|
215084
|
-
callTool: (name, args, signal) => this.callTool(resource.resourceId, name, args, signal)
|
|
215361
|
+
callTool: (name, args, signal, options) => this.callTool(resource.resourceId, name, args, signal, options)
|
|
215085
215362
|
};
|
|
215086
215363
|
}
|
|
215087
215364
|
createDescriptor(resourceId, value) {
|
|
@@ -215095,17 +215372,28 @@ var LocalHttpMcpServerProvider = class {
|
|
|
215095
215372
|
...isRecord2(value.inputSchema) ? { inputSchema: value.inputSchema } : {},
|
|
215096
215373
|
...isRecord2(value.outputSchema) ? { outputSchema: value.outputSchema } : {},
|
|
215097
215374
|
...isRecord2(value.annotations) ? { annotations: value.annotations } : {},
|
|
215098
|
-
execute: (args, signal) => this.callTool(resourceId, value.name, args, signal
|
|
215375
|
+
execute: (args, signal, context2) => this.callTool(resourceId, value.name, args, signal, {
|
|
215376
|
+
context: context2,
|
|
215377
|
+
toolSchema: {
|
|
215378
|
+
inputSchema: value.inputSchema,
|
|
215379
|
+
outputSchema: value.outputSchema
|
|
215380
|
+
}
|
|
215381
|
+
})
|
|
215099
215382
|
};
|
|
215100
215383
|
}
|
|
215101
|
-
async callTool(resourceId, toolName, args, signal) {
|
|
215384
|
+
async callTool(resourceId, toolName, args, signal, options) {
|
|
215385
|
+
const observation = options?.context?.observation;
|
|
215386
|
+
recordMcpContentSection(observation, ETelemetryContentSection.MCP_REQUESTED_INPUT, args, options?.toolSchema?.inputSchema);
|
|
215387
|
+
recordMcpContentSection(observation, ETelemetryContentSection.MCP_INPUT, args, options?.toolSchema?.inputSchema);
|
|
215102
215388
|
const response = await this.fetchImpl(this.resourceUrl(resourceId, `tools/${encodeURIComponent(toolName)}/call`), {
|
|
215103
215389
|
method: "POST",
|
|
215104
215390
|
headers: { "content-type": "application/json" },
|
|
215105
215391
|
body: JSON.stringify({ arguments: args }),
|
|
215106
215392
|
signal
|
|
215107
215393
|
});
|
|
215108
|
-
|
|
215394
|
+
const result = await readJsonResponse(response);
|
|
215395
|
+
recordMcpContentSection(observation, ETelemetryContentSection.MCP_OUTPUT, result, options?.toolSchema?.outputSchema);
|
|
215396
|
+
return result;
|
|
215109
215397
|
}
|
|
215110
215398
|
resourceUrl(resourceId, suffix) {
|
|
215111
215399
|
return new URL(`resources/${encodeURIComponent(resourceId)}/${suffix}`, ensureTrailingSlash(this.baseUrl));
|
|
@@ -215784,6 +216072,7 @@ function unzip(data, opts, cb) {
|
|
|
215784
216072
|
}
|
|
215785
216073
|
|
|
215786
216074
|
// ../linkque-agent-runtime/dist/esm/impl/webSkillLoader.js
|
|
216075
|
+
init_types();
|
|
215787
216076
|
init_skillTools();
|
|
215788
216077
|
init_httpLoggingFetch();
|
|
215789
216078
|
var ESkillUrlScheme;
|
|
@@ -215821,7 +216110,7 @@ var WebSkillLoader = class {
|
|
|
215821
216110
|
return records.filter((record4, idx) => {
|
|
215822
216111
|
if (record4 !== void 0)
|
|
215823
216112
|
return true;
|
|
215824
|
-
this.debugLog?.(`[skill] \u8DF3\u8FC7\u8D44\u6E90 ${resources[idx]?.resourceId ?? "?"}:SKILL.md \u7F3A description(\u524D\u7F6E\u65E0\u6548),\u6309 spec \u4E0D\u52A0\u8F7D
|
|
216113
|
+
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);
|
|
215825
216114
|
return false;
|
|
215826
216115
|
});
|
|
215827
216116
|
}
|
|
@@ -216324,6 +216613,7 @@ var allowedAttributeKeys = /* @__PURE__ */ new Set([
|
|
|
216324
216613
|
ETelemetryAttribute.GEN_AI_REQUEST_MODEL,
|
|
216325
216614
|
ETelemetryAttribute.GEN_AI_RESPONSE_MODEL,
|
|
216326
216615
|
ETelemetryAttribute.GEN_AI_RESPONSE_ID,
|
|
216616
|
+
ETelemetryAttribute.LINKQUE_CONTENT_VALUE_TRUNCATED,
|
|
216327
216617
|
ETelemetryAttribute.GEN_AI_RESPONSE_FINISH_REASONS,
|
|
216328
216618
|
ETelemetryAttribute.GEN_AI_USAGE_INPUT_TOKENS,
|
|
216329
216619
|
ETelemetryAttribute.GEN_AI_USAGE_OUTPUT_TOKENS,
|
|
@@ -216482,7 +216772,7 @@ var OtelRuntimeTelemetry = class {
|
|
|
216482
216772
|
{
|
|
216483
216773
|
onEmit: (record4, ctx) => {
|
|
216484
216774
|
const route = ctx?.getValue(this.routeKey);
|
|
216485
|
-
this.output(ETelemetrySignal.LOGS, import_otlp_transformer.JsonLogsSerializer.serializeRequest([record4]), route?.route, route?.critical ?? false);
|
|
216775
|
+
this.output(ETelemetrySignal.LOGS, import_otlp_transformer.JsonLogsSerializer.serializeRequest([record4]), route?.route, route?.critical ?? false, route?.localOnly ?? false);
|
|
216486
216776
|
},
|
|
216487
216777
|
forceFlush: async () => void 0,
|
|
216488
216778
|
shutdown: async () => void 0
|
|
@@ -216490,12 +216780,13 @@ var OtelRuntimeTelemetry = class {
|
|
|
216490
216780
|
]
|
|
216491
216781
|
});
|
|
216492
216782
|
}
|
|
216493
|
-
output(signal, encoded, route, critical) {
|
|
216783
|
+
output(signal, encoded, route, critical, localOnly = false) {
|
|
216494
216784
|
if (!encoded || this.outputActive || this.disposed)
|
|
216495
216785
|
return;
|
|
216496
216786
|
this.outputActive = true;
|
|
216497
216787
|
try {
|
|
216498
|
-
|
|
216788
|
+
if (!localOnly)
|
|
216789
|
+
this.queue.enqueue(route, signal, encoded, critical);
|
|
216499
216790
|
if (this.options.localSink) {
|
|
216500
216791
|
try {
|
|
216501
216792
|
const payload = JSON.parse(new TextDecoder().decode(encoded));
|
|
@@ -216520,7 +216811,6 @@ var OtelRuntimeTelemetry = class {
|
|
|
216520
216811
|
return new NoopRuntimeObservation();
|
|
216521
216812
|
}
|
|
216522
216813
|
const state2 = {
|
|
216523
|
-
agentId: input.agentId,
|
|
216524
216814
|
sequence: 0,
|
|
216525
216815
|
route: auth2 ? this.queue.authorize(auth2) : void 0,
|
|
216526
216816
|
attributes: sanitizeTelemetryAttributes({
|
|
@@ -216576,7 +216866,6 @@ var OtelRuntimeTelemetry = class {
|
|
|
216576
216866
|
isRemote: upstream !== null,
|
|
216577
216867
|
traceState: parentContext.traceState ? createTraceState(parentContext.traceState) : void 0
|
|
216578
216868
|
});
|
|
216579
|
-
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;
|
|
216580
216869
|
const attributes = sanitizeTelemetryAttributes({
|
|
216581
216870
|
...state2.attributes,
|
|
216582
216871
|
...parent?.attributes,
|
|
@@ -216594,11 +216883,11 @@ var OtelRuntimeTelemetry = class {
|
|
|
216594
216883
|
ETelemetryAttribute.LINKQUE_CONVERSATION_ID
|
|
216595
216884
|
].some((attribute) => attribute === key))),
|
|
216596
216885
|
[ETelemetryAttribute.LINKQUE_OPERATION_ID]: (0, import_node_crypto5.randomUUID)(),
|
|
216597
|
-
[ETelemetryAttribute.LINKQUE_OPERATION_NAME]:
|
|
216886
|
+
[ETelemetryAttribute.LINKQUE_OPERATION_NAME]: spec.name,
|
|
216598
216887
|
[ETelemetryAttribute.LINKQUE_OPERATION_PARENT_ID]: spec.detached ? "" : parent?.operationId ?? "",
|
|
216599
216888
|
[ETelemetryAttribute.LINKQUE_SPAN_PARENT_ID]: spec.detached ? "" : parentContext?.spanId ?? ""
|
|
216600
216889
|
});
|
|
216601
|
-
const span = this.tracerProvider.getTracer(ETelemetryMetadata.SCOPE_NAME, ETelemetryVersion.V1_0).startSpan(
|
|
216890
|
+
const span = this.tracerProvider.getTracer(ETelemetryMetadata.SCOPE_NAME, ETelemetryVersion.V1_0).startSpan(spec.name, {
|
|
216602
216891
|
kind: spec.name === ETelemetryOperationName.MODEL_ATTEMPT ? SpanKind.CLIENT : SpanKind.INTERNAL,
|
|
216603
216892
|
attributes,
|
|
216604
216893
|
links: spec.links.filter((link) => validContext(link.context)).slice(0, 16).map((link) => ({
|
|
@@ -216626,7 +216915,7 @@ var OtelRuntimeTelemetry = class {
|
|
|
216626
216915
|
operation.record(`${spec.eventPrefix}.${ETelemetryEventPhase.STARTED}`, {});
|
|
216627
216916
|
return operation;
|
|
216628
216917
|
}
|
|
216629
|
-
emit(operation, name, attributes, critical) {
|
|
216918
|
+
emit(operation, name, attributes, critical, body) {
|
|
216630
216919
|
if (this.disposed || this.queue.isExporting)
|
|
216631
216920
|
return;
|
|
216632
216921
|
const contextAttributes = operation.attributes;
|
|
@@ -216653,18 +216942,33 @@ var OtelRuntimeTelemetry = class {
|
|
|
216653
216942
|
Math.floor(now / 1e3),
|
|
216654
216943
|
now % 1e3 * 1e6
|
|
216655
216944
|
];
|
|
216656
|
-
|
|
216945
|
+
const localOnly = name === ETelemetryEventName.CONTENT_RECORDED;
|
|
216946
|
+
if (localOnly && body && typeof body === "object" && "value" in body) {
|
|
216947
|
+
const { value, ...metadata } = body;
|
|
216948
|
+
try {
|
|
216949
|
+
const valueJson = JSON.stringify(value);
|
|
216950
|
+
body = valueJson !== void 0 && Buffer.byteLength(JSON.stringify(valueJson), "utf8") <= 512 * 1024 ? { ...metadata, valueJson } : { ...metadata, availability: "unavailable", reason: "content_limit" };
|
|
216951
|
+
} catch {
|
|
216952
|
+
body = { ...metadata, availability: "unavailable" };
|
|
216953
|
+
}
|
|
216954
|
+
}
|
|
216955
|
+
if (!localOnly && operation.span.isRecording())
|
|
216657
216956
|
operation.span.addEvent(
|
|
216658
216957
|
name,
|
|
216659
216958
|
// 复用已投影的属性;Span 已持有上下文,事件只保留本次事实及去重字段。
|
|
216660
216959
|
Object.fromEntries(Object.entries(record4).filter(([key]) => Object.hasOwn(attributes, key) || key === ETelemetryAttribute.HARNESS_RECORD_ID || key === ETelemetryAttribute.HARNESS_EVENT_SEQUENCE)),
|
|
216661
216960
|
time3
|
|
216662
216961
|
);
|
|
216663
|
-
const ctx = trace.setSpan(ROOT_CONTEXT, operation.span).setValue(this.routeKey, {
|
|
216962
|
+
const ctx = trace.setSpan(ROOT_CONTEXT, operation.span).setValue(this.routeKey, {
|
|
216963
|
+
route: operation.state.route,
|
|
216964
|
+
critical,
|
|
216965
|
+
localOnly
|
|
216966
|
+
});
|
|
216664
216967
|
this.loggerProvider.getLogger(ETelemetryMetadata.SCOPE_NAME, ETelemetryVersion.V1_0).emit({
|
|
216665
216968
|
eventName: name,
|
|
216666
216969
|
timestamp: time3,
|
|
216667
216970
|
observedTimestamp: time3,
|
|
216971
|
+
...body !== void 0 ? { body } : {},
|
|
216668
216972
|
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,
|
|
216669
216973
|
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],
|
|
216670
216974
|
attributes: record4,
|
|
@@ -216735,10 +217039,11 @@ var OtelObservation = class {
|
|
|
216735
217039
|
return new NoopRuntimeObservation();
|
|
216736
217040
|
return this.owner.createOperation(this.state, spec, this);
|
|
216737
217041
|
}
|
|
216738
|
-
record(name, attributes) {
|
|
217042
|
+
record(name, attributes, body) {
|
|
216739
217043
|
if (this.lost || !/^(harness|linkque)\.[a-z0-9_.]{1,128}$/.test(name))
|
|
216740
217044
|
return;
|
|
216741
|
-
|
|
217045
|
+
const critical = name.endsWith(`.${ETelemetryEventPhase.FINISHED}`) || name === ETelemetryEventName.MODEL_USAGE_RECORDED || name === ETelemetryEventName.RUNTIME_UNCAUGHT_ERROR || name.endsWith(`.${ETelemetryEventPhase.OBSERVATION_LOST}`);
|
|
217046
|
+
this.owner.emit(this, name, attributes, critical, body);
|
|
216742
217047
|
}
|
|
216743
217048
|
finish(outcome, attributes) {
|
|
216744
217049
|
if (this.ended)
|
|
@@ -216978,6 +217283,7 @@ var OtlpFileSink = class {
|
|
|
216978
217283
|
// src/commands/agentdev/sandboxIntegrate/sandboxRuntimeConfigProvider.ts
|
|
216979
217284
|
var SANDBOX_RUNTIME_CONFIG_DEFAULTS = Object.freeze({
|
|
216980
217285
|
...RUNTIME_CONFIG_DEFAULTS,
|
|
217286
|
+
LOG_LEVEL: "DEBUG",
|
|
216981
217287
|
LINKQUE_MCP_SIGN_ENDPOINT: RUNTIME_CONFIG_DEFAULTS.LINKQUEGW_MCP_SIGN_ENDPOINT,
|
|
216982
217288
|
LINKQUE_OPEN_MCP_BASE_URL: "https://opengw.alipay.com",
|
|
216983
217289
|
LINKQUEGW_TELEMETRY_LOGS_ENDPOINT: `${LINKQUE_ENDPOINT_PROD}/api/telemetry/v1/logs`,
|
|
@@ -217435,6 +217741,7 @@ var fileSize = async (filePath) => {
|
|
|
217435
217741
|
};
|
|
217436
217742
|
var maskSecret = (raw) => raw ? "<set>" : "<unset>";
|
|
217437
217743
|
var AGENT_ENV_SNAPSHOT = [
|
|
217744
|
+
["LOG_LEVEL", false],
|
|
217438
217745
|
["LINKQUE_AGENT_API_KEY", true],
|
|
217439
217746
|
["LINKQUE_AGENT_ACCESS_KEY", true],
|
|
217440
217747
|
["LINKQUE_USER_TOKEN", true],
|
|
@@ -217671,11 +217978,15 @@ var main = async () => {
|
|
|
217671
217978
|
`[${(/* @__PURE__ */ new Date()).toISOString()}] agent worker loading agent runtime
|
|
217672
217979
|
`
|
|
217673
217980
|
);
|
|
217674
|
-
const
|
|
217675
|
-
|
|
217676
|
-
|
|
217981
|
+
const config2 = new SandboxRuntimeConfigProvider();
|
|
217982
|
+
const debugLog = createRuntimeDebugLog(
|
|
217983
|
+
config2.get("LOG_LEVEL"),
|
|
217984
|
+
(line, scope) => {
|
|
217985
|
+
const prefix = scope ? `[${scope}] ` : "";
|
|
217986
|
+
log.write(`[${(/* @__PURE__ */ new Date()).toISOString()}]${prefix}${line}
|
|
217677
217987
|
`);
|
|
217678
|
-
|
|
217988
|
+
}
|
|
217989
|
+
);
|
|
217679
217990
|
agentDevTelemetry = await createAgentDevTelemetry(
|
|
217680
217991
|
input.agentId,
|
|
217681
217992
|
input.logPath,
|
|
@@ -217689,7 +218000,6 @@ var main = async () => {
|
|
|
217689
218000
|
executeHomeData2 = executeHomeData;
|
|
217690
218001
|
executeCardAction2 = executeCardAction;
|
|
217691
218002
|
executeFunctionActionMcp2 = executeFunctionActionMcp;
|
|
217692
|
-
const config2 = new SandboxRuntimeConfigProvider();
|
|
217693
218003
|
const localMcpUrl = config2.get("LINKQUE_AGENT_MCP_FIXTURE_URL");
|
|
217694
218004
|
const gatewayAuthorization = resolveSandboxGatewayAuthorization(process.env);
|
|
217695
218005
|
const remoteAuthorizationHeader = gatewayAuthorization ? async () => gatewayAuthorization : void 0;
|
|
@@ -217764,9 +218074,9 @@ var main = async () => {
|
|
|
217764
218074
|
// opengw 响应头 alipay-trace-id 下沉到 agent.log(同 SSE 会话级复用,
|
|
217765
218075
|
// 每会话首个 POST 上报一次有效值),供 MCP 调用链路归因排查。
|
|
217766
218076
|
onTraceId: (info) => {
|
|
217767
|
-
|
|
217768
|
-
`[
|
|
217769
|
-
|
|
218077
|
+
debugLog(
|
|
218078
|
+
`[mcp-trace] ${info.httpMethod} ${info.requestUrl} alipay-trace-id=${info.traceId}`,
|
|
218079
|
+
EDebugLogScope.MCP
|
|
217770
218080
|
);
|
|
217771
218081
|
},
|
|
217772
218082
|
// HTTP 出站日志下沉(scope=http):tag=mcp-sign(签名服务)+ mcp-call(SSE GET/POST 工具调用)→ agent.log。
|