linkque-cli-v2 1.3.8-beta.1 → 1.4.0
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 +343 -1093
- package/package.json +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-7MJID6LL.js → chunk-OHRCYI66.js} +165 -222
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-EFUO43CY.js → chunk-WM6JHW55.js} +225 -214
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-BU3S4JYG.js → chunk-XL6BPKTI.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js +110 -71
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/clientCapability.js +3 -3
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/protocol.js +3 -3
- package/vendor/linkque-agent-appwrite-integrate/package.json +1 -1
- package/worker.js +180 -185
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{anthropic-messages-EL2IU4YU.js → anthropic-messages-5DOLTIGP.js} +3 -3
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{azure-openai-responses-A4XURCOX.js → azure-openai-responses-HVAVRLTK.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{mistral-conversations-5RZTVEO2.js → mistral-conversations-OEBGEDLQ.js} +10 -10
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{openai-codex-responses-WLREQPZK.js → openai-codex-responses-3KOC6KHN.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{openai-completions-U6LUBY4P.js → openai-completions-HG6OJRL5.js} +3 -3
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{openai-responses-SFZAU5JA.js → openai-responses-F6V2PG3Y.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{pi-messages-QQA6ZGV2.js → pi-messages-DC4DVRAJ.js} +3 -3
package/worker.js
CHANGED
|
@@ -4361,14 +4361,13 @@ var require_fast_uri = __commonJS({
|
|
|
4361
4361
|
if (!malformedIPLiteral) {
|
|
4362
4362
|
malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP2);
|
|
4363
4363
|
}
|
|
4364
|
-
if (uri.indexOf("%") !== -1 && parsed.host !== void 0 && !malformedIPLiteral) {
|
|
4365
|
-
let host = isIP2 ? parsed.host : normalizePercentEncoding(parsed.host, true);
|
|
4366
|
-
if (!isIP2) {
|
|
4367
|
-
host = normalizePercentEncoding(host.toLowerCase());
|
|
4368
|
-
}
|
|
4369
|
-
parsed.host = reescapeHostDelimiters(host, isIP2);
|
|
4370
|
-
}
|
|
4371
4364
|
if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
|
|
4365
|
+
if (uri.indexOf("%") !== -1) {
|
|
4366
|
+
if (parsed.host !== void 0 && !malformedIPLiteral) {
|
|
4367
|
+
const host = isIP2 ? parsed.host : normalizePercentEncoding(parsed.host, true);
|
|
4368
|
+
parsed.host = reescapeHostDelimiters(host, isIP2);
|
|
4369
|
+
}
|
|
4370
|
+
}
|
|
4372
4371
|
if (parsed.path) {
|
|
4373
4372
|
parsed.path = normalizePathEncoding(parsed.path);
|
|
4374
4373
|
}
|
|
@@ -12628,7 +12627,7 @@ var init_hookRegistry = __esm({
|
|
|
12628
12627
|
});
|
|
12629
12628
|
|
|
12630
12629
|
// ../linkque-agent-protocol/dist/esm/telemetry/telemetryEnums.js
|
|
12631
|
-
var ETelemetryAttribute, ETelemetryEventPrefix, ETelemetryEventPhase, ETelemetryEventName,
|
|
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;
|
|
12632
12631
|
var init_telemetryEnums = __esm({
|
|
12633
12632
|
"../linkque-agent-protocol/dist/esm/telemetry/telemetryEnums.js"() {
|
|
12634
12633
|
"use strict";
|
|
@@ -12787,20 +12786,7 @@ var init_telemetryEnums = __esm({
|
|
|
12787
12786
|
ETelemetryEventName2["HISTORY_APPEND_FINISHED"] = "linkque.history.append.finished";
|
|
12788
12787
|
ETelemetryEventName2["HOOK_DRAIN_STARTED"] = "linkque.hook.drain.started";
|
|
12789
12788
|
ETelemetryEventName2["HOOK_DRAIN_FINISHED"] = "linkque.hook.drain.finished";
|
|
12790
|
-
ETelemetryEventName2["DEBUG_CONTENT_RECORDED"] = "linkque.debug.content.recorded";
|
|
12791
12789
|
})(ETelemetryEventName || (ETelemetryEventName = {}));
|
|
12792
|
-
(function(ETelemetryContentSection2) {
|
|
12793
|
-
ETelemetryContentSection2["QUERY_INPUT"] = "query.input";
|
|
12794
|
-
ETelemetryContentSection2["TOOL_INPUT"] = "tool.input";
|
|
12795
|
-
ETelemetryContentSection2["TOOL_OUTPUT"] = "tool.output";
|
|
12796
|
-
ETelemetryContentSection2["MCP_REQUESTED_INPUT"] = "mcp.requested_input";
|
|
12797
|
-
ETelemetryContentSection2["MCP_INPUT"] = "mcp.input";
|
|
12798
|
-
ETelemetryContentSection2["MCP_OUTPUT"] = "mcp.output";
|
|
12799
|
-
ETelemetryContentSection2["SKILL_INPUT"] = "skill.input";
|
|
12800
|
-
ETelemetryContentSection2["SKILL_OUTPUT"] = "skill.output";
|
|
12801
|
-
ETelemetryContentSection2["KNOWLEDGE_INPUT"] = "knowledge.input";
|
|
12802
|
-
ETelemetryContentSection2["KNOWLEDGE_OUTPUT"] = "knowledge.output";
|
|
12803
|
-
})(ETelemetryContentSection || (ETelemetryContentSection = {}));
|
|
12804
12790
|
(function(ETelemetryOperationName2) {
|
|
12805
12791
|
ETelemetryOperationName2["OPERATION"] = "linkque.operation";
|
|
12806
12792
|
ETelemetryOperationName2["TOOL_INVOKE"] = "harness.tool.invoke";
|
|
@@ -14198,17 +14184,6 @@ var init_linkquegwEventHookExecutor = __esm({
|
|
|
14198
14184
|
}
|
|
14199
14185
|
});
|
|
14200
14186
|
|
|
14201
|
-
// ../linkque-agent-runtime/dist/esm/core/telemetry/contentRecording.js
|
|
14202
|
-
function recordContentSection(observation, section, value, availability = "available") {
|
|
14203
|
-
observation?.record(ETelemetryEventName.DEBUG_CONTENT_RECORDED, {}, { section, value, availability });
|
|
14204
|
-
}
|
|
14205
|
-
var init_contentRecording = __esm({
|
|
14206
|
-
"../linkque-agent-runtime/dist/esm/core/telemetry/contentRecording.js"() {
|
|
14207
|
-
"use strict";
|
|
14208
|
-
init_telemetry();
|
|
14209
|
-
}
|
|
14210
|
-
});
|
|
14211
|
-
|
|
14212
14187
|
// ../linkque-agent-runtime/dist/esm/core/skillTools.js
|
|
14213
14188
|
function parseSkillFile(raw, fallbackName) {
|
|
14214
14189
|
const parsed = splitFrontmatter(raw);
|
|
@@ -14277,43 +14252,18 @@ function createActivateSkillTool(records) {
|
|
|
14277
14252
|
required: ["name"],
|
|
14278
14253
|
additionalProperties: false
|
|
14279
14254
|
},
|
|
14280
|
-
execute: async (args
|
|
14255
|
+
execute: async (args) => {
|
|
14281
14256
|
const name = extractName(args);
|
|
14282
|
-
|
|
14283
|
-
const obs = context2?.observation;
|
|
14284
|
-
recordContentSection(obs, ETelemetryContentSection.SKILL_INPUT, { name: name ?? null });
|
|
14285
|
-
if (!name) {
|
|
14286
|
-
recordContentSection(obs, ETelemetryContentSection.SKILL_OUTPUT, {
|
|
14287
|
-
status: "failed",
|
|
14288
|
-
error: "\u7F3A\u5C11 name \u53C2\u6570",
|
|
14289
|
-
durationMs: Date.now() - startedAt
|
|
14290
|
-
});
|
|
14257
|
+
if (!name)
|
|
14291
14258
|
return "\u6FC0\u6D3B\u6280\u80FD\u5931\u8D25:\u7F3A\u5C11 name \u53C2\u6570\u3002";
|
|
14292
|
-
}
|
|
14293
14259
|
if (!bodyByName.has(name)) {
|
|
14294
|
-
recordContentSection(obs, ETelemetryContentSection.SKILL_OUTPUT, {
|
|
14295
|
-
name,
|
|
14296
|
-
status: "failed",
|
|
14297
|
-
error: `\u672A\u627E\u5230\u6280\u80FD "${name}"`,
|
|
14298
|
-
durationMs: Date.now() - startedAt
|
|
14299
|
-
});
|
|
14300
14260
|
return `\u6FC0\u6D3B\u6280\u80FD\u5931\u8D25:\u672A\u627E\u5230\u6280\u80FD "${name}"\u3002\u53EF\u7528:${[...bodyByName.keys()].join(", ")}`;
|
|
14301
14261
|
}
|
|
14302
14262
|
if (activated.has(name)) {
|
|
14303
|
-
recordContentSection(obs, ETelemetryContentSection.SKILL_OUTPUT, {
|
|
14304
|
-
name,
|
|
14305
|
-
status: "already_loaded",
|
|
14306
|
-
durationMs: Date.now() - startedAt
|
|
14307
|
-
});
|
|
14308
14263
|
return `\u6280\u80FD "${name}" \u5DF2\u5728\u672C\u8F6E\u52A0\u8F7D,\u65E0\u9700\u91CD\u590D\u6FC0\u6D3B\u3002`;
|
|
14309
14264
|
}
|
|
14310
14265
|
activated.add(name);
|
|
14311
14266
|
const body = bodyByName.get(name) ?? "";
|
|
14312
|
-
recordContentSection(obs, ETelemetryContentSection.SKILL_OUTPUT, {
|
|
14313
|
-
name,
|
|
14314
|
-
status: "loaded",
|
|
14315
|
-
durationMs: Date.now() - startedAt
|
|
14316
|
-
});
|
|
14317
14267
|
return `<skill name="${escapeXml(name)}">
|
|
14318
14268
|
${body}
|
|
14319
14269
|
</skill>`;
|
|
@@ -14371,8 +14321,6 @@ var ACTIVATE_SKILL_TOOL_NAME, AVAILABLE_SKILLS_OPEN, AVAILABLE_SKILLS_CLOSE;
|
|
|
14371
14321
|
var init_skillTools = __esm({
|
|
14372
14322
|
"../linkque-agent-runtime/dist/esm/core/skillTools.js"() {
|
|
14373
14323
|
"use strict";
|
|
14374
|
-
init_telemetry();
|
|
14375
|
-
init_contentRecording();
|
|
14376
14324
|
ACTIVATE_SKILL_TOOL_NAME = "activate_skill";
|
|
14377
14325
|
AVAILABLE_SKILLS_OPEN = "<available_skills>";
|
|
14378
14326
|
AVAILABLE_SKILLS_CLOSE = "</available_skills>";
|
|
@@ -14600,7 +14548,7 @@ function createKnowledgeTools(resources, searchPort, agentId) {
|
|
|
14600
14548
|
additionalProperties: false
|
|
14601
14549
|
},
|
|
14602
14550
|
annotations: { readOnlyHint: true },
|
|
14603
|
-
execute: (
|
|
14551
|
+
execute: () => listKnowledge()
|
|
14604
14552
|
},
|
|
14605
14553
|
{
|
|
14606
14554
|
name: KNOWLEDGE_RECALL_TOOL_NAME,
|
|
@@ -14627,46 +14575,24 @@ function createKnowledgeTools(resources, searchPort, agentId) {
|
|
|
14627
14575
|
additionalProperties: false
|
|
14628
14576
|
},
|
|
14629
14577
|
annotations: { readOnlyHint: true },
|
|
14630
|
-
execute: (args, signal
|
|
14578
|
+
execute: (args, signal) => recallKnowledge(args, signal)
|
|
14631
14579
|
}
|
|
14632
14580
|
];
|
|
14633
|
-
async function listKnowledge(
|
|
14634
|
-
|
|
14635
|
-
recordContentSection(context2?.observation, ETelemetryContentSection.KNOWLEDGE_OUTPUT, {
|
|
14636
|
-
knowledgeBases: result.knowledgeBases.map((kb) => ({
|
|
14637
|
-
knowledgeBaseId: kb.knowledgeBaseId,
|
|
14638
|
-
knowledgeDesc: kb.knowledgeDesc
|
|
14639
|
-
}))
|
|
14640
|
-
});
|
|
14641
|
-
return result;
|
|
14581
|
+
async function listKnowledge() {
|
|
14582
|
+
return { knowledgeBases: await getKnowledgeBases() };
|
|
14642
14583
|
}
|
|
14643
|
-
async function recallKnowledge(args, signal
|
|
14584
|
+
async function recallKnowledge(args, signal) {
|
|
14644
14585
|
const parsed = parseRecallArgs(args);
|
|
14645
|
-
const obs = context2?.observation;
|
|
14646
14586
|
if ("error" in parsed) {
|
|
14647
|
-
recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_INPUT, {
|
|
14648
|
-
error: parsed.error
|
|
14649
|
-
});
|
|
14650
|
-
recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_OUTPUT, {
|
|
14651
|
-
hits: [],
|
|
14652
|
-
error: parsed.error
|
|
14653
|
-
});
|
|
14654
14587
|
return { hits: [], error: parsed.error };
|
|
14655
14588
|
}
|
|
14656
|
-
recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_INPUT, {
|
|
14657
|
-
knowledgeBaseId: parsed.knowledgeBaseId,
|
|
14658
|
-
query: parsed.query,
|
|
14659
|
-
topK: parsed.topK
|
|
14660
|
-
});
|
|
14661
14589
|
const knowledgeBases = await getKnowledgeBases();
|
|
14662
14590
|
const bound = knowledgeBases.some((info) => info.knowledgeBaseId === parsed.knowledgeBaseId);
|
|
14663
14591
|
if (!bound) {
|
|
14664
|
-
|
|
14665
|
-
recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_OUTPUT, {
|
|
14592
|
+
return {
|
|
14666
14593
|
hits: [],
|
|
14667
|
-
error:
|
|
14668
|
-
}
|
|
14669
|
-
return { hits: [], error: error40 };
|
|
14594
|
+
error: `knowledgeBaseId \u672A\u7ED1\u5B9A: ${parsed.knowledgeBaseId}\u3002\u8BF7\u5148\u8C03\u7528 knowledge_list \u67E5\u770B\u53EF\u7528\u77E5\u8BC6\u5E93\u3002`
|
|
14595
|
+
};
|
|
14670
14596
|
}
|
|
14671
14597
|
try {
|
|
14672
14598
|
const result = await searchPort.search({
|
|
@@ -14675,18 +14601,10 @@ function createKnowledgeTools(resources, searchPort, agentId) {
|
|
|
14675
14601
|
agentId,
|
|
14676
14602
|
topK: parsed.topK
|
|
14677
14603
|
}, signal);
|
|
14678
|
-
recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_OUTPUT, {
|
|
14679
|
-
hits: result.hits
|
|
14680
|
-
});
|
|
14681
14604
|
return { hits: result.hits };
|
|
14682
14605
|
} catch (e2) {
|
|
14683
14606
|
const msg = e2 instanceof Error ? e2.message : String(e2);
|
|
14684
|
-
|
|
14685
|
-
recordContentSection(obs, ETelemetryContentSection.KNOWLEDGE_OUTPUT, {
|
|
14686
|
-
hits: [],
|
|
14687
|
-
error: error40
|
|
14688
|
-
});
|
|
14689
|
-
return { hits: [], error: error40 };
|
|
14607
|
+
return { hits: [], error: `\u77E5\u8BC6\u5E93\u68C0\u7D22\u5931\u8D25: ${msg}` };
|
|
14690
14608
|
}
|
|
14691
14609
|
}
|
|
14692
14610
|
async function getKnowledgeBases() {
|
|
@@ -14700,8 +14618,6 @@ var init_createKnowledgeTools = __esm({
|
|
|
14700
14618
|
"../linkque-agent-runtime/dist/esm/core/createKnowledgeTools.js"() {
|
|
14701
14619
|
"use strict";
|
|
14702
14620
|
init_knowledgeTools();
|
|
14703
|
-
init_telemetry();
|
|
14704
|
-
init_contentRecording();
|
|
14705
14621
|
}
|
|
14706
14622
|
});
|
|
14707
14623
|
|
|
@@ -14732,7 +14648,7 @@ var init_noopRuntimeTelemetry = __esm({
|
|
|
14732
14648
|
startOperation(_operation) {
|
|
14733
14649
|
return this;
|
|
14734
14650
|
}
|
|
14735
|
-
record(_name, _attributes
|
|
14651
|
+
record(_name, _attributes) {
|
|
14736
14652
|
}
|
|
14737
14653
|
finish(_outcome, _attributes) {
|
|
14738
14654
|
}
|
|
@@ -14830,7 +14746,7 @@ var init_runtimeObservation = __esm({
|
|
|
14830
14746
|
find(key) {
|
|
14831
14747
|
return this.associations.get(key);
|
|
14832
14748
|
}
|
|
14833
|
-
record(name, attributes
|
|
14749
|
+
record(name, attributes) {
|
|
14834
14750
|
if (this.abandoned)
|
|
14835
14751
|
return;
|
|
14836
14752
|
try {
|
|
@@ -14838,7 +14754,7 @@ var init_runtimeObservation = __esm({
|
|
|
14838
14754
|
this.resultAttributes = {
|
|
14839
14755
|
[ETelemetryAttribute.LINKQUE_TOOL_FAILURE_STAGE]: attributes[ETelemetryAttribute.LINKQUE_TOOL_FAILURE_STAGE]
|
|
14840
14756
|
};
|
|
14841
|
-
this.sink.record(name, attributes
|
|
14757
|
+
this.sink.record(name, attributes);
|
|
14842
14758
|
} catch {
|
|
14843
14759
|
}
|
|
14844
14760
|
}
|
|
@@ -33271,6 +33187,25 @@ var init_history = __esm({
|
|
|
33271
33187
|
});
|
|
33272
33188
|
|
|
33273
33189
|
// ../agent-conversation-contract/dist/esm/sse.js
|
|
33190
|
+
function parseConversationToolCallDisplayName(value) {
|
|
33191
|
+
if (typeof value !== "string" || /[\r\n\u2028\u2029]/u.test(value)) {
|
|
33192
|
+
return void 0;
|
|
33193
|
+
}
|
|
33194
|
+
const normalized = value.trim();
|
|
33195
|
+
if (!normalized || normalized.length > MAX_CONVERSATION_TOOL_CALL_DISPLAY_NAME_LENGTH) {
|
|
33196
|
+
return void 0;
|
|
33197
|
+
}
|
|
33198
|
+
return normalized;
|
|
33199
|
+
}
|
|
33200
|
+
function createConversationToolCallStartEvent(toolCallId, toolCallName, displayName) {
|
|
33201
|
+
const normalized = parseConversationToolCallDisplayName(displayName);
|
|
33202
|
+
return {
|
|
33203
|
+
type: EventType.TOOL_CALL_START,
|
|
33204
|
+
toolCallId,
|
|
33205
|
+
toolCallName,
|
|
33206
|
+
...normalized ? { displayName: normalized } : {}
|
|
33207
|
+
};
|
|
33208
|
+
}
|
|
33274
33209
|
function createConversationRunAck(runId, threadId, options = {}) {
|
|
33275
33210
|
return {
|
|
33276
33211
|
event: "ack",
|
|
@@ -33288,8 +33223,18 @@ function createConversationAGUIEvent(data, id) {
|
|
|
33288
33223
|
}
|
|
33289
33224
|
function parseConversationAGUIEvent(value) {
|
|
33290
33225
|
const parsed = EventSchemas.safeParse(value);
|
|
33291
|
-
if (parsed.success)
|
|
33292
|
-
|
|
33226
|
+
if (parsed.success) {
|
|
33227
|
+
if (parsed.data.type !== EventType.TOOL_CALL_START)
|
|
33228
|
+
return parsed.data;
|
|
33229
|
+
const event = parsed.data;
|
|
33230
|
+
const displayName = parseConversationToolCallDisplayName(event.displayName);
|
|
33231
|
+
const baseEvent = { ...event };
|
|
33232
|
+
delete baseEvent.displayName;
|
|
33233
|
+
return {
|
|
33234
|
+
...baseEvent,
|
|
33235
|
+
...displayName ? { displayName } : {}
|
|
33236
|
+
};
|
|
33237
|
+
}
|
|
33293
33238
|
throw new ConversationProtocolValidationError(parsed.error.issues.map((issue4) => `${issue4.path.length ? issue4.path.join(".") : "event"}: ${issue4.message}`));
|
|
33294
33239
|
}
|
|
33295
33240
|
function createConversationTransportError(data, id) {
|
|
@@ -33305,12 +33250,14 @@ function encodeConversationSseEvent(event) {
|
|
|
33305
33250
|
|
|
33306
33251
|
`;
|
|
33307
33252
|
}
|
|
33253
|
+
var MAX_CONVERSATION_TOOL_CALL_DISPLAY_NAME_LENGTH;
|
|
33308
33254
|
var init_sse = __esm({
|
|
33309
33255
|
"../agent-conversation-contract/dist/esm/sse.js"() {
|
|
33310
33256
|
"use strict";
|
|
33311
33257
|
init_dist();
|
|
33312
33258
|
init_run();
|
|
33313
33259
|
init_version();
|
|
33260
|
+
MAX_CONVERSATION_TOOL_CALL_DISPLAY_NAME_LENGTH = 20;
|
|
33314
33261
|
}
|
|
33315
33262
|
});
|
|
33316
33263
|
|
|
@@ -33355,11 +33302,7 @@ function mapAgentEventToBaseEvents(event, messageId, thinkingId) {
|
|
|
33355
33302
|
}
|
|
33356
33303
|
case "tool_start": {
|
|
33357
33304
|
const events = [
|
|
33358
|
-
|
|
33359
|
-
type: EventType.TOOL_CALL_START,
|
|
33360
|
-
toolCallId: event.toolCallId,
|
|
33361
|
-
toolCallName: event.toolName
|
|
33362
|
-
}
|
|
33305
|
+
createConversationToolCallStartEvent(event.toolCallId, event.toolName, event.displayName)
|
|
33363
33306
|
];
|
|
33364
33307
|
const argsDelta = safeStringifyArgs(event.args);
|
|
33365
33308
|
if (argsDelta !== "") {
|
|
@@ -49138,19 +49081,8 @@ function observeTool(tool, observation) {
|
|
|
49138
49081
|
detached: false,
|
|
49139
49082
|
links: []
|
|
49140
49083
|
});
|
|
49141
|
-
const captureBody = !isSkillTool(tool);
|
|
49142
49084
|
try {
|
|
49143
|
-
|
|
49144
|
-
recordContentSection(operation, ETelemetryContentSection.TOOL_INPUT, args);
|
|
49145
|
-
}
|
|
49146
|
-
const execContext = {
|
|
49147
|
-
...context2 ?? { toolCallId: "", emit: () => void 0 },
|
|
49148
|
-
observation: operation
|
|
49149
|
-
};
|
|
49150
|
-
const result = await tool.execute(args, signal, execContext);
|
|
49151
|
-
if (captureBody) {
|
|
49152
|
-
recordContentSection(operation, ETelemetryContentSection.TOOL_OUTPUT, result);
|
|
49153
|
-
}
|
|
49085
|
+
const result = await tool.execute(args, signal, context2);
|
|
49154
49086
|
operation.finish(toolResultOutcome(result), {
|
|
49155
49087
|
[ETelemetryAttribute.HARNESS_TOOL_RESULT_STATUS]: toolResultOutcome(result)
|
|
49156
49088
|
});
|
|
@@ -49168,16 +49100,13 @@ function observeTool(tool, observation) {
|
|
|
49168
49100
|
}
|
|
49169
49101
|
};
|
|
49170
49102
|
}
|
|
49171
|
-
var import_node_crypto6
|
|
49103
|
+
var import_node_crypto6;
|
|
49172
49104
|
var init_toolObservation = __esm({
|
|
49173
49105
|
"../linkque-agent-runtime/dist/esm/core/telemetry/toolObservation.js"() {
|
|
49174
49106
|
"use strict";
|
|
49175
49107
|
init_telemetry();
|
|
49176
49108
|
init_telemetryEnums2();
|
|
49177
|
-
init_skillTools();
|
|
49178
49109
|
import_node_crypto6 = require("node:crypto");
|
|
49179
|
-
init_contentRecording();
|
|
49180
|
-
isSkillTool = (tool) => (tool.modelName ?? tool.name) === ACTIVATE_SKILL_TOOL_NAME;
|
|
49181
49110
|
}
|
|
49182
49111
|
});
|
|
49183
49112
|
|
|
@@ -205262,13 +205191,16 @@ function toPiAgentTools(descriptors, emitToolEvent = () => void 0) {
|
|
|
205262
205191
|
if (names.has(name))
|
|
205263
205192
|
throw new Error(`Duplicate AgentTool name ${name}`);
|
|
205264
205193
|
names.add(name);
|
|
205194
|
+
const uiStatusParameters = decorateToolParametersWithUiStatus(descriptor.inputSchema);
|
|
205265
205195
|
return {
|
|
205266
205196
|
name,
|
|
205267
205197
|
label: descriptor.label ?? descriptor.name,
|
|
205268
205198
|
description: descriptor.description ?? descriptor.name,
|
|
205269
|
-
parameters:
|
|
205199
|
+
parameters: uiStatusParameters.parameters,
|
|
205200
|
+
...uiStatusParameters.enabled ? { prepareArguments: stripToolUiStatusArgument } : {},
|
|
205270
205201
|
execute: async (toolCallId, params, signal) => {
|
|
205271
|
-
const
|
|
205202
|
+
const args = uiStatusParameters.enabled ? stripToolUiStatusArgument(params) : params;
|
|
205203
|
+
const result = await descriptor.execute(args, signal, {
|
|
205272
205204
|
toolCallId,
|
|
205273
205205
|
emit: emitToolEvent
|
|
205274
205206
|
});
|
|
@@ -205286,6 +205218,45 @@ function toPiAgentTools(descriptors, emitToolEvent = () => void 0) {
|
|
|
205286
205218
|
};
|
|
205287
205219
|
});
|
|
205288
205220
|
}
|
|
205221
|
+
function getToolUiStatusEnabledNames(descriptors) {
|
|
205222
|
+
return new Set(descriptors.flatMap((descriptor) => decorateToolParametersWithUiStatus(descriptor.inputSchema).enabled ? [descriptor.modelName ?? descriptor.name] : []));
|
|
205223
|
+
}
|
|
205224
|
+
function decorateToolParametersWithUiStatus(value) {
|
|
205225
|
+
const parameters = normalizeParameters(value);
|
|
205226
|
+
if (!isRecord6(parameters) || parameters.type !== "object") {
|
|
205227
|
+
return { parameters, enabled: false };
|
|
205228
|
+
}
|
|
205229
|
+
if ([...UNSAFE_TOOL_SCHEMA_KEYS].some((key) => key in parameters)) {
|
|
205230
|
+
return { parameters, enabled: false };
|
|
205231
|
+
}
|
|
205232
|
+
const properties = parameters.properties;
|
|
205233
|
+
if (properties !== void 0 && !isRecord6(properties)) {
|
|
205234
|
+
return { parameters, enabled: false };
|
|
205235
|
+
}
|
|
205236
|
+
const required2 = parameters.required;
|
|
205237
|
+
if (properties && TOOL_UI_STATUS_ARGUMENT in properties || Array.isArray(required2) && required2.includes(TOOL_UI_STATUS_ARGUMENT)) {
|
|
205238
|
+
return { parameters, enabled: false };
|
|
205239
|
+
}
|
|
205240
|
+
return {
|
|
205241
|
+
parameters: {
|
|
205242
|
+
...parameters,
|
|
205243
|
+
properties: {
|
|
205244
|
+
...properties,
|
|
205245
|
+
[TOOL_UI_STATUS_ARGUMENT]: TOOL_UI_STATUS_SCHEMA
|
|
205246
|
+
}
|
|
205247
|
+
},
|
|
205248
|
+
enabled: true
|
|
205249
|
+
};
|
|
205250
|
+
}
|
|
205251
|
+
function stripToolUiStatusArgument(value) {
|
|
205252
|
+
if (!isRecord6(value) || !(TOOL_UI_STATUS_ARGUMENT in value))
|
|
205253
|
+
return value;
|
|
205254
|
+
const { [TOOL_UI_STATUS_ARGUMENT]: _status, ...args } = value;
|
|
205255
|
+
return args;
|
|
205256
|
+
}
|
|
205257
|
+
function isRecord6(value) {
|
|
205258
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
205259
|
+
}
|
|
205289
205260
|
function normalizeParameters(value) {
|
|
205290
205261
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
205291
205262
|
return value;
|
|
@@ -205319,6 +205290,7 @@ function safeStringifyPayload(payload) {
|
|
|
205319
205290
|
return "<unserializable>";
|
|
205320
205291
|
}
|
|
205321
205292
|
}
|
|
205293
|
+
var TOOL_UI_STATUS_ARGUMENT, TOOL_UI_STATUS_SCHEMA, UNSAFE_TOOL_SCHEMA_KEYS;
|
|
205322
205294
|
var init_createAgentSession = __esm({
|
|
205323
205295
|
"../linkque-agent-runtime/dist/esm/impl/agent/pi/createAgentSession.js"() {
|
|
205324
205296
|
"use strict";
|
|
@@ -205327,11 +205299,35 @@ var init_createAgentSession = __esm({
|
|
|
205327
205299
|
init_logFailure();
|
|
205328
205300
|
init_dist4();
|
|
205329
205301
|
init_dist3();
|
|
205302
|
+
init_esm5();
|
|
205330
205303
|
init_esm();
|
|
205331
205304
|
init_types();
|
|
205332
205305
|
init_cardTools();
|
|
205333
205306
|
init_httpLoggingFetch();
|
|
205334
205307
|
init_llmRequestThrottle();
|
|
205308
|
+
TOOL_UI_STATUS_ARGUMENT = "__ui_status";
|
|
205309
|
+
TOOL_UI_STATUS_SCHEMA = Object.freeze({
|
|
205310
|
+
type: "string",
|
|
205311
|
+
minLength: 1,
|
|
205312
|
+
maxLength: MAX_CONVERSATION_TOOL_CALL_DISPLAY_NAME_LENGTH,
|
|
205313
|
+
description: "\u754C\u9762\u8FDB\u884C\u4E2D\u72B6\u6001\u3002\u8BF7\u7528\u4E0D\u8D85\u8FC720\u4E2A\u5B57\u7684\u4E2D\u6587\u77ED\u53E5\u6982\u62EC\u672C\u6B21\u8C03\u7528\u76EE\u7684\uFF0C\u4F8B\u5982\u201C\u6B63\u5728\u641C\u7D22\u9644\u8FD1\u9152\u5E97\u201D\uFF1B\u63CF\u8FF0\u52A8\u4F5C\u4E0E\u5BF9\u8C61\uFF0C\u4E0D\u590D\u8FF0\u624B\u673A\u53F7\u3001\u8BA2\u5355\u53F7\u7B49\u5177\u4F53\u53C2\u6570\u503C\u3002"
|
|
205314
|
+
});
|
|
205315
|
+
UNSAFE_TOOL_SCHEMA_KEYS = /* @__PURE__ */ new Set([
|
|
205316
|
+
"$dynamicRef",
|
|
205317
|
+
"$ref",
|
|
205318
|
+
"$recursiveRef",
|
|
205319
|
+
"allOf",
|
|
205320
|
+
"anyOf",
|
|
205321
|
+
"dependentSchemas",
|
|
205322
|
+
"else",
|
|
205323
|
+
"if",
|
|
205324
|
+
"not",
|
|
205325
|
+
"oneOf",
|
|
205326
|
+
"patternProperties",
|
|
205327
|
+
"propertyNames",
|
|
205328
|
+
"then",
|
|
205329
|
+
"unevaluatedProperties"
|
|
205330
|
+
]);
|
|
205335
205331
|
}
|
|
205336
205332
|
});
|
|
205337
205333
|
|
|
@@ -205544,7 +205540,7 @@ function providerIdFor(provider) {
|
|
|
205544
205540
|
throw new Error(`\u672A\u5B9E\u73B0\u7684 model provider: ${provider}`);
|
|
205545
205541
|
}
|
|
205546
205542
|
}
|
|
205547
|
-
function translateEvent(event) {
|
|
205543
|
+
function translateEvent(event, uiStatusToolNames = /* @__PURE__ */ new Set()) {
|
|
205548
205544
|
switch (event.type) {
|
|
205549
205545
|
case "message_update": {
|
|
205550
205546
|
const inner = event.assistantMessageEvent;
|
|
@@ -205578,13 +205574,17 @@ function translateEvent(event) {
|
|
|
205578
205574
|
}
|
|
205579
205575
|
return void 0;
|
|
205580
205576
|
}
|
|
205581
|
-
case "tool_execution_start":
|
|
205577
|
+
case "tool_execution_start": {
|
|
205578
|
+
const uiStatusEnabled = uiStatusToolNames.has(event.toolName);
|
|
205579
|
+
const displayName = uiStatusEnabled ? parseConversationToolCallDisplayName(readToolUiStatus(event.args)) : void 0;
|
|
205582
205580
|
return {
|
|
205583
205581
|
type: "tool_start",
|
|
205584
205582
|
toolCallId: event.toolCallId,
|
|
205585
205583
|
toolName: event.toolName,
|
|
205586
|
-
|
|
205584
|
+
...displayName ? { displayName } : {},
|
|
205585
|
+
args: uiStatusEnabled ? stripToolUiStatusArgument(event.args) : event.args
|
|
205587
205586
|
};
|
|
205587
|
+
}
|
|
205588
205588
|
case "tool_execution_end":
|
|
205589
205589
|
return {
|
|
205590
205590
|
type: "tool_end",
|
|
@@ -205599,14 +205599,17 @@ function translateEvent(event) {
|
|
|
205599
205599
|
return void 0;
|
|
205600
205600
|
}
|
|
205601
205601
|
}
|
|
205602
|
-
function translateEvents(event) {
|
|
205603
|
-
const translated = translateEvent(event);
|
|
205602
|
+
function translateEvents(event, uiStatusToolNames = /* @__PURE__ */ new Set()) {
|
|
205603
|
+
const translated = translateEvent(event, uiStatusToolNames);
|
|
205604
205604
|
const events = translated ? [translated] : [];
|
|
205605
205605
|
if (event.type === "tool_execution_end" && !event.isError && event.result && typeof event.result === "object" && isAgentPresentationToolResult(event.result.details)) {
|
|
205606
205606
|
events.push(event.result.details.card);
|
|
205607
205607
|
}
|
|
205608
205608
|
return events;
|
|
205609
205609
|
}
|
|
205610
|
+
function readToolUiStatus(args) {
|
|
205611
|
+
return args && typeof args === "object" && !Array.isArray(args) ? args[TOOL_UI_STATUS_ARGUMENT] : void 0;
|
|
205612
|
+
}
|
|
205610
205613
|
function toErrorEvent(err3) {
|
|
205611
205614
|
const message = err3 instanceof Error ? err3.message : typeof err3 === "string" ? err3 : "unknown agent error";
|
|
205612
205615
|
const code = err3 !== null && typeof err3 === "object" && "code" in err3 && typeof err3.code === "string" ? err3.code : void 0;
|
|
@@ -205619,6 +205622,7 @@ var init_agentService = __esm({
|
|
|
205619
205622
|
init_piTelemetry();
|
|
205620
205623
|
init_compat2();
|
|
205621
205624
|
init_esm();
|
|
205625
|
+
init_esm5();
|
|
205622
205626
|
init_types();
|
|
205623
205627
|
init_createAgentSession();
|
|
205624
205628
|
init_testProvider();
|
|
@@ -205679,6 +205683,7 @@ var init_agentService = __esm({
|
|
|
205679
205683
|
sessionDisposed = false;
|
|
205680
205684
|
session;
|
|
205681
205685
|
unsubscribe;
|
|
205686
|
+
uiStatusToolNames;
|
|
205682
205687
|
constructor(prompt, auth2, options, images, createSession, linkqueBaseUrl) {
|
|
205683
205688
|
this.prompt = prompt;
|
|
205684
205689
|
this.auth = auth2;
|
|
@@ -205686,6 +205691,7 @@ var init_agentService = __esm({
|
|
|
205686
205691
|
this.images = images;
|
|
205687
205692
|
this.createSession = createSession;
|
|
205688
205693
|
this.linkqueBaseUrl = linkqueBaseUrl;
|
|
205694
|
+
this.uiStatusToolNames = getToolUiStatusEnabledNames(options.tools ?? []);
|
|
205689
205695
|
}
|
|
205690
205696
|
/** 产出事件直到 done/error;迭代异常(return()/throw())时走 finally 清理。 */
|
|
205691
205697
|
async *iterate() {
|
|
@@ -205819,7 +205825,7 @@ var init_agentService = __esm({
|
|
|
205819
205825
|
return;
|
|
205820
205826
|
this.telemetry?.onEvent(event);
|
|
205821
205827
|
this.logDebug(`[pi-event] ${this.safeStringify(event)}`);
|
|
205822
|
-
for (const translated of translateEvents(event)) {
|
|
205828
|
+
for (const translated of translateEvents(event, this.uiStatusToolNames)) {
|
|
205823
205829
|
if (translated.type === "error" || translated.type === "done") {
|
|
205824
205830
|
if (this.settled)
|
|
205825
205831
|
return;
|
|
@@ -207416,32 +207422,11 @@ var init_agentRuntime = __esm({
|
|
|
207416
207422
|
}
|
|
207417
207423
|
}, (observation) => this.runObservedAdvance(request, auth2, options, observation), options.signal);
|
|
207418
207424
|
}
|
|
207419
|
-
/**
|
|
207420
|
-
* 记录本次用户输入(RFC §4.1):取进入 Runtime 的本次新消息中最后一条 user message
|
|
207421
|
-
* 的 content,作为 `linkque.debug.content.recorded` 的 body 走 record 链路落入
|
|
207422
|
-
* OTLP logs(body 含 section/value/availability)。不以模型 messages 上下文为输入;
|
|
207423
|
-
* 无 user 文本(卡片交互等)时按可用性如实标记,不伪造自然语言 Query。
|
|
207424
|
-
*/
|
|
207425
|
-
recordCurrentQuery(observation, request) {
|
|
207426
|
-
let lastUser;
|
|
207427
|
-
for (const message of request.messages) {
|
|
207428
|
-
if (message.role === "user")
|
|
207429
|
-
lastUser = message;
|
|
207430
|
-
}
|
|
207431
|
-
const text2 = typeof lastUser?.content === "string" ? lastUser.content : "";
|
|
207432
|
-
const body = {
|
|
207433
|
-
section: ETelemetryContentSection.QUERY_INPUT,
|
|
207434
|
-
value: text2,
|
|
207435
|
-
availability: text2 ? "available" : "not_recorded"
|
|
207436
|
-
};
|
|
207437
|
-
observation.record(ETelemetryEventName.DEBUG_CONTENT_RECORDED, {}, body);
|
|
207438
|
-
}
|
|
207439
207425
|
async *runObservedAdvance(request, auth2, options, observation) {
|
|
207440
207426
|
observation.record(ETelemetryEventName.TELEMETRY_COVERAGE, {
|
|
207441
207427
|
[ETelemetryAttribute.LINKQUE_TELEMETRY_COVERAGE]: this.agentLoop instanceof PiAgentLoop ? ETelemetryCoverage.PI_MODEL_TOOL_HOOK : ETelemetryCoverage.CORE_ONLY,
|
|
207442
207428
|
[ETelemetryAttribute.HARNESS_TELEMETRY_COMPLETENESS]: this.agentLoop instanceof PiAgentLoop ? ETelemetryCompleteness.COMPLETE : ETelemetryCompleteness.PARTIAL
|
|
207443
207429
|
});
|
|
207444
|
-
this.recordCurrentQuery(observation, request);
|
|
207445
207430
|
const cleanup = [];
|
|
207446
207431
|
let termination = ETelemetryStreamTermination.CANCEL;
|
|
207447
207432
|
let failed = false;
|
|
@@ -214580,8 +214565,6 @@ var LinkquegwTokenVerifier = class {
|
|
|
214580
214565
|
};
|
|
214581
214566
|
|
|
214582
214567
|
// ../linkque-agent-runtime/dist/esm/impl/mcp/alipay/remoteGatewayMcpServer.js
|
|
214583
|
-
init_telemetry();
|
|
214584
|
-
init_contentRecording();
|
|
214585
214568
|
init_types();
|
|
214586
214569
|
init_logFailure();
|
|
214587
214570
|
var defaultCreateSigner = (config2, getAuthorizationHeader, debugLog) => new RemoteSignatureSigner({
|
|
@@ -214654,8 +214637,6 @@ var RemoteGatewayMcpServerProvider = class {
|
|
|
214654
214637
|
callTool: (params, resultSchema, requestOptions) => request("tools/call", params, () => client.callTool(params, resultSchema, requestOptions))
|
|
214655
214638
|
};
|
|
214656
214639
|
const callTool = (name, args, signal, options) => callHeaders.run(options?.headers ?? {}, () => this.invocationContext.run(timeoutMs, signal, async (invocation) => {
|
|
214657
|
-
const observation = options?.context?.observation;
|
|
214658
|
-
recordContentSection(observation, ETelemetryContentSection.MCP_REQUESTED_INPUT, args);
|
|
214659
214640
|
const plan = createArgsMappingPlan(name, args, argsMappingRules);
|
|
214660
214641
|
if (plan.requiresUserId) {
|
|
214661
214642
|
if (config2.signEndpoint !== void 0 && config2.signEndpoint !== DEFAULT_SIGN_ENDPOINT && !config2.verifyTokenEndpoint?.trim())
|
|
@@ -214678,18 +214659,15 @@ var RemoteGatewayMcpServerProvider = class {
|
|
|
214678
214659
|
};
|
|
214679
214660
|
}
|
|
214680
214661
|
const mapped = resolveArgsMappingPlan(plan, invocation.auth);
|
|
214681
|
-
recordContentSection(observation, ETelemetryContentSection.MCP_INPUT, mapped);
|
|
214682
214662
|
invocation.signal.throwIfAborted();
|
|
214683
214663
|
const remaining = Math.max(1, invocation.deadline - performance.now());
|
|
214684
214664
|
try {
|
|
214685
|
-
|
|
214665
|
+
return await loggedClient.callTool({ name, arguments: mapped }, void 0, {
|
|
214686
214666
|
signal: invocation.signal,
|
|
214687
214667
|
timeout: remaining,
|
|
214688
214668
|
maxTotalTimeout: remaining,
|
|
214689
214669
|
resetTimeoutOnProgress: false
|
|
214690
214670
|
});
|
|
214691
|
-
recordContentSection(observation, ETelemetryContentSection.MCP_OUTPUT, result);
|
|
214692
|
-
return result;
|
|
214693
214671
|
} catch (error40) {
|
|
214694
214672
|
invocation.signal.throwIfAborted();
|
|
214695
214673
|
if (invocation.auth && !(error40 instanceof McpInvocationError))
|
|
@@ -214718,7 +214696,7 @@ async function listToolsFromClient(client, resourceId, callTool) {
|
|
|
214718
214696
|
const descriptor = {
|
|
214719
214697
|
name: tool.name,
|
|
214720
214698
|
resourceId,
|
|
214721
|
-
execute: (args, signal
|
|
214699
|
+
execute: (args, signal) => callTool(tool.name, args, signal)
|
|
214722
214700
|
};
|
|
214723
214701
|
if (tool.description !== void 0)
|
|
214724
214702
|
descriptor.description = tool.description;
|
|
@@ -215097,7 +215075,7 @@ var LocalHttpMcpServerProvider = class {
|
|
|
215097
215075
|
}
|
|
215098
215076
|
return body.tools.map((value) => this.createDescriptor(resource.resourceId, value));
|
|
215099
215077
|
},
|
|
215100
|
-
callTool: (name, args, signal
|
|
215078
|
+
callTool: (name, args, signal) => this.callTool(resource.resourceId, name, args, signal)
|
|
215101
215079
|
};
|
|
215102
215080
|
}
|
|
215103
215081
|
createDescriptor(resourceId, value) {
|
|
@@ -216642,7 +216620,7 @@ var OtelRuntimeTelemetry = class {
|
|
|
216642
216620
|
operation.record(`${spec.eventPrefix}.${ETelemetryEventPhase.STARTED}`, {});
|
|
216643
216621
|
return operation;
|
|
216644
216622
|
}
|
|
216645
|
-
emit(operation, name, attributes, critical
|
|
216623
|
+
emit(operation, name, attributes, critical) {
|
|
216646
216624
|
if (this.disposed || this.queue.isExporting)
|
|
216647
216625
|
return;
|
|
216648
216626
|
const contextAttributes = operation.attributes;
|
|
@@ -216681,7 +216659,6 @@ var OtelRuntimeTelemetry = class {
|
|
|
216681
216659
|
eventName: name,
|
|
216682
216660
|
timestamp: time3,
|
|
216683
216661
|
observedTimestamp: time3,
|
|
216684
|
-
...body !== void 0 ? { body } : {},
|
|
216685
216662
|
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,
|
|
216686
216663
|
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],
|
|
216687
216664
|
attributes: record4,
|
|
@@ -216752,11 +216729,10 @@ var OtelObservation = class {
|
|
|
216752
216729
|
return new NoopRuntimeObservation();
|
|
216753
216730
|
return this.owner.createOperation(this.state, spec, this);
|
|
216754
216731
|
}
|
|
216755
|
-
record(name, attributes
|
|
216732
|
+
record(name, attributes) {
|
|
216756
216733
|
if (this.lost || !/^(harness|linkque)\.[a-z0-9_.]{1,128}$/.test(name))
|
|
216757
216734
|
return;
|
|
216758
|
-
|
|
216759
|
-
this.owner.emit(this, name, attributes, critical, body);
|
|
216735
|
+
this.owner.emit(this, name, attributes, name.endsWith(`.${ETelemetryEventPhase.FINISHED}`) || name === ETelemetryEventName.MODEL_USAGE_RECORDED || name === ETelemetryEventName.RUNTIME_UNCAUGHT_ERROR || name.endsWith(`.${ETelemetryEventPhase.OBSERVATION_LOST}`));
|
|
216760
216736
|
}
|
|
216761
216737
|
finish(outcome, attributes) {
|
|
216762
216738
|
if (this.ended)
|
|
@@ -217001,9 +216977,28 @@ var SANDBOX_RUNTIME_CONFIG_DEFAULTS = Object.freeze({
|
|
|
217001
216977
|
LINKQUEGW_TELEMETRY_LOGS_ENDPOINT: `${LINKQUE_ENDPOINT_PROD}/api/telemetry/v1/logs`,
|
|
217002
216978
|
LINKQUEGW_TELEMETRY_TRACES_ENDPOINT: `${LINKQUE_ENDPOINT_PROD}/api/telemetry/v1/traces`
|
|
217003
216979
|
});
|
|
216980
|
+
function resolveTokenVerifyDefault(env2) {
|
|
216981
|
+
const signEndpoint = env2.LINKQUE_MCP_SIGN_ENDPOINT?.trim() || SANDBOX_RUNTIME_CONFIG_DEFAULTS.LINKQUE_MCP_SIGN_ENDPOINT;
|
|
216982
|
+
switch (signEndpoint) {
|
|
216983
|
+
case "https://linkquegw.alipay.com/api/mcp/signature":
|
|
216984
|
+
return "https://linkquegw.alipay.com/api/auth/verify";
|
|
216985
|
+
case "https://linkquegw-pre.alipay.com/api/mcp/signature":
|
|
216986
|
+
return "https://linkquegw-pre.alipay.com/api/auth/verify";
|
|
216987
|
+
default:
|
|
216988
|
+
return "";
|
|
216989
|
+
}
|
|
216990
|
+
}
|
|
217004
216991
|
var SandboxRuntimeConfigProvider = class extends RuntimeConfigProvider {
|
|
217005
216992
|
constructor(env2 = process.env) {
|
|
217006
|
-
super(env2,
|
|
216993
|
+
super(env2, {
|
|
216994
|
+
...SANDBOX_RUNTIME_CONFIG_DEFAULTS,
|
|
216995
|
+
LINKQUEGW_TOKEN_VERIFY_ENDPOINT: resolveTokenVerifyDefault(env2)
|
|
216996
|
+
});
|
|
216997
|
+
}
|
|
216998
|
+
getSource(name) {
|
|
216999
|
+
if (name === "LINKQUEGW_TOKEN_VERIFY_ENDPOINT" && !this.get(name))
|
|
217000
|
+
return "unset";
|
|
217001
|
+
return super.getSource(name);
|
|
217007
217002
|
}
|
|
217008
217003
|
};
|
|
217009
217004
|
|
|
@@ -217624,10 +217619,10 @@ var handleFunctionActionMcp = async (req, res, input) => {
|
|
|
217624
217619
|
}
|
|
217625
217620
|
};
|
|
217626
217621
|
var parseHomeDataProxyInput = (value) => {
|
|
217627
|
-
const trustedContext =
|
|
217628
|
-
const trustedUserId =
|
|
217622
|
+
const trustedContext = isRecord7(value) ? value[HOME_DATA_TRUSTED_CONTEXT_FIELD] : void 0;
|
|
217623
|
+
const trustedUserId = isRecord7(trustedContext) ? trustedContext.userId : void 0;
|
|
217629
217624
|
const normalizedUserId = typeof trustedUserId === "string" ? trustedUserId.trim() : "";
|
|
217630
|
-
if (!
|
|
217625
|
+
if (!isRecord7(value) || !normalizedUserId) {
|
|
217631
217626
|
throw new Error("home-data trusted user is invalid");
|
|
217632
217627
|
}
|
|
217633
217628
|
const request = { ...value };
|
|
@@ -217635,19 +217630,19 @@ var parseHomeDataProxyInput = (value) => {
|
|
|
217635
217630
|
return { request, userId: normalizedUserId };
|
|
217636
217631
|
};
|
|
217637
217632
|
var parseA2UIActionProxyInput = (value) => {
|
|
217638
|
-
const trustedContext =
|
|
217639
|
-
const userId =
|
|
217640
|
-
if (!
|
|
217633
|
+
const trustedContext = isRecord7(value) ? value[HOME_DATA_TRUSTED_CONTEXT_FIELD] : void 0;
|
|
217634
|
+
const userId = isRecord7(trustedContext) && typeof trustedContext.userId === "string" ? trustedContext.userId.trim() : "";
|
|
217635
|
+
if (!isRecord7(value) || !userId)
|
|
217641
217636
|
throw new Error("a2ui action trusted user is invalid");
|
|
217642
217637
|
const request = { ...value };
|
|
217643
217638
|
delete request[HOME_DATA_TRUSTED_CONTEXT_FIELD];
|
|
217644
|
-
const tenantId =
|
|
217639
|
+
const tenantId = isRecord7(trustedContext) && typeof trustedContext.tenantId === "string" ? trustedContext.tenantId.trim() : void 0;
|
|
217645
217640
|
return { request, userId, ...tenantId ? { tenantId } : {} };
|
|
217646
217641
|
};
|
|
217647
217642
|
var parseFunctionActionMcpProxyInput = (value) => {
|
|
217648
|
-
if (!
|
|
217643
|
+
if (!isRecord7(value)) throw new Error("function action request is invalid");
|
|
217649
217644
|
const trustedContext = value._trustedContext_;
|
|
217650
|
-
const userId =
|
|
217645
|
+
const userId = isRecord7(trustedContext) && typeof trustedContext.userId === "string" ? trustedContext.userId.trim() : "";
|
|
217651
217646
|
if (!userId) {
|
|
217652
217647
|
throw new Error("function action trusted context is invalid");
|
|
217653
217648
|
}
|
|
@@ -217659,7 +217654,7 @@ var writeJson = (res, status, value) => {
|
|
|
217659
217654
|
res.writeHead(status, { "content-type": "application/json; charset=utf-8" });
|
|
217660
217655
|
res.end(JSON.stringify(value));
|
|
217661
217656
|
};
|
|
217662
|
-
var
|
|
217657
|
+
var isRecord7 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
217663
217658
|
var errorMessage4 = (error40) => error40 instanceof Error ? error40.message : "unknown agent error";
|
|
217664
217659
|
var main = async () => {
|
|
217665
217660
|
const input = decodeInput();
|
|
@@ -217754,8 +217749,8 @@ var main = async () => {
|
|
|
217754
217749
|
agentId: protocol.agentId,
|
|
217755
217750
|
remoteBaseUrl: config2.get("LINKQUE_OPEN_MCP_BASE_URL"),
|
|
217756
217751
|
signEndpoint: config2.get("LINKQUE_MCP_SIGN_ENDPOINT"),
|
|
217757
|
-
//
|
|
217758
|
-
verifyTokenEndpoint: config2.
|
|
217752
|
+
// 与启动日志共用环境配置解析;未知网关无默认地址,由运行时拒绝缺失配置。
|
|
217753
|
+
verifyTokenEndpoint: config2.get("LINKQUEGW_TOKEN_VERIFY_ENDPOINT") || void 0
|
|
217759
217754
|
});
|
|
217760
217755
|
return new RemoteGatewayMcpServerProvider({
|
|
217761
217756
|
resolveConfig,
|